Skip to content

SDK env var config Enum values are case-insensitive#4576

Merged
carlosalberto merged 9 commits intoopen-telemetry:mainfrom
pellared:enum-casing
Jul 21, 2025
Merged

SDK env var config Enum values are case-insensitive#4576
carlosalberto merged 9 commits intoopen-telemetry:mainfrom
pellared:enum-casing

Conversation

@pellared
Copy link
Member

@pellared pellared commented Jul 2, 2025

What

Enum values provided via environment variables SHOULD be interpreted in a case-insensitive manner.
When reporting configuration errors, implementations SHOULD display the original user-provided value to aid debugging.

Why

This improves user experience by allowing more flexible configuration (e.g., OTEL_EXPORTER_OTLP_PROTOCOL=grpc and OTEL_EXPORTER_OTLP_PROTOCOL=gRPC can be treated equivalently).

This improves consistency as it is also similar to the Boolean definition which has many in common to Enum type:

Any value that represents a Boolean MUST be set to true only by the case-insensitive string "true"

Implementations

Here is an example from OTel Go (existing code from main branch) where OTEL_TRACES_SAMPLER enum value is lower-cased before comparing with known-values:

https://github.com/open-telemetry/opentelemetry-go/blob/118298edcfd5a38c7eb767bc290a528d380a79fd/sdk/trace/sampler_env.go#L49-L54

tsloughter
tsloughter previously approved these changes Jul 2, 2025
Copy link
Member

@tsloughter tsloughter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, only way to undo an approval is to make a comment it seems.

@pellared pellared dismissed tsloughter’s stale review July 2, 2025 14:15

Dismissing 😉

@pellared
Copy link
Member Author

pellared commented Jul 2, 2025

Oops, only way to undo an approval is to make a comment it seems.

Not really. I dismissed your approval.

@pellared pellared added enhancement New feature or request area:configuration Related to configuring the SDK labels Jul 2, 2025
@pellared pellared marked this pull request as ready for review July 2, 2025 14:23
@pellared pellared requested review from a team and tsloughter July 2, 2025 14:23
@pellared pellared changed the title Enum value is case-insensitive Enum values are case-insensitive Jul 2, 2025
@carlosalberto
Copy link
Contributor

Let's advertise this PR in the next spec call so maintainers can double check it.

@arminru arminru changed the title Enum values are case-insensitive SDK env var config Enum values are case-insensitive Jul 8, 2025
@github-actions
Copy link

This PR was marked stale due to lack of activity. It will be closed in 7 days.

@github-actions github-actions bot added the Stale label Jul 16, 2025
@pellared pellared removed the Stale label Jul 16, 2025
@marcalff
Copy link
Member

Note that this is an existing behavior for some enums already:

See https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk_exporters/otlp.md

The recognized (case-insensitive) values for OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE are:
The recognized (case-insensitive) values for OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION are:

Copy link
Member

@marcalff marcalff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, existing behavior.

@carlosalberto carlosalberto added this pull request to the merge queue Jul 21, 2025
Merged via the queue into open-telemetry:main with commit 2c00113 Jul 21, 2025
6 checks passed
@carlosalberto carlosalberto mentioned this pull request Aug 11, 2025
github-merge-queue bot pushed a commit that referenced this pull request Aug 13, 2025
August 2025 release.

### Logs

- Improve concurrency safety description of `LogRecordProcessor.OnEmit`.

([#4578](#4578))
- Clarify that `SeverityNumber` values are used when comparing
severities.

([#4552](#4552))

### Entities

- Mention entity references in the stability guarantees.

([#4593](#4593))

### OpenTelemetry Protocol

- Clarify protocol defaults on specification.

([#4585](#4585))

### Compatibility

- Flexibilie escaping of characters that are discouraged by Prometheus
Conventions
  in Prometheus exporters.

([#4533](#4533))
- Flexibilize addition of unit/type related suffixes in Prometheus
exporters.

([#4533](#4533))
- Define the configuration option "Translation Strategies" for
Prometheus exporters.

([#4533](#4533))
- Define conversion of Prometheus native histograms to OpenTelemetry
exponential histograms.

([#4561](#4561))
- Clarify what to do when scope attribute conflicts with name, version
and schema URL.

([#4599](#4599))

### SDK Configuration

- Enum values provided via environment variables SHOULD be interpreted
in a case-insensitive manner.

([#4576](#4576))

Co-authored-by: Armin Ruech <7052238+arminru@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:configuration Related to configuring the SDK enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants