New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow Disabling Trace Exporting by Default Without Environment Variable Tampering #5194
Comments
Doing some investigating: In otel spec, otlp is the default for automatically configured exporters: I think this suggestion would need to be requested to opentelemetry-specification instead. My recommendation would be to use |
@scorpionknifes we do not want to change the SDK defaults for everyone. We just need a way to change the defaults for our application where the OpenTelemetry-mandated SDK defaults would be inappropriate. And what we are requesting is functionality that the OpenTelemetry Specification (arguably) mandates MUST be possible.
The autoexport package already has an affordance for the application to override the default span exporter using the autoexport.WithFallbackSpanExporter(func(ctx context.Context) (trace.SpanExporter, error) {
return autoexport.noopSpanExporter{}, nil
}) in application code.
No, that is not equivalent because
What exactly are you recommending; that we not use the autoexport package at all to configure tracing in our application? Our users need to be able to configure the application to export traces using the standard environment variables. |
Hey @corhere, thanks for the feedback and more context.
Originally I was recommending to default to not use autoexport if the env is not set, I think the I believe |
While
The noopSpanExporter doesn't necessarily have to be exported. One option would be to export a spanExporterFactory function compatible with package autoexport
// NoneExporterFactory can be used with the [WithFallbackSpanExporter] option
// to use "none" as the fallback span exporter.
func NoneExporterFactory(ctx context.Context) (trace.SpanExporter, error) {
return noopSpanExporter{}, nil
} If the above is still too easy to misuse, the factory could be hidden away entirely inside a special-case span option: package autoexport
func WithFallbackSpanExporterNone() SpanOption {
return withFallbackFactory[trace.SpanExporter](func(ctx context.Context) (trace.SpanExporter, error) {
return autoexport.noopSpanExporter{}, nil
})
} Or a new option could be introduced which requires no special casing: package autoexport
// WithRegisteredFallbackSpanExporter sets the fallback exporter to use
// when no exporter is configured through the OTEL_TRACES_EXPORTER
// environment variable. This function will panic if name is not
// "none", "otlp", "console" or an exporter registered with
// [RegisterSpanExporter].
func WithRegisteredFallbackSpanExporter(name string) SpanOption |
Problem Statement
In the current implementation, trace exporting is enabled by default (
OTLP
). This can cause issues because it repeatedly tries to connect to a tracing service that hasn't been set up, leading to a lot of error messages. While some people who use OpenTelemetry might expect it to send data to a local tracing service by default, this automatic behavior may not be suitable for all types of software, especially those used by others in different settings. For example, well-known software likeNginx
orEnvoy
doesn't turn on tracing automatically.Proposed Solution
Introduce a programmatically accessible mechanism to disable trace exporting by default in the OpenTelemetry Go SDK's autoexport package. This would allow applications to disable tracing without relying on environment variable manipulation, providing a clearer and more direct way to control telemetry features.
Alternatives
Change the default exporter type: Modify the
autoexport/signal.go
file to set the default expType tonone
instead ofotlp
. This straightforward approach would ensure that, in the absence of explicit configuration, no trace data is exported.Export noopSpanExporter: Making the
noopSpanExporter
type exportable would allow developers to explicitly set a no-operation span exporter. This method provides flexibility while ensuring that trace exporting can be disabled programmatically.Additional Context
This feature request is driven by the aim to enhance the usability and security of the Distribution project's OpenTelemetry integration, as discussed in Issue #4270.
I am keen to collaborate closely on this matter and would be happy to open a related Pull Request once we reach an agreement on the best way forward.
The text was updated successfully, but these errors were encountered: