Getting Trace_ID when using llamaindex native instrumentation and llama_deploy #29835
Replies: 1 comment 5 replies
-
To address the issue of obtaining the
Here's a revised version of your code with these considerations: instrumentor = LlamaIndexInstrumentor()
# Consider whether you need this global start if using observe locally
# instrumentor.start()
# create a dummy workflow
class EchoWorkflow(Workflow):
"""A dummy workflow with only one step sending back the input given."""
@step()
async def run_step(self, ev: StartEvent) -> StopEvent:
with instrumentor.observe() as trace:
message = str(ev.get("message", ""))
# Access trace_id here if needed
trace_id = trace.trace_id
print(f"Trace ID: {trace_id}")
return StopEvent(result=f"Message received: {message}")
echo_workflow = EchoWorkflow() By placing the To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I have the below sample code for a workflow (the actual code has more steps this is just a demo) and I am trying to use langfuse for instrmentation, which works perfectly fine, with the onyl difficulty being getting the trace_id
What I have tried so far:
Using langfuse_context - the trace_id does not appear tobe in the context - getting None when using instrumentor.start()
Encapsulating everything in a with statement - with
instrumentor.observe() as trace
: - getting fromtrace.trace_id
Probably this seems to be the way to go, but not sure where to place the with statement considering I am using the instrumntor.start() and I feel like there is a conflict between the two. Also it seems weird that there is not a native way to get the trace of the already started instrumentor from inside the step?
Code:
Beta Was this translation helpful? Give feedback.
All reactions