feat: add auto-instrumentation to langchain agent template#835
Merged
jesseturner21 merged 1 commit intoaws:mainfrom Apr 14, 2026
Merged
Conversation
jesseturner21
approved these changes
Apr 14, 2026
jariy17
reviewed
Apr 14, 2026
| {{/if}}{{#if (eq modelProvider "Gemini")}}"langchain-google-genai >= 2.0.0", | ||
| {{/if}}{{#if (eq modelProvider "OpenAI")}}"langchain-openai >= 0.2.0", | ||
| {{/if}}"aws-opentelemetry-distro", | ||
| "opentelemetry-instrumentation-langchain", |
Collaborator
There was a problem hiding this comment.
Every other third-party dep in this file uses a >= X.Y.Z minimum pin (langgraph >= 0.2.0, bedrock-agentcore >= 1.0.3, etc.). This package is from the Traceloop/OpenLLMetry project (not AWS-controlled) and has a very active release cadence in the 0.x series. An unpinned dep could pull a breaking version for users. Same applies to the HTTP variant.
Suggested change
| "opentelemetry-instrumentation-langchain", | |
| "opentelemetry-instrumentation-langchain >= 0.38.0", |
5 tasks
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.
Description
Adds auto-instrumentation to the LangChain/LangGraph agent templates so that traces emitted by LangChain agents are compatible with AgentCore's observability and evaluation features out of the box.
Changes:
LangchainInstrumentor().instrument()at module level in both A2A and HTTP LangChain templatemain.pyfilesopentelemetry-instrumentation-langchainto the templatepyproject.tomldependencies for both A2A and HTTP variantsWhy: Without the LangChain OpenTelemetry instrumentor, traces from LangChain agents are emitted under a generic scope that the Evaluate API does not recognize. Running
agentcore run evalagainst a LangChain agent would fail with:With this change, LangChain agent traces are emitted under the
opentelemetry.instrumentation.langchainscope, andagentcore run evalsucceeds.Reference: Configuring custom observability in AgentCore
Type of Change
Testing
Verified by running
agentcore run evalagainst a LangChain agent — evaluation completes successfully instead of returning the unsupported-scope error.npm run test:unitandnpm run test:integnpm run typechecknpm run lintsrc/assets/, I rannpm run test:update-snapshotsand committed the updated snapshotsChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the
terms of your choice.