feat(examples): add Pydantic AI zero-code OTLP example#117
Conversation
5fffa96 to
e47fd28
Compare
krisztianfekete
left a comment
There was a problem hiding this comment.
I think we should drop the unnecessary logging related boilerplate, the unused ENV var, align the tests, and then we are good.
| endpoint = os.environ.get("OTEL_EXPORTER_OTLP_ENDPOINT", "http://localhost:4318") | ||
| print(f"OTLP endpoint: {endpoint}") | ||
|
|
||
| os.environ.setdefault("OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT", "true") |
There was a problem hiding this comment.
Hm, taking a closer look at their SDK. Are you sure this ENV var is being used?
There was a problem hiding this comment.
I see. It was not used. I should have review the code again more thoroughly. Thank you very much!
| # Pydantic AI uses both spans (for structure/metadata) and log records | ||
| # (for message content). Both providers are required to capture full | ||
| # conversation content in agentevals. | ||
| tracer_provider = TracerProvider(resource=resource) | ||
| tracer_provider.add_span_processor(BatchSpanProcessor(OTLPSpanExporter(), schedule_delay_millis=1000)) | ||
| trace.set_tracer_provider(tracer_provider) | ||
|
|
||
| logger_provider = LoggerProvider(resource=resource) | ||
| logger_provider.add_log_record_processor(BatchLogRecordProcessor(OTLPLogExporter(), schedule_delay_millis=1000)) | ||
| set_logger_provider(logger_provider) |
There was a problem hiding this comment.
Looks like by default their v2 is used, which is not using logs, see https://pydantic.dev/docs/ai/integrations/logfire/#version-2-default
There was a problem hiding this comment.
Thanks for the link. I have checked the code and it already complies with the defaults. Thank you very much again!
e47fd28 to
2cceab5
Compare
Adds examples/zero-code-examples/pydantic-ai/ with run.py and requirements.txt, following the same pattern as the existing zero-code examples. Added a TestPydanticAIZeroCode E2E test class in tests/integration/test_live_agents.py and updates the examples/README.md tables to include the new example.
2cceab5 to
6b380de
Compare
|
I believe I made the changes you have suggested. Thank you very much for the time reviewing and all the suggestions! |
Addressing #92
Adds examples/zero-code-examples/pydantic-ai/ with run.py and requirements.txt, following the same pattern as the existing zero-code examples.
Added a TestPydanticAIZeroCode E2E test class in tests/integration/test_live_agents.py and updates the examples/README.md tables to include the new example.