diff --git a/CHANGELOG.md b/CHANGELOG.md index c78bff6ac42..6019a1330fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,8 @@ release. ([#3804](https://github.com/open-telemetry/opentelemetry-specification/pull/3804)) - Define mechanism for SDK extension components. ([#3802](https://github.com/open-telemetry/opentelemetry-specification/pull/3802)) +- Define `OTEL_CONFIG_FILE` environment variable. + ([#3805](https://github.com/open-telemetry/opentelemetry-specification/pull/3805)) ### Common diff --git a/spec-compliance-matrix.md b/spec-compliance-matrix.md index f19a36477f9..ae733976891 100644 --- a/spec-compliance-matrix.md +++ b/spec-compliance-matrix.md @@ -276,37 +276,38 @@ Disclaimer: this list of features is still a work in progress, please refer to t Note: Support for environment variables is optional. -| Feature | Go | Java | JS | Python | Ruby | Erlang | PHP | Rust | C++ | .NET | Swift | -|----------------------------------------------------------|-----|------|-----|-------------|------|--------|-----|------|-----|------|-------| -| OTEL_SDK_DISABLED | - | + | - | - | - | - | + | - | - | - | - | -| OTEL_RESOURCE_ATTRIBUTES | + | + | + | + | + | + | + | + | + | + | - | -| OTEL_SERVICE_NAME | + | + | + | + | + | + | + | | | + | | -| OTEL_LOG_LEVEL | - | - | + | [-][py1059] | + | - | + | | - | - | - | -| OTEL_PROPAGATORS | - | + | | + | + | + | + | - | - | - | - | -| OTEL_BSP_* | + | + | + | + | + | + | + | + | - | + | - | -| OTEL_BLRP_* | | + | | | | | | + | | + | | -| OTEL_EXPORTER_OTLP_* | + | + | | + | + | + | + | + | + | + | - | -| OTEL_EXPORTER_ZIPKIN_* | - | + | | + | + | - | + | - | - | + | - | -| OTEL_TRACES_EXPORTER | - | + | + | + | + | + | + | - | - | - | | -| OTEL_METRICS_EXPORTER | - | + | | + | - | - | + | - | - | - | - | -| OTEL_LOGS_EXPORTER | - | + | | + | | | + | | | - | | -| OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT | + | + | + | + | + | + | + | + | - | + | | -| OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT | + | + | + | + | + | + | + | | | + | | -| OTEL_SPAN_EVENT_COUNT_LIMIT | + | + | + | + | + | + | + | + | - | + | | -| OTEL_SPAN_LINK_COUNT_LIMIT | + | + | + | + | + | + | + | + | - | + | | -| OTEL_EVENT_ATTRIBUTE_COUNT_LIMIT | + | - | | + | + | + | + | | | + | | -| OTEL_LINK_ATTRIBUTE_COUNT_LIMIT | + | - | | + | + | + | + | | | + | | -| OTEL_LOGRECORD_ATTRIBUTE_COUNT_LIMIT | | | | | | | + | | | | | -| OTEL_LOGRECORD_ATTRIBUTE_VALUE_LENGTH_LIMIT | | | | | | | + | | | | | -| OTEL_TRACES_SAMPLER | + | + | + | + | + | + | + | - | - | - | | -| OTEL_TRACES_SAMPLER_ARG | + | + | + | + | + | + | + | - | - | - | | -| OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT | + | + | + | + | + | - | + | | | + | | -| OTEL_ATTRIBUTE_COUNT_LIMIT | + | + | + | + | + | - | + | | | + | | -| OTEL_METRIC_EXPORT_INTERVAL | - | + | | | | | + | | | + | | -| OTEL_METRIC_EXPORT_TIMEOUT | - | - | | | | | + | | | + | | -| OTEL_METRICS_EXEMPLAR_FILTER | - | + | | | | | + | | | - | | -| OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE | - | + | + | + | | | + | | | + | | -| OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION | | + | | | | | | | | | | +| Feature | Go | Java | JS | Python | Ruby | Erlang | PHP | Rust | C++ | .NET | Swift | +|----------------------------------------------------------|----|------|----|-------------|------|--------|-----|------|-----|------|-------| +| OTEL_SDK_DISABLED | - | + | - | - | - | - | + | - | - | - | - | +| OTEL_RESOURCE_ATTRIBUTES | + | + | + | + | + | + | + | + | + | + | - | +| OTEL_SERVICE_NAME | + | + | + | + | + | + | + | | | + | | +| OTEL_LOG_LEVEL | - | - | + | [-][py1059] | + | - | + | | - | - | - | +| OTEL_PROPAGATORS | - | + | | + | + | + | + | - | - | - | - | +| OTEL_BSP_* | + | + | + | + | + | + | + | + | - | + | - | +| OTEL_BLRP_* | | + | | | | | | + | | + | | +| OTEL_EXPORTER_OTLP_* | + | + | | + | + | + | + | + | + | + | - | +| OTEL_EXPORTER_ZIPKIN_* | - | + | | + | + | - | + | - | - | + | - | +| OTEL_TRACES_EXPORTER | - | + | + | + | + | + | + | - | - | - | | +| OTEL_METRICS_EXPORTER | - | + | | + | - | - | + | - | - | - | - | +| OTEL_LOGS_EXPORTER | - | + | | + | | | + | | | - | | +| OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT | + | + | + | + | + | + | + | + | - | + | | +| OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT | + | + | + | + | + | + | + | | | + | | +| OTEL_SPAN_EVENT_COUNT_LIMIT | + | + | + | + | + | + | + | + | - | + | | +| OTEL_SPAN_LINK_COUNT_LIMIT | + | + | + | + | + | + | + | + | - | + | | +| OTEL_EVENT_ATTRIBUTE_COUNT_LIMIT | + | - | | + | + | + | + | | | + | | +| OTEL_LINK_ATTRIBUTE_COUNT_LIMIT | + | - | | + | + | + | + | | | + | | +| OTEL_LOGRECORD_ATTRIBUTE_COUNT_LIMIT | | | | | | | + | | | | | +| OTEL_LOGRECORD_ATTRIBUTE_VALUE_LENGTH_LIMIT | | | | | | | + | | | | | +| OTEL_TRACES_SAMPLER | + | + | + | + | + | + | + | - | - | - | | +| OTEL_TRACES_SAMPLER_ARG | + | + | + | + | + | + | + | - | - | - | | +| OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT | + | + | + | + | + | - | + | | | + | | +| OTEL_ATTRIBUTE_COUNT_LIMIT | + | + | + | + | + | - | + | | | + | | +| OTEL_METRIC_EXPORT_INTERVAL | - | + | | | | | + | | | + | | +| OTEL_METRIC_EXPORT_TIMEOUT | - | - | | | | | + | | | + | | +| OTEL_METRICS_EXEMPLAR_FILTER | - | + | | | | | + | | | - | | +| OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE | - | + | + | + | | | + | | | + | | +| OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION | | + | | | | | | | | | | +| OTEL_CONFIG_FILE | | | | | | | | | | | | ## File Configuration diff --git a/specification/configuration/file-configuration.md b/specification/configuration/file-configuration.md index b530ee73ab1..9aceee263b6 100644 --- a/specification/configuration/file-configuration.md +++ b/specification/configuration/file-configuration.md @@ -21,6 +21,7 @@ linkTitle: File + [Create Plugin](#create-plugin) * [Operations](#operations) + [Parse](#parse) + + [Merge Environment](#merge-environment) + [Create](#create) + [Register Component Provider](#register-component-provider) - [References](#references) @@ -276,6 +277,11 @@ Parse SHOULD return an error if: * The parsed `file` content does not conform to the [configuration model](#configuration-model) schema. +#### Merge Environment + +TODO: define environment variable naming scheme with names derived from the +configuration model + #### Create Interpret [configuration model](#in-memory-configuration-model) and return SDK components. diff --git a/specification/configuration/sdk-environment-variables.md b/specification/configuration/sdk-environment-variables.md index ef4794cb046..1600c1bd7ac 100644 --- a/specification/configuration/sdk-environment-variables.md +++ b/specification/configuration/sdk-environment-variables.md @@ -8,7 +8,39 @@ aliases: # OpenTelemetry Environment Variable Specification -**Status**: [Mixed](../document-status.md) +**Status**: [Stable](../document-status.md) except where otherwise specified + +
+Table of Contents + + + +- [Implementation guidelines](#implementation-guidelines) +- [Parsing empty value](#parsing-empty-value) +- [Special configuration types](#special-configuration-types) + * [Boolean value](#boolean-value) + * [Numeric value](#numeric-value) + * [Enum value](#enum-value) + * [Duration](#duration) +- [General SDK Configuration](#general-sdk-configuration) +- [Batch Span Processor](#batch-span-processor) +- [Batch LogRecord Processor](#batch-logrecord-processor) +- [Attribute Limits](#attribute-limits) +- [Span Limits](#span-limits) +- [LogRecord Limits](#logrecord-limits) +- [OTLP Exporter](#otlp-exporter) +- [Zipkin Exporter](#zipkin-exporter) +- [Prometheus Exporter](#prometheus-exporter) +- [Exporter Selection](#exporter-selection) +- [Metrics SDK Configuration](#metrics-sdk-configuration) + * [Exemplar](#exemplar) + * [Periodic exporting MetricReader](#periodic-exporting-metricreader) +- [File Configuration](#file-configuration) +- [Language Specific Environment Variables](#language-specific-environment-variables) + + + +
The goal of this specification is to unify the environment variable names between different OpenTelemetry implementations. @@ -17,22 +49,16 @@ If they do, they SHOULD use the names listed in this document. ## Implementation guidelines -**Status**: [Stable](../document-status.md) - Environment variables MAY be handled (implemented) directly by a component, in the SDK, or in a separate component (e.g. environment-based autoconfiguration component). The environment-based configuration MUST have a direct code configuration equivalent. ## Parsing empty value -**Status**: [Stable](../document-status.md) - The SDK MUST interpret an empty value of an environment variable the same way as when the variable is unset. ## Special configuration types -**Status**: [Stable](../document-status.md) - ### Boolean value Any value that represents a Boolean MUST be set to true only by the case-insensitive string `"true"`, meaning `"True"` or `"TRUE"` are also accepted, as true. @@ -47,9 +73,9 @@ Renaming or changing the default value MUST NOT happen without a major version u If an implementation chooses to support an integer-valued environment variable, it SHOULD support nonnegative values between 0 and 2³¹ − 1 (inclusive). Individual SDKs MAY choose to support a larger range of values. > The following paragraph was added after stabilization and the requirements are -thus qualified as "SHOULD" to allow implementations to avoid breaking changes. -For new -implementations, these should be treated as MUST requirements. +> thus qualified as "SHOULD" to allow implementations to avoid breaking changes. +> For new +> implementations, these should be treated as MUST requirements. For variables accepting a numeric value, if the user provides a value the implementation cannot parse, or which is outside the valid range for the configuration item, the implementation SHOULD @@ -83,8 +109,6 @@ For example, the value `12000` indicates 12000 milliseconds, i.e., 12 seconds. ## General SDK Configuration -**Status**: [Stable](../document-status.md) - | Name | Description | Default | Notes | |--------------------------|---------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | OTEL_SDK_DISABLED | Disable the SDK for all signals | false | Boolean value. If "true", a no-op SDK implementation will be used for all telemetry signals. Any other value or absence of the variable will have no effect and the SDK will remain enabled. This setting has no effect on propagators configured through the OTEL_PROPAGATORS variable. | @@ -129,8 +153,6 @@ Depending on the value of `OTEL_TRACES_SAMPLER`, `OTEL_TRACES_SAMPLER_ARG` may b ## Batch Span Processor -**Status**: [Stable](../document-status.md) - | Name | Description | Default | Notes | | ------------------------------ | ---------------------------------------------------------------- | ------- | ----------------------------------------------------- | | OTEL_BSP_SCHEDULE_DELAY | Delay interval (in milliseconds) between two consecutive exports | 5000 | | @@ -140,8 +162,6 @@ Depending on the value of `OTEL_TRACES_SAMPLER`, `OTEL_TRACES_SAMPLER_ARG` may b ## Batch LogRecord Processor -**Status**: [Stable](../document-status.md) - | Name | Description | Default | Notes | | ------------------------------- | ---------------------------------------------------------------- | ------- | ------------------------------------------------------ | | OTEL_BLRP_SCHEDULE_DELAY | Delay interval (in milliseconds) between two consecutive exports | 1000 | | @@ -163,8 +183,6 @@ See the SDK [Attribute Limits](../common/README.md#attribute-limits) section for ## Span Limits -**Status**: [Stable](../document-status.md) - See the SDK [Span Limits](../trace/sdk.md#span-limits) section for the definition of the limits. | Name | Description | Default | Notes | @@ -178,8 +196,6 @@ See the SDK [Span Limits](../trace/sdk.md#span-limits) section for the definitio ## LogRecord Limits -**Status**: [Stable](../document-status.md) - See the SDK [LogRecord Limits](../logs/sdk.md#logrecord-limits) section for the definition of the limits. | Name | Description | Default | Notes | @@ -193,8 +209,6 @@ See [OpenTelemetry Protocol Exporter Configuration Options](../protocol/exporter ## Zipkin Exporter -**Status**: [Stable](../document-status.md) - | Name | Description | Default | | ----------------------------- | ---------------------------------------------------------------------------------- |------------------------------------- | | OTEL_EXPORTER_ZIPKIN_ENDPOINT | Endpoint for Zipkin traces | `http://localhost:9411/api/v2/spans` | @@ -220,8 +234,6 @@ _is no specified default, or configuration via environment variables_. ## Exporter Selection -**Status**: [Stable](../document-status.md) - We define environment variables for setting one or more exporters per signal. | Name | Description | Default | @@ -260,8 +272,6 @@ NOT be supported by new implementations. ## Metrics SDK Configuration -**Status**: [Mixed](../document-status.md) - ### Exemplar **Status**: [Experimental](../document-status.md) @@ -278,8 +288,6 @@ Known values for `OTEL_METRICS_EXEMPLAR_FILTER` are: ### Periodic exporting MetricReader -**Status**: [Stable](../document-status.md) - Environment variables specific for the push metrics exporters (OTLP, stdout, in-memory) that use [periodic exporting MetricReader](../metrics/sdk.md#periodic-exporting-metricreader). @@ -288,6 +296,48 @@ that use [periodic exporting MetricReader](../metrics/sdk.md#periodic-exporting- | `OTEL_METRIC_EXPORT_INTERVAL` | The time interval (in milliseconds) between the start of two export attempts. | 60000 | | | `OTEL_METRIC_EXPORT_TIMEOUT` | Maximum allowed time (in milliseconds) to export data. | 30000 | | +## File Configuration + +**Status**: [Experimental](../document-status.md) + +Environment variables involved in [file configuration](./file-configuration.md). + +| Name | Description | Default | Notes | +|------------------|------------------------------------------------------------------------------------------------------------------------------------|---------|-----------| +| OTEL_CONFIG_FILE | The path of the configuration file used to configure the SDK. If set other environment variables defined in the sdk environment variables specifications are ignored. | | See below | + +If `OTEL_CONFIG_FILE` is set, the file at the specified path is used to +call [Parse](file-configuration.md#parse), [Merge Environment](./file-configuration.md#merge-environment), [Create](file-configuration.md#create). +The implementation SHOULD log a warning if calling Merge Environment results in +changes to +the [configuration model](file-configuration.md#configuration-model). +Implementations MAY provide a mechanism to further customize the configuration +model parsed from `OTEL_CONFIG_FILE`. It SHOULD be possible to opt-in to logging +the resolved configuration model. + +Note: Environment variable overrides are available as defined +in [Merge Environment](./file-configuration.md#merge-environment), but the +environment variables described in this file are ignored. + +An example Java implementation: + +```java +OpenTelemetryConfiguration parsedModel = parse("/path/to/config.yaml"); +OpenTelemetryConfiguration modelWithEnvironment = mergeEnvironment(parsedModel); +if (parsedModel.equals(modelWithEnvironment)) { + logger.warn("Environment variables were set that overrode the configuration specified at /path/to/config.yaml"); +} +// Log at debug level so user has to opt-in to logging effective configuration +logger.debug("Effective configuration: \n" + toString(modelWithEnvironment)); +OpenTelemetrySdk sdk = create(modelWithEnvironment); +``` + +Users with complex configuration requirements (e.g. merging multiple +configuration files or non-standard merging of environment variables) are +encouraged to directly use [Parse](./file-configuration.md#parse) and +programmatically manipulate the configuration model before +calling [Create](./file-configuration.md#create). + ## Language Specific Environment Variables To ensure consistent naming across projects, this specification recommends that language specific environment variables are formed using the following convention: