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
Hi there. I'm struggling a bit with my tracing setup. The basics work fine, but when I invoke my agent, I have already started a trace, and I want the agent to continue with the trace id that I'm sending it.
My agent is deployed to aws bedrock agentcore runtime.
# omitted: setting the OTEL_EXPORTER_OTLP_ENDPOINT and OTEL_EXPORTER_OTLP_HEADERS env vars
StrandsTelemetry().setup_otlp_exporter()
@app.entrypoint
async def process_request(payload, context):
pompt = payload['prompt']
agent = Agent(
trace_attributes={"foo":"bar"}
# other args omitted
)
async for event in agent.stream_async(prompt):
# omitted a lot of irrelevant stuff like handling tool calls and tool results
if "data" in event:
yield {"type": "text_chunk", "content": event["data"]}
What I've tried / learned:
Firstly, looking at the bedrock documentation I assumed I would be able to just send a traceparent header, but it looks like it's being ignored, my langfuse traces just get newly generated ids.
Second, I've tried to wrap the async for loop my own span. It doesn't work, but I may have missed things, I'm still working it out, but already it feels very verbose and icky
tracer: Tracer = trace_api.get_tracer(__name__)
if trace_id:
logger.info(f"Creating span context with trace_id: {trace_id}")
span_context = SpanContext(
trace_id=int(trace_id, 16),
span_id=int.from_bytes(os.urandom(8), 'big'),
is_remote=True,
trace_flags=TraceFlags(0x01)
)
ctx = trace_api.set_span_in_context(trace_api.NonRecordingSpan(span_context))
else:
logger.info("No trace_id found, using default context")
ctx = None
with tracer.start_span("process_request", context=ctx) as span:
logger.info(f"Span created successfully")
logger.info(f"Trace ID original: {trace_id}")
if trace_id:
logger.info(f"Trace ID original as int: {int(trace_id, 16)}")
logger.info(f"Trace ID from span: {format(span.get_span_context().trace_id, '032x')}")
Third, I've looked into providing my own tracer_provider when creating StrandsTelemetry() but that fails in all kinds of fancy ways.
I'm willing to look into downgrading to python 3.13, but other than that I would really appreciate some feedback regarding my expectations (i.e. it should just handle the traceparent header out of the box 🎉 )
Btw, thanks for reading all the way you magnificent reader you!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi there. I'm struggling a bit with my tracing setup. The basics work fine, but when I invoke my agent, I have already started a trace, and I want the agent to continue with the trace id that I'm sending it.
My agent is deployed to aws bedrock agentcore runtime.
What I've tried / learned:
Firstly, looking at the bedrock documentation I assumed I would be able to just send a traceparent header, but it looks like it's being ignored, my langfuse traces just get newly generated ids.
Second, I've tried to wrap the async for loop my own span. It doesn't work, but I may have missed things, I'm still working it out, but already it feels very verbose and icky
Third, I've looked into providing my own tracer_provider when creating StrandsTelemetry() but that fails in all kinds of fancy ways.
My last attempt was following the langfuse recommended way, but I ran into a wall because I'm set up with python 3.14.
I'm willing to look into downgrading to python 3.13, but other than that I would really appreciate some feedback regarding my expectations (i.e. it should just handle the traceparent header out of the box 🎉 )
Btw, thanks for reading all the way you magnificent reader you!
Beta Was this translation helpful? Give feedback.
All reactions