Skip to content
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

Logger 'OtlpLogExporter' ignores standard settings if not coming from actual Environment Variables #4259

Closed
julealgon opened this issue Mar 3, 2023 · 1 comment · Fixed by #4916
Labels
bug Something isn't working

Comments

@julealgon
Copy link

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 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:

public OtlpExporterOptions()
: this(new ConfigurationBuilder().AddEnvironmentVariables().Build(), new())

This is related to:

@julealgon julealgon added the bug Something isn't working label Mar 3, 2023
@noahfalk
Copy link

+1 I just hit this issue. I had the configuration inside appsettings.json and was very puzzled why metrics were being reported but logs were not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants