Repository navigation
Add langchain instrumentation - #26
Merged
Radhika Gupta (rads-1996) merged 32 commits intoApr 10, 2026
Merged
Radhika Gupta (rads-1996) merged 32 commits into
Radhika Gupta (rads-1996) merged 32 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds first-party LangChain instrumentation to the Microsoft OpenTelemetry Python distro by introducing a LangChain BaseTracer implementation, an OTel BaseInstrumentor entry point for auto-discovery, and accompanying unit tests + sample.
Changes:
- Introduce
genai._langchainmodule with attribute-extraction utilities, a LangChain tracer that emits OTel spans, and an instrumentor that hooksBaseCallbackManager. - Register
langchainas a supported/preview instrumentation and add anopentelemetry_instrumentorentry point. - Add a LangChain sample and a dedicated
tests/langchain/test suite.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/langchain/test_utils.py | Unit tests for LangChain → OTel attribute extraction helpers. |
| tests/langchain/test_tracer.py | Unit tests for tracer span lifecycle, agent wrapper spans, and aggregation behavior. |
| tests/langchain/test_tracer_instrumentor.py | Unit tests for instrumentor wiring and callback-manager hook behavior. |
| tests/langchain/init.py | Marks tests.langchain as a package. |
| src/microsoft/opentelemetry/_constants.py | Adds langchain to supported instrumented libraries list. |
| src/microsoft/opentelemetry/_azure_monitor/_constants.py | Adds langchain to preview/opt-in instrumentations. |
| src/genai/_langchain/_utils.py | Implements core extraction/normalization utilities and OTel GenAI attribute mapping. |
| src/genai/_langchain/_tracer.py | Implements LangChainTracer that creates spans for runs and aggregates agent content. |
| src/genai/_langchain/_tracer_instrumentor.py | Adds OTel BaseInstrumentor to attach tracer to LangChain callback managers + convenience APIs. |
| src/genai/_langchain/init.py | Exposes LangChainInstrumentor. |
| src/genai/init.py | Introduces genai package. |
| samples/langchain/sample_langchain_instrumentation.py | Demonstrates enabling LangChain instrumentation and running LLM + agent flows. |
| pyproject.toml | Adds dependencies + registers the langchain instrumentor entry point. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Radhika Gupta (rads-1996)
force-pushed
the
add-langchain-instrumentation
branch
from
April 9, 2026 23:38
26e10a7 to
cd32b83
Compare
Radhika Gupta (rads-1996)
requested a review
from Hector Hernandez (hectorhdzg)
April 10, 2026 17:22
Hector Hernandez (hectorhdzg)
approved these changes
Apr 10, 2026
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Radhika Gupta (rads-1996)
force-pushed
the
add-langchain-instrumentation
branch
from
April 10, 2026 17:45
9c9f829 to
4c9772c
Compare
Hector Hernandez (hectorhdzg)
approved these changes
Apr 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.