-
Notifications
You must be signed in to change notification settings - Fork 443
feat(llmobs): [MLOB-2989] add pydantic_ai instrumentation #13621
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Bootstrap import analysisComparison of import times between this PR and base. SummaryThe average import time from this PR is: 274 ± 2 ms. The average import time from base is: 276 ± 2 ms. The import time difference between this PR and base is: -1.16 ± 0.09 ms. Import time breakdownThe following import paths have shrunk:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just one thought about the span type and kind but otherwise so happy with how clean this was! nice work 😄
tests/snapshots/tests.contrib.pydantic_ai.test_pydantic_ai.test_agent_run.json
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left a thought, otherwise the files owned by core lgtm
This PR implements APM tracing for the PydanticAI library. Currently, the following methods are traced:
agent.Agent.iter
: captures all ways of running the agent, includingagent.run
,agent.run_sync
,agent.run_stream
, andagent.iter
tools.Tool.run
: captures tool invocationsThe only llmobs related tags set on these spans are
pydantic_ai.request.model
andpydantic_ai.request.provider
(for Pydantic Agent spans only).Below is an example script using PydanticAI for a simple math problem. Running this script with
DD_SERVICE="nicole-test" DD_ENV="nicole-test" ddtrace-run python3 agent_iter_example.py
produces the following APM trace with a span representing the agent invocation, a span representing the tool invocation, and two Open AI LLM calls that occurred during the execution.Checklist
Reviewer Checklist