Repository navigation
Add langchain instrumentation - #10
Merged
Hector Hernandez (hectorhdzg) merged 3 commits intoApr 10, 2026
Merged
Hector Hernandez (hectorhdzg) merged 3 commits into
Hector Hernandez (hectorhdzg) merged 3 commits into
Conversation
Hector Hernandez (hectorhdzg)
requested review from
Jackson Weber (JacksonWeber),
Nev (MSNev),
Leighton Chen (lzchen) and
Radhika Gupta (rads-1996)
as code owners
April 9, 2026 22:32
Member
|
Could you add a sample app for langchain instrumentation as well, so the usage with the distro can be demonstrated? Or are you planning to add it in another PR? |
Member
|
LGTM, having a langchain sample would be quite useful. |
Radhika Gupta (rads-1996)
approved these changes
Apr 10, 2026
Radhika Gupta (rads-1996)
left a comment
Member
There was a problem hiding this comment.
A change log entry should be added
Copilot started reviewing on behalf of
Hector Hernandez (hectorhdzg)
April 10, 2026 16:17
View session
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a LangChain/LangGraph → OpenTelemetry tracing bridge under src/genai/, emitting spans annotated with GenAI semantic convention attributes and providing a CallbackManager patching instrumentor.
Changes:
- Introduces GenAI semantic convention constants and LangChain instrumentation implementation (tracer, utils, instrumentor).
- Adds extensive unit + functional tests validating span naming, attributes, filtering, parent/child relationships, and content-recording gating.
- Adds
@langchain/coreto dev dependencies (and lockfile updates).
Reviewed changes
Copilot reviewed 16 out of 17 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| test/internal/unit/genai/langchain/utils.test.ts | Unit tests for LangChain utils attribute extraction/mapping. |
| test/internal/unit/genai/langchain/tracer.test.ts | Unit tests for tracer lifecycle, filtering, parent/child, and caps. |
| test/internal/unit/genai/langchain/langchainTraceInstrumentor.test.ts | Unit tests for CallbackManager patching and handler injection behavior. |
| test/internal/functional/langchain.test.ts | End-to-end functional test using InMemorySpanExporter. |
| src/genai/utils.ts | Adds attribute-value truncation helper (currently unused by LangChain code). |
| src/genai/semconv.ts | Adds GenAI semconv constants used by instrumentation/tests. |
| src/genai/instrumentations/langchain/utils.ts | Extracts operation/model/provider/messages/tool/session/token attributes from LangChain runs. |
| src/genai/instrumentations/langchain/tracer.ts | Implements BaseTracer bridge to create/end OTel spans per LangChain run. |
| src/genai/instrumentations/langchain/langchainTraceInstrumentor.ts | Implements an OTel InstrumentationBase wrapper that patches LangChain CallbackManager handlers. |
| src/genai/instrumentations/langchain/index.ts | Re-exports LangChain tracer/instrumentor. |
| src/genai/index.ts | Re-exports GenAI semconv constants. |
| package.json | Adds @langchain/core devDependency. |
| package-lock.json | Lockfile updates including @langchain/core and related packages. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Radhika Gupta (rads-1996)
approved these changes
Apr 10, 2026
Hector Hernandez (hectorhdzg)
merged commit Apr 10, 2026
a29a246
into
microsoft:main
5 checks passed
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.