From 5c306950e26206214ad1cadf73cff4ab19156e5e Mon Sep 17 00:00:00 2001 From: Tyler Yahn Date: Wed, 1 Sep 2021 07:14:28 -0700 Subject: [PATCH] Add support for the OTEL_SERVICE_NAME env var (#121) * Add support for the OTEL_SERVICE_NAME env var * Account for srv name in code * Rely on OTel for assignment and precedence Co-authored-by: Owais Lone --- CHANGELOG.md | 3 +++ specification/configuration.md | 17 +++++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b54fdf7f9d..6330a597158 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,11 @@ ## Unreleased +### Repository + ### Configuration +- Add support for the `OTEL_SERVICE_NAME` environment variable. - Remove suggestion for end users of instrumentation libraries to provide configuration. diff --git a/specification/configuration.md b/specification/configuration.md index 74248bc1f3a..6646763453a 100644 --- a/specification/configuration.md +++ b/specification/configuration.md @@ -110,16 +110,17 @@ beyond the OpenTelemetry specification exist. #### [OpenTelemetry Environment Variable](https://github.com/open-telemetry/opentelemetry-specification/blob/f228a83e652e5cd3ba96b9f780b704ee7a7daa4c/specification/sdk-environment-variables.md) -- `OTEL_RESOURCE_ATTRIBUTES` - - User MUST define [`service.name`](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/semantic_conventions/README.md#service) - resource attribute. - - Distribution MUST log a warning when the `service.name` resource attribute is not set. The - warning message MUST clearly describe how to set the attribute or link to relevant documentation. - E.g. +- `OTEL_SERVICE_NAME` + - Users MUST define a name for the service they are instrumenting. The + service name can either be defined using the `OTEL_SERVICE_NAME` or + `OTEL_RESOURCE_ATTRIBUTES` environment variable, or directly in their code. + If the user fails to define a service name the distribution MUST log a + warning. The warning message MUST clearly describe how to set the service + name or link to relevant documentation. E.g. ``` service.name attribute is not set, your service is unnamed and will be difficult to identify. - set your service name using the OTEL_RESOURCE_ATTRIBUTES environment variable. - E.g. `OTEL_RESOURCE_ATTRIBUTES="service.name="` + set your service name using the OTEL_SERVICE_NAME environment variable. + E.g. `OTEL_SERVICE_NAME=""` ``` - `OTEL_PROPAGATORS` - Distribution MUST default to `"tracecontext,baggage"`