Logger 'OtlpLogExporter' ignores standard settings if not coming from actual Environment Variables #4259
Description
Bug Report
List of all OpenTelemetry NuGet
packages and version that you are
using (e.g. OpenTelemetry 1.0.2
):
- OpenTelemetry.Exporter.OpenTelemetryProtocol.Logs v1.4.0-rc.4
Runtime version (e.g. net462
, net48
, netcoreapp3.1
, net6.0
etc. You can
find this information from the *.csproj
file):
- net48/net6.0/net7.0
Symptom
When providing the OTEL_EXPORTER_OTLP_ENDPOINT
value through a source other than environment variables, the setting is completely ignored for the logging configuration, but is honored for the tracing and metrics ones.
What is the expected behavior?
I'd expect for all the standard configuration keys to be honored in all 3 telemetry flows in the same way so that I can centralize and simplify my configuration.
What is the actual behavior?
Logs are not pushed to my collector address, since it keeps targeting the standard localhost endpoint.
Reproduce
https://github.com/julealgon/OTELLoggingIgnoresConfigurationSample
Sample contains 2 launch profiles:
- AppSettings: passes
OTEL_EXPORTER_OTLP_ENDPOINT
viaappsettings.json
- EnvVars: passes
OTEL_EXPORTER_OTLP_ENDPOINT
via an environment variable
It produces a small log when run.
For the AppSettings scenario:
info: OTELLoggingIgnoresConfigurationSample.Worker[0]
Worker running at: 03/03/2023 10:34:19 -03:00.
'OTEL_EXPORTER_OTLP_ENDPOINT' from env var: (null)
'OTEL_EXPORTER_OTLP_ENDPOINT' from configuration: http://192.168.0.0:4317
Otpl endpoint from OtlpExporterOptions: http://localhost:4317/
For the EnvVars scenario:
info: OTELLoggingIgnoresConfigurationSample.Worker[0]
Worker running at: 03/03/2023 10:35:07 -03:00.
'OTEL_EXPORTER_OTLP_ENDPOINT' from env var: http://192.168.0.0:4317
'OTEL_EXPORTER_OTLP_ENDPOINT' from configuration: http://192.168.0.0:4317
Otpl endpoint from OtlpExporterOptions: http://192.168.0.0:4317/
Additional Context
This happens because of the way the options instance is initialized inside the AddOtlpExporter
extension:
This is related to: