Description
Component
OpenTelemetry.Exporter.OneCollector
Package Version
Package Name | Version |
---|---|
OpenTelemetry.Api | 1.8.0 |
OpenTelemetry | 1.8.0 |
TBD | TBD |
Runtime Version
1.9.2
Description
One Collector Exporter double serializing Dictionary payload with loggerMessage
Steps to Reproduce
Use LoggerMessage and Otel with a dictionary of objects indexed by strings. Send a message and notice how in fiddler the JSON is not being formed/parsed corectly.
[LoggerMessage(LogLevel.Debug, EventName = "ExtensionInitialized")]
public static partial void SendExtensionInitializedEvent(this ILogger logger, Dictionary<string, object> payload);
Expected Result
When direct logging is used everything is formed/parsed correctly.
otelLogger.Log(LogLevel.Information, new EventId(0, eventName), "{EventName}{Payload}", eventName, payload);
Actual Result
Use LoggerMessage and Otel with a dictionary of objects indexed by strings. Send a message and notice how in fiddler the JSON is not being formed/parsed corectly.
[LoggerMessage(LogLevel.Debug, EventName = "ExtensionInitialized")]
public static partial void SendExtensionInitializedEvent(this ILogger logger, Dictionary<string, object> payload);
Additional Context
We have found a partial mitigation via
[LogProperties(OmitReferenceName = true)] as described in documentation.
[LoggerMessage(LogLevel.Information, EventName = "WidgetActionStarted")]
public static partial void SendWidgetActionStartedEvent(this ILogger logger, [LogProperties(OmitReferenceName = true)] WidgetActionTelemetryEvent payload);