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):
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 via appsettings.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:
|
var exporterOptions = new OtlpExporterOptions(); |
|
public OtlpExporterOptions() |
|
: this(new ConfigurationBuilder().AddEnvironmentVariables().Build(), new()) |
This is related to:
Bug Report
List of all OpenTelemetry NuGet
packages and version that you are
using (e.g.
OpenTelemetry 1.0.2):Runtime version (e.g.
net462,net48,netcoreapp3.1,net6.0etc. You canfind this information from the
*.csprojfile):Symptom
When providing the
OTEL_EXPORTER_OTLP_ENDPOINTvalue 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:
OTEL_EXPORTER_OTLP_ENDPOINTviaappsettings.jsonOTEL_EXPORTER_OTLP_ENDPOINTvia an environment variableIt produces a small log when run.
For the AppSettings scenario:
For the EnvVars scenario:
Additional Context
This happens because of the way the options instance is initialized inside the
AddOtlpExporterextension:opentelemetry-dotnet/src/OpenTelemetry.Exporter.OpenTelemetryProtocol.Logs/OtlpLogExporterHelperExtensions.cs
Line 58 in 690f7e5
opentelemetry-dotnet/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptions.cs
Lines 60 to 61 in 690f7e5
This is related to: