open-telemetry / opentelemetry-dotnet

The OpenTelemetry .NET Client
https://opentelemetry.io
Apache License 2.0
3.23k stars 765 forks source link

Exception Logging #5719

Closed joaoluizalbuquerque closed 4 months ago

joaoluizalbuquerque commented 4 months ago

What is the question?

Hi, guys.

Recently I've been trying to figure out why some of my API's don't log exceptions. When I call _logger.LogError(ex, "Error message"); it seems like the log is ignored by the SDK, although it's shown in stdout.

I tried taking a look at the open telemetry collector logs and I can see the following three attributes for another API with the same instrumentation: exception.type, exception.message, exception.stacktrace, but they don't appear for the API in question. I also tried using the self diagnose tool but it don't show any Waning/Error logs.

So my question is: Is there any SDK setting for disabling logs with exceptions? Or disabling stack traces? (It also doesn't seem like a log length limit as I have already tried logging a really long string and it worked)

Additional context

I'm using .Net 7; "OpenTelemetry.Instrumentation.AspNetCore" Version="1.7.1"; "OpenTelemetry" Version="1.7.0"

xiang17 commented 4 months ago

Hi @joaoluizalbuquerque, how are you calling the APIs and how is it shown in stdout? (With any exporter?) Can you provide a minimal reproduce app to showcase your issue?

cijothomas commented 4 months ago

If using OTLPExporter and exception was missing - then simply update to the newest stable (1.9.0).

Exceptions were not exported by default in OTLP until recently... https://github.com/open-telemetry/opentelemetry-dotnet/blob/main/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md#180-beta1

joaoluizalbuquerque commented 4 months ago

Sorry for the delayed response. Updating to OpenTelemetry.Exporter.OpenTelemetryProtocol to 1.9.0 did the job. Thanks @cijothomas