dotnet / aspire

Tools, templates, and packages to accelerate building observable, production-ready apps
https://learn.microsoft.com/dotnet/aspire
MIT License
3.91k stars 475 forks source link

NullReferenceException when log event is missing body #6703

Closed codefromthecrypt closed 11 hours ago

codefromthecrypt commented 4 days ago

Is there an existing issue for this?

Describe the bug

opentelemetry-instrumentation-openai-v2 has a configuration that results in log events missing a body. Specifically this is when OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=false.

Right now, these aren't processed properly and result in an error in the console.

Expected Behavior

log events without a body, should be processed and result in a row saying either nothing for the "message" or something like N/A

Steps To Reproduce

send a message like this to aspire's grpc endpoint

{
    "body": null,
    "severity_number": "<SeverityNumber.INFO: 9>",
    "severity_text": null,
    "attributes": {
        "gen_ai.system": "openai",
        "event.name": "gen_ai.user.message"
    },
    "dropped_attributes": 0,
    "timestamp": "2024-11-18T01:35:17.645811Z",
    "observed_timestamp": "2024-11-18T01:35:17.645818Z",
    "trace_id": "0x686742abcda6e1f53351a1b160449a75",
    "span_id": "0x77f0e85389d498f8",
    "trace_flags": 1,
    "resource": {
        "attributes": {
            "telemetry.sdk.language": "python",
            "telemetry.sdk.name": "opentelemetry",
            "telemetry.sdk.version": "1.28.1",
            "telemetry.auto.version": "0.49b1",
            "service.name": "unknown_service"
        },
        "schema_url": ""
    }
}

Exceptions (if any)

info: Aspire.Dashboard.Otlp.Storage.TelemetryRepository[0]
      Error adding log entry.
      System.NullReferenceException: Object reference not set to an instance of an object.
         at Aspire.Dashboard.Otlp.Model.OtlpHelpers.GetString(AnyValue value) in /_/src/Aspire.Dashboard/Otlp/Model/OtlpHelpers.cs:line 96
         at Aspire.Dashboard.Otlp.Model.OtlpLogEntry..ctor(LogRecord record, OtlpApplicationView logApp, OtlpScope scope, OtlpContext context) in /_/src/Aspire.Dashboard/Otlp/Model/OtlpLogEntry.cs:line 55
         at Aspire.Dashboard.Otlp.Storage.TelemetryRepository.AddLogsCore(AddContext context, OtlpApplicationView applicationView, RepeatedField`1 scopeLogs) in /_/src/Aspire.Dashboard/Otlp/Storage/TelemetryRepository.cs:line 320

.NET Version info

No response

Anything else?

I used docker run --rm -it -p 18888:18888 -p 4317:18889 --name aspire-dashboard mcr.microsoft.com/dotnet/aspire-dashboard:9.0