[opentelemetry-instrumentation-genai-dspy] Add initial setup / boilerplate - #439
Conversation
Assisted-by: Antigravity
…orkflow Assisted-by: Antigravity
There was a problem hiding this comment.
Pull request overview
Adds an initial “skeleton” instrumentation package for the dspy framework under instrumentation/, wiring it into the monorepo workspace, CI/test matrix, and documentation. The package currently provides the DSPyInstrumentor lifecycle and shared util-genai handler setup, with DSPy-specific patching intended for follow-up work.
Changes:
- Introduces the new
opentelemetry-instrumentation-genai-dspypackage scaffold (entry point, versioning, README, licensing/notice, changelog fragment). - Adds minimal unit tests and test configuration for instrumentor lifecycle.
- Wires the new package into the repo (root deps, pyright include/exclude, README table, tox envs, uv lock).
Reviewed changes
Copilot reviewed 18 out of 19 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| uv.lock | Adds the new package to the workspace lock and resolves new dependencies introduced by DSPy. |
| tox.ini | Adds oldest/latest test env wiring for the new DSPy instrumentation package. |
| README.md | Registers DSPy instrumentation in the top-level instrumentation table. |
| pyproject.toml | Adds the new package to workspace deps and to the root pyright include/exclude lists. |
| instrumentation/opentelemetry-instrumentation-genai-dspy/tests/test_instrumentor.py | Adds unit tests for instrument/uninstrument lifecycle and dependency declaration. |
| instrumentation/opentelemetry-instrumentation-genai-dspy/tests/requirements.oldest.txt | Declares oldest-factor behavior (no additional pins). |
| instrumentation/opentelemetry-instrumentation-genai-dspy/tests/requirements.latest.txt | Declares latest-factor deps for DSPy tests (including editable installs). |
| instrumentation/opentelemetry-instrumentation-genai-dspy/tests/conftest.py | Adds shared-provider instrumentation fixture via opentelemetry.test_util_genai. |
| instrumentation/opentelemetry-instrumentation-genai-dspy/tests/init.py | Establishes test package module. |
| instrumentation/opentelemetry-instrumentation-genai-dspy/src/opentelemetry/instrumentation/genai/dspy/version.py | Defines the package version. |
| instrumentation/opentelemetry-instrumentation-genai-dspy/src/opentelemetry/instrumentation/genai/dspy/package.py | Declares the dspy instrumentation dependency tuple. |
| instrumentation/opentelemetry-instrumentation-genai-dspy/src/opentelemetry/instrumentation/genai/dspy/init.py | Implements DSPyInstrumentor skeleton with completion hook wiring and handler construction. |
| instrumentation/opentelemetry-instrumentation-genai-dspy/README.rst | Adds package-level documentation and usage guidance. |
| instrumentation/opentelemetry-instrumentation-genai-dspy/pyproject.toml | Defines packaging metadata, deps, entry point, and towncrier config for the new package. |
| instrumentation/opentelemetry-instrumentation-genai-dspy/NOTICE | Adds third-party notice text for attribution. |
| instrumentation/opentelemetry-instrumentation-genai-dspy/LICENSE | Adds the Apache-2.0 license file to the package directory. |
| instrumentation/opentelemetry-instrumentation-genai-dspy/CHANGELOG.md | Adds the towncrier-managed changelog stub for the package. |
| instrumentation/opentelemetry-instrumentation-genai-dspy/.changelog/439.added | Adds a towncrier fragment describing the initial package setup. |
| instrumentation/opentelemetry-instrumentation-genai-dspy/.changelog/.gitignore | Keeps the changelog directory structure tracked. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Assisted-by: Antigravity
Pull request dashboard statusMerged · refreshed 2026-08-21 22:17 UTC Status above doesn't look right?
|
That sounds like a good fit. Earlier versions of LangGraph also had ReAct as the only canned agent loop you could use.
Were you able to check dspy with popular providers (say OpenAI, Anthropic, Gemini) uses the client libraries we already instrumented under the hood? |
|
Ah interesting it actually just uses
|
Seconding this—I’m trying to instrument LlamaIndex’s ReActAgent as an invoke_agent operation. CrewAI, LlamaIndex, and DSPy appear to use similar agent architectures, such as ReAct. |
|
I think if we are going to the trouble of instrumenting this package we should go ahead and instrument the model call, it's not much work and we can also support disabling it if the user wants to use I tried out
|
SGTM, maybe drop that in the issue. I'm merging this one |
Description
Initial boilerplate / setup for the
dspyinstrumentation.dspyis a bit of a tricky case. IMO the only spans this instrumentation should write (that are good matches for sem convs) areexecute_toolandinferencespans.Open inference instrumentation wraps the various
dspyprimitives (Module,Predict,Retrieve,Adapter) and create spans (which aren't in our sem convs..) for each one. What these primitives do doesn't align with any existing sem conv. Wrapping them in spans is interesting and makes some sense, as it describes what the framework is doing internally..There is 1 built in Module
ReAct(https://dspy.ai/diving-deeper/react/) which triggers what they call an "agentic loop".. so probably that one could be an invoke agent span..Also
dspyis yet another python library that wraps inference calls (adk,agno, and lots of other libraries do this too), so we have the same issue of double instrumentation when the model is also instrumented. The way I think we should resolve this is for thedspyinstrumentation to check if the correspondingmodelinstrumentation is installed and active. If it is, don't instrument the model call.We can eventually add an env var that allows the user to choose which span they want (or both), but I assume if they have the model level instrumentation enabled they prefer to have the span from that.
Type of change
How has this been tested?
Unit tests
Checklist