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

Semantic Convention not fully working #5342

Closed
smoms opened this issue Feb 10, 2024 · 2 comments
Closed

Semantic Convention not fully working #5342

smoms opened this issue Feb 10, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@smoms
Copy link

smoms commented Feb 10, 2024

Why standard exception fields like exception.message and exception.stacktrace. are NOT visible in the following output?

I have the ILogger configured for using OTel.
When I log this error on Console:

try
{
...
int num1 = 5, num2 = 0, division_res = 0;
division_res = num1 / num2;
}
catch (Exception ex)
{
    logger.LogError(ex, "You divided by 0");
}

I get on Console:

fail: Program[0]
      "You divided by 0
      System.DivideByZeroException: Attempted to divide by zero.
         at Program.<<Main>$>g__HandleRollDice|0_4(ILogger`1 logger, String player) in C:\...\Program.cs:line 85
LogRecord.Timestamp:               2024-02-06T07:57:44.2418249Z
LogRecord.TraceId:                 d73bd4a40d4c4ca764ac87b0aa392b04
LogRecord.SpanId:                  b735f0c40f6c7243
LogRecord.TraceFlags:              Recorded
LogRecord.CategoryName:            Program
LogRecord.Severity:                Error
LogRecord.SeverityText:            Error
LogRecord.Body:                    "You divided by 0
LogRecord.Attributes (Key:Value):
    OriginalFormat (a.k.a Body): Y"You divided by 0
LogRecord.Exception:               System.DivideByZeroException: Attempted to divide by zero.

I do not see anywhere those attributes?

Furthermore, the same beahaviour appears with OTel Exporter too:

2024-02-09 12:15:47.005	
{
  "body": "You shall not divide by 0",
  "traceid": "a9b25c950fcadf6bc37ad7a88af58cfc",
  "spanid": "67687d1a30e805fd",
  "severity": "Error",
  "flags": 1,
  "resources": {
    "service.instance.id": "38033f53-0fb8-490c-8261-c2c050a0def9",
    "service.name": "myService",
    "service.namespace": "myNs",
    "service.version": "1.0.0",
    "telemetry.sdk.language": "dotnet",
    "telemetry.sdk.name": "opentelemetry",
    "telemetry.sdk.version": "1.7.0"
  },
  "instrumentation_scope": {
    "name": "Program"
  }
}
@smoms smoms added the bug Something isn't working label Feb 10, 2024
@cijothomas
Copy link
Member

https://github.com/open-telemetry/opentelemetry-dotnet/blob/main/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md#unreleased

From the next release of OTLP Exporter onwards, this will happen by default. Else, use OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES to turn it on.

Unfortunately, the doc is not updated... https://github.com/open-telemetry/opentelemetry-dotnet/blob/main/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md#otlp-log-exporter

ConsoleExporter exports exception as is. It could be modified to emit them as if they are attributes..

@cijothomas
Copy link
Member

#5343 will fix the doc. Given there is no bug, closing this issue.

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

No branches or pull requests

2 participants