You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[This issue is a meant as a landing spot for anyone searching.]
Issue: When upgrading to OpenTelemetry.dll v1.5.0 - v1.7.0 users may lose attributes added by custom LogRecord processors
Who is impacted?
Users attempting to enrich LogRecord instances via a BaseProcessor<LogRecord> implementation by setting onlyLogRecord.State. For example:
privatesealedclassLogEnrichmentProcessor:BaseProcessor<LogRecord>{publicoverridevoidOnEnd(LogRecorddata){if(data.StateisIReadOnlyList<KeyValuePair<string,object?>>listOfKvp){data.State=this.AddFields(listOfKvp);}}privateIReadOnlyList<KeyValuePair<string,object?>>AddFields(IReadOnlyList<KeyValuePair<string,object?>>stateValues){// Implementation not shown}}
What happens?
Starting with OpenTelemetry v1.5.0 the SDK will automatically set Attributes \ StateValues if the logged TState implements IReadOnlyList or IEnumerable of KeyValuePair<string, object?>.
When the OnEnd code above executes, LogRecord.State & LogRecord.Attributes \ LogRecord.StateValues are in sync. But when it exits, they are out of sync.
Depending on the exporter(s) being used, data loss may occur:
If an exporter looks at Attributes \ StateValues first, it will export the original (prior to enrichment) attributes and the enriched attributes will be lost.
If an exporter looks at State first, everything should work fine and the enriched data will be exported.
[This issue is a meant as a landing spot for anyone searching.]
Issue: When upgrading to
OpenTelemetry.dllv1.5.0 - v1.7.0 users may lose attributes added by customLogRecordprocessorsWho is impacted?
Users attempting to enrich
LogRecordinstances via aBaseProcessor<LogRecord>implementation by setting onlyLogRecord.State. For example:What happens?
Starting with OpenTelemetry v1.5.0 the SDK will automatically set
Attributes\StateValuesif the loggedTStateimplementsIReadOnlyListorIEnumerableofKeyValuePair<string, object?>.When the
OnEndcode above executes,LogRecord.State&LogRecord.Attributes\LogRecord.StateValuesare in sync. But when it exits, they are out of sync.Depending on the exporter(s) being used, data loss may occur:
If an exporter looks at
Attributes\StateValuesfirst, it will export the original (prior to enrichment) attributes and the enriched attributes will be lost.If an exporter looks at
Statefirst, everything should work fine and the enriched data will be exported.Is there a fix?
Upgrade to an OpenTelemetry SDK >v1.7.0 which includes [sdk-logs] Keep LogRecord.State & LogRecord.Attributes in sync if either is updated by a log processor #5169 to keep
State&Attributes\StateValuesin sync automatically.Or update the log processor to do this:
Setting both
StateandStateValues(orAttributes) will work for all known SDK versions.