opentelemetry-specification icon indicating copy to clipboard operation
opentelemetry-specification copied to clipboard

Clarification on `OTEL_SDK_DISABLED` scope

Open kaylareopelle opened this issue 11 months ago • 11 comments

What are you trying to achieve?

Ruby received a PR to implement the OTEL_SDK_DISABLED environment variable, but we're not sure how far the functionality needs to go. The PR as it stands would skip creating providers through configuration, but someone could still manually create functional providers and tracers/meters/loggers. Is that acceptable?

Additional context.

Here's the description:

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.

I took a look at https://github.com/open-telemetry/opentelemetry-python/pull/3648, and it seems like they always return no-ops when OTEL_SDK_DISABLED is true.

However, Java's implementation seems closer to the Ruby PR. Configuration is skipped, but I don't know enough about Java to know if that means you cannot create working tracers, etc.

kaylareopelle avatar Dec 10 '24 01:12 kaylareopelle

cc @open-telemetry/python-approvers @open-telemetry/java-approvers

MrAlias avatar Dec 10 '24 18:12 MrAlias

However, Java's implementation seems closer to the Ruby PR. Configuration is skipped, but I don't know enough about Java to know if that means you cannot create working tracers, etc.

If you are using the Java autoconfigure module and set OTEL_SDK_DISABLED=true then none of the autoconfigure callbacks to customize the OpenTelemetry SDK are called, and so there's no way to add your own tracers etc.

trask avatar Dec 10 '24 21:12 trask

If you are using the Java autoconfigure module and set OTEL_SDK_DISABLED=true then none of the autoconfigure callbacks to customize the OpenTelemetry SDK are called, and so there's no way to add your own tracers etc.

Thanks for clarifying, @trask. Is there a way for to use the Java SDK without the autoconfigure module? If so, does OTEL_SDK_DISABLED have any impact on that path?

kaylareopelle avatar Dec 10 '24 23:12 kaylareopelle

ya, you can use the Java SDK without the autoconfigure module, in which case OTEL_SDK_DISABLED has no effect

trask avatar Dec 11 '24 00:12 trask

Thanks, @trask!

@open-telemetry/python-approvers - Am I reading your code correctly, will OTEL_SDK_DISABLED create no-ops for all attempts at creating tracer providers, etc.?

kaylareopelle avatar Dec 13 '24 18:12 kaylareopelle

@trask thinking about your response, and reading the spec, should OTEL_SDK_DISABLED also have effect with custom SDK config (i.e. without autoconfigure)?

The way I read it

a no-op SDK implementation will be used for all telemetry signals

I understand that if I pass OTEL_SDK_DISABLED then a no-op SDK would override any other config?

danielgblanco avatar Jan 06 '25 10:01 danielgblanco

@trask thinking about your response, and reading the spec, should OTEL_SDK_DISABLED also have effect with custom SDK config (i.e. without autoconfigure)?

I think this falls under (emphasis added) https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#implementation-guidelines:

Environment variables MAY be handled (implemented) directly by a component, in the SDK, or in a separate component (e.g. environment-based autoconfiguration component).

trask avatar Jan 06 '25 19:01 trask

Thanks, @trask!

@open-telemetry/python-approvers - Am I reading your code correctly, will OTEL_SDK_DISABLED create no-ops for all attempts at creating tracer providers, etc.?

It return no-ops when calling get_logger, get_tracer and get_meter of the sdk signals providers, so it's not a no-op tracer provider but a no-op tracer.

xrmx avatar Jan 07 '25 10:01 xrmx

I think this falls under (emphasis added) https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#implementation-guidelines:

Environment variables MAY be handled (implemented) directly by a component, in the SDK, or in a separate component (e.g. environment-based autoconfiguration component).

@trask - I'm not sure I understand how this answers @danielgblanco's question. Does this mean an implementation can choose to apply an environment variable configuration only in an autoconfiguration component and have no impact on lower-level ways to access the SDK?

kaylareopelle avatar Jan 10 '25 20:01 kaylareopelle

Does this mean an implementation can choose to apply an environment variable configuration only in an autoconfiguration component and have no impact on lower-level ways to access the SDK?

yeah, this is how Java SDK works. the SDK itself has no knowledge of env vars. you have to use a separate autoconfigure module in order to create an instance of the SDK based on env vars

there are definitely pros and cons of this approach, I'd probably look at a couple of other language implementations and consider what would be best specifically for Ruby

also keep in mind that future otel configuration will be built on top of declarative config in case that has any affect on your thinking

trask avatar Jan 12 '25 02:01 trask

hi @aka14048, please ask your question in https://github.com/open-telemetry/opentelemetry-java, thanks!

trask avatar Jun 12 '25 02:06 trask