add LlamaIndex zero-code OTLP example#134
Conversation
1b870bb to
606b84f
Compare
krisztianfekete
left a comment
There was a problem hiding this comment.
Thanks for the PR!
Have you checked LlamaIndex best practices around OTel instrumentation, e.g. https://developers.llamaindex.ai/python/framework-api-reference/observability/otel/?
The goal with these examples to leverage each framework's best practices and prove that agentevals can work meaningfully with that. If there are gaps, we should fallback to a similar approach we have here, and document this in details in the main docstring of the example.
Can you please see if you can use the official approach, and refactor the PR to follow it? I also added comments at various places where we'd like to follow existing patterns/conventions across all examples, so please also address those when you revisit the pull request.
| load_dotenv(override=True) | ||
|
|
||
|
|
||
| def roll_die(sides: int) -> int: |
There was a problem hiding this comment.
Please add docstrings to tool calls.
| result = await agent.run(q) | ||
| print(f" {result.response.content}") | ||
|
|
||
| tp.force_flush() |
There was a problem hiding this comment.
Please follow this pattern to guarantee flushes:
agentevals/examples/zero-code-examples/pydantic-ai/run.py
Lines 88 to 101 in 43bc581
| resource = Resource.create() | ||
| tp = TracerProvider(resource=resource) | ||
| tp.add_span_processor(BatchSpanProcessor(OTLPSpanExporter(), schedule_delay_millis=1000)) | ||
| trace.set_tracer_provider(tp) | ||
| lp = LoggerProvider(resource=resource) | ||
| lp.add_log_record_processor(BatchLogRecordProcessor(OTLPLogExporter(), schedule_delay_millis=1000)) |
There was a problem hiding this comment.
Please use longer, more descriptive variable names, like the other examples.
| print("OPENAI_API_KEY not set.") | ||
| return | ||
|
|
||
| os.environ["OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT"] = "true" |
There was a problem hiding this comment.
Please use setdefault
| agent = FunctionAgent( | ||
| tools=[FunctionTool.from_defaults(fn=roll_die), FunctionTool.from_defaults(fn=check_prime)], | ||
| llm=llm, | ||
| system_prompt="Use roll_die for dice rolls. Use check_prime to check if a number is prime.", |
There was a problem hiding this comment.
Please use the same system prompt we have in all other examples. When a user runs multiple examples to compare frameworks, you don't want subtle differences like this that can affect results.
606b84f to
83f5f46
Compare
|
@krisztianfekete i corrected them. I v checked the link, switched to LlamaIndexOpenTelemetry from llama-index-observability-otel which is the official approach. It handles the tracer provider setup internally so the code is simpler now. 1 thing to note: this integration is span-based only, no log export. |
Uses official LlamaIndexOpenTelemetry integration. Adds e2e tests.
83f5f46 to
f456c3a
Compare
Closes #94
Adds a LlamaIndex zero-code OTLP example.
Tested with Qwen3-32B on an OpenAI-compatible endpoint. All three queries ran and traces flushed.