fix(otel): align MDC log-correlation keys with JS and Python SDKs - #592
Conversation
MdcSpanEnricher injected MDC keys trace_id/span_id/traceSampled, but the JS (enrichLogContext) and Python (OtelContextLogFilter) plugins emit traceId/spanId/otelTraceSampled. This left log-trace correlation using two different field schemas across the SDKs. Rename the three MDC keys to traceId/spanId/otelTraceSampled so all six plugins (JS/Python/Java x Execution/Invocation) share one schema. Both Java plugins use these via the MdcSpanEnricher.MDC_* constants, so this reconciles both at once. Note: SLF4J MDC values are always strings, so Java's otelTraceSampled remains the string "true"/"false" (a boolean in the JS/Python log records); this value-type difference is inherent to MDC and documented in the code. Tests: +1 asserting the exact key strings (otel-plugin suite green).
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Aligns with the Java SDK rename in aws/aws-durable-execution-sdk-java#592 and the TS/Python otelTraceSampled naming.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Claude AI reviewThe rename is correct and complete at the code level. All production and test references go through the Finding (documentation, medium):
Fix: update these to Residual test risk: low. The change is a pure constant rename covered by the updated/added tests. No correctness, concurrency, replay, or serialization semantics are affected. The only downstream risk is external log-parsing/field-mapping configs (CloudWatch/Datadog), which the PR body already calls out as breaking. Reviewed commit |
Codex AI review
Reviewed commit |
Issue
aws/aws-durable-execution-conformance-tests#23 (comment)
Summary
MdcSpanEnricherinjected the MDC keystrace_id/span_id/traceSampled, but the JS (enrichLogContext) and Python (OtelContextLogFilter) plugins emittraceId/spanId/otelTraceSampled. Log↔trace correlation was therefore using two different field schemas across the SDKs (and Java's own naming was internally inconsistent — snake_case IDs but camelCasetraceSampled).This PR renames the three MDC keys to
traceId/spanId/otelTraceSampledso all six plugins (JS / Python / Java × Execution / Invocation) share one field schema.Both Java plugins reference these via the
MdcSpanEnricher.MDC_*constants, so this reconciles bothExecutionOtelPluginandInvocationOtelPluginin a single change.Field schema (after this PR)
traceIdspanIdotelTraceSampled(boolean)traceIdspanIdotelTraceSampled(boolean)traceIdspanIdotelTraceSampled(string)Residual difference (inherent, documented): SLF4J MDC stores only strings, so Java's
otelTraceSampledis the string"true"/"false"rather than a boolean. The key names are now unified across all three SDKs.Compatibility
trace_id/span_id/traceSampledkeys (log formatters, CloudWatch/Datadog field mappings) must update to the new names.Tests
+1 test asserting the exact key strings (
traceId/spanId/otelTraceSampled); existing MDC + both plugin suites pass unchanged (they reference the constants).