From 78f460c4de33bb02f9ec4f2a48197d8cbc3a4dba Mon Sep 17 00:00:00 2001 From: Marcus Efraimsson Date: Thu, 11 Apr 2024 15:18:46 +0200 Subject: [PATCH] Tracing: Allow otel service name and attributes to be overridden from env (#85937) Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> --- docs/sources/setup-grafana/configure-grafana/_index.md | 2 +- pkg/infra/tracing/tracing.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/sources/setup-grafana/configure-grafana/_index.md b/docs/sources/setup-grafana/configure-grafana/_index.md index d26b77ead9f..114f1ae6bd7 100644 --- a/docs/sources/setup-grafana/configure-grafana/_index.md +++ b/docs/sources/setup-grafana/configure-grafana/_index.md @@ -1925,7 +1925,7 @@ Configure general parameters shared between OpenTelemetry providers. Comma-separated list of attributes to include in all new spans, such as `key1:value1,key2:value2`. -Can be set with the environment variable `OTEL_RESOURCE_ATTRIBUTES` (use `=` instead of `:` with the environment variable). +Can be set or overridden with the environment variable `OTEL_RESOURCE_ATTRIBUTES` (use `=` instead of `:` with the environment variable). The service name can be set or overridden using attributes or with the environment variable `OTEL_SERVICE_NAME`. ### sampler_type diff --git a/pkg/infra/tracing/tracing.go b/pkg/infra/tracing/tracing.go index 233e8cbd604..73ad8801d55 100644 --- a/pkg/infra/tracing/tracing.go +++ b/pkg/infra/tracing/tracing.go @@ -209,6 +209,7 @@ func initTracerProvider(exp tracesdk.SpanExporter, serviceName string, serviceVe semconv.ServiceVersionKey.String(serviceVersion), ), resource.WithAttributes(customAttribs...), + resource.WithFromEnv(), resource.WithProcessRuntimeDescription(), resource.WithTelemetrySDK(), )