opentelemetry-go
opentelemetry-go copied to clipboard
Feature request: span/ metric exporter initialization ignoring environment
Problem Statement
When deploying to a shared environment, it's possible that the system's environment variables are polluted with other application's OTel configuration that could cause issue during the exporter initialization. For example:
OTEL_RESOURCE_ATTRIBUTESmay include extra values not desired in the application's attribute configurationOTEL_EXPORTER_OTLP_ENDPOINTmight set the protocol tohttp(insecure), which the SDK currently provides no mechanism to override back to secure (see #1344)
Proposed Solution
- An entirely new API for
otlptracehttp.Neworotlpmetrichttp.New(->NewWithoutEnv) which do not read from the environment- Add a new option
WithEnvironment,WithDefault?
- Add a new option
- Add an option to the existing API
WithoutEnv
Alternatives
Currently the only alternative I've found is to call os.Unsetenv and explicitly remove the polluting environment variables
Prior Art
The resource APIs currently offer a means to initialize without inheriting values from the Environment.
resource.Defaultuses the environment, or when creating a resource explicitly one can useresource.WithFromEnv()
Additional Context
n/a
If you do not want to use an environment variable, use the os.Unsetenv function.
If you do not want to use an environment variable, use the
os.Unsetenvfunction.
I called that out in Alternatives, and is the approach I ended up going with in my application as a workaround.