Adds a Opentelemetry 'Carrier' implementation for Temporal Headers. This can be used by third party libraries to propagate Opentelemetry data via the Temporal headers. For example to propagate trace ID from the starter to workers.
I have made these changes in order for external libraries to be able to add Opentelemetry trace info to the Temporal Headers. Specifically my use case is a custom temporal interceptor that we have written.
Example usage:
import (
"go.opentelemetry.io/otel/propagation"
"go.temporal.io/sdk/interceptor"
)
carrier := temporal_propagator.TemporalHeaderCarrier(interceptor.WorkflowHeader(ctx)
// In order to copy otel TextMap data from context into Temporal Headers
propagation.TextMapPropagator.Inject(ctx, carrier)
// In order to copy the otel TextMap data from Temporal Headers into context
propagation.TextMapPropagator.Extract(ctx, carrier)
Checklist
Closes
How was this tested:
Unit test
I was unable to figure out where in the temporal interceptor code the trace ID is copied into the temporal headers, but perhaps that could be updated to use this and then it will be covered by an integration test? Appreciate any pointers on that.
What was changed
Adds a Opentelemetry 'Carrier' implementation for Temporal Headers. This can be used by third party libraries to propagate Opentelemetry data via the Temporal headers. For example to propagate trace ID from the starter to workers.
Similar to implementations for other protocols here https://github.com/open-telemetry/opentelemetry-go/blob/0485de287ec48767a58e9fc2eda30b3dc1836668/propagation/propagation.go#L104 and here https://github.com/open-telemetry/opentelemetry-go-contrib/blob/main/instrumentation/google.golang.org/grpc/otelgrpc/metadata_supplier.go#L21.
Why?
I have made these changes in order for external libraries to be able to add Opentelemetry trace info to the Temporal Headers. Specifically my use case is a custom temporal interceptor that we have written.
Example usage:
Checklist
Closes
How was this tested: Unit test I was unable to figure out where in the temporal interceptor code the trace ID is copied into the temporal headers, but perhaps that could be updated to use this and then it will be covered by an integration test? Appreciate any pointers on that.
Any docs updates needed? not sure?