Skip to content

Instantly share code, notes, and snippets.

@up1
Last active March 3, 2024 04:13
Show Gist options
  • Save up1/beb229a8b438df80f95b0a7d62a3bd6f to your computer and use it in GitHub Desktop.
Save up1/beb229a8b438df80f95b0a7d62a3bd6f to your computer and use it in GitHub Desktop.
OpenTelemetry + Test result + Prometheus + Grafana
func main() {
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt)
defer cancel()
shutdown := initProvider(ctx)
defer shutdown()
commonLabels := []attribute.KeyValue{
attribute.String("result", "[skiped|success|failure]"),
}
meter := otel.Meter("demo-client-meter")
testRequestCount, _ := meter.Int64Counter(
"test_request_count",
metric.WithDescription("The number of test result"),
)
testRequestCount.Add(ctx, 0, metric.WithAttributes(commonLabels...))
}
receivers:
otlp:
protocols:
grpc:
exporters:
prometheus:
endpoint: "0.0.0.0:8889"
namespace: promexample
const_labels:
label1: value1
logging:
loglevel: debug
file:
path: /tmp/tests.json
processors:
batch:
extensions:
health_check:
pprof:
endpoint: :1888
zpages:
endpoint: :55679
service:
extensions: [pprof, zpages, health_check]
pipelines:
traces:
receivers: [otlp]
processors: [batch]
exporters: [file, logging]
metrics:
receivers: [otlp]
processors: [batch]
exporters: [file, logging, prometheus]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment