Context propagation using AWS S3 metadata #1715
-
Hello everyone, I have a Python app running on an AWS ECS container that goes out to a FTP server, fetches a file and places it in AWS' object store S3. Once a file gets placed, that creates an event which kicks off a AWS Python Lambda (serverless function) for further processing. Both the Python processes are instrumented with OTel and are production separate traces. Now I'm trying to combine them together as a single trace with the ECS span being the parent and the Lambda being the child. So far, I've been able to pass the trace headers via S3's metadata from the ECS app. `span = trace.get_current_span() traceparent = "{}-{}-{}-{}".format( s3_client.put_object(Bucket=bucket, In the Lambda, I can read traceparent :
What I need help with is creating a span in the Lambda such that it becomes a child span? Does anyone have experience doing something like this or can point me to sample code that I can reference? Appreciate your help! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Are you looking for a way to extract the trace context from carrier and use is it in your code? Probably something like this helps. ...
from opentelemetry.trace.propagation.textmap import DictGetter
from opentelemetry.trace.propagation.tracecontext import TraceContextTextMapPropagator
...
carrier = {'traceparent': '00-a9c3b99a95cc045e573e163c3ac80a77-d99d251a8caecd06-01'} # response['Metadata'] in your case?
ctx = TraceContextTextMapPropagator().extract(DictGetter(), carrier)
# with 1.0 getter/setter are optional and `extract` signature changed. It would be just
# `.extract(carrier)` as default getter is `DictGetter()`
with tracer.start_as_current_span('child', ctx):
... |
Beta Was this translation helpful? Give feedback.
Are you looking for a way to extract the trace context from carrier and use is it in your code? Probably something like this helps.