fix(opentelemetry): serialize TraceState before exporting to sink #1891
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What was changed
Serialize
SpanContext.TraceStatebefore calling the sink and deserialize it before passing it onto the underlyingSpanExporter.Why?
Some
SpanExporters such asOTLPTraceExporterwill callTraceState.serialize()before exporting spans. This method ended up getting removed as part of thestructuredClonethat happens when calling the sink and thus the call would fail withTypeError: _a.serialize is not a function.To prevent this we call
serialize()before calling the sink and thencreateTraceStatebefore passing it onto theSpanExporter.Checklist
Closes [Bug] opentelemetry traceState is handled properly in makeWorkflowExporter #1738
How was this tested:
Initial commit added failing test that captured the
TypeError: _a.serialize is not a functionthat happens when using aOTLPTraceExporterwhen the exporter attempts to serialize theTraceStateit received from the workflow.After fix was applied added more assertions to verify that the
TraceStatereceived by the sink is properly deserialized.N/A