-
Notifications
You must be signed in to change notification settings - Fork 67
feat(langchain): implement callback-based instrumentation with auto-injection #649
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
Merged
Merged
Changes from 11 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
ed79220
feat(langchain): implement callback-based instrumentation with auto-i…
nirga 7759fb4
fix: resolve lint errors and warnings
nirga 50fcc66
fix: update test assertions for callback-based instrumentation
nirga 6b4a270
fix: resolve require() issue and apply prettier formatting
nirga b4003af
refactor: simplify to single span per chat model call
nirga 6e6b639
refactor: make handleLLMStart consistent with handleChatModelStart
nirga ea3b08b
feat: add response model attribute for complete semantic coverage
nirga 1bcbeb5
fix: correct span naming to match Python implementation
nirga 51b8557
fix: apply prettier formatting to LangChain instrumentation
nirga d4424b4
refactor: remove debug console.log statements
nirga aa7ed30
fix: add eslint disable for require() in TypeScript build
nirga 7506cc4
fix: resolve TypeScript build error with @types/node
nirga 656265d
chore: update pnpm lockfile after adding @types/node
nirga 6af4c33
fix: correct Cohere response parsing for finish_reason
nirga c0c6b94
Merge branch 'main' into feat/langchain-callback-instrumentation
nirga add8309
Update packages/instrumentation-langchain/src/callback_handler.ts
nirga 54c66fc
Update packages/instrumentation-langchain/src/callback_handler.ts
nirga File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
114 changes: 114 additions & 0 deletions
114
...3722718/should-set-attributes-in-span-for-BedrockChat-with-tools_4092244032/recording.har
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| { | ||
| "log": { | ||
| "_recordingName": "Test Langchain instrumentation/should set attributes in span for BedrockChat with tools", | ||
| "creator": { | ||
| "comment": "persister:fs", | ||
| "name": "Polly.JS", | ||
| "version": "6.0.6" | ||
| }, | ||
| "entries": [ | ||
| { | ||
| "_id": "33d0981109e372ba00d53a7539abbf6c", | ||
| "_order": 0, | ||
| "cache": {}, | ||
| "request": { | ||
| "bodySize": 181, | ||
| "cookies": [], | ||
| "headers": [ | ||
| { | ||
| "name": "accept", | ||
| "value": "application/json" | ||
| }, | ||
| { | ||
| "name": "content-type", | ||
| "value": "application/json" | ||
| }, | ||
| { | ||
| "name": "host", | ||
| "value": "bedrock-runtime.us-east-1.amazonaws.com" | ||
| }, | ||
| { | ||
| "name": "x-amz-content-sha256", | ||
| "value": "310e77b0f186ec71e53132330f18b74d81cec1ef6123bdfb6e7bb1d60acc149a" | ||
| }, | ||
| { | ||
| "name": "x-amz-date", | ||
| "value": "20250817T135829Z" | ||
| } | ||
| ], | ||
| "headersSize": 599, | ||
| "httpVersion": "HTTP/1.1", | ||
| "method": "POST", | ||
| "postData": { | ||
| "mimeType": "application/json", | ||
| "params": [], | ||
| "text": "{\"anthropic_version\":\"bedrock-2023-05-31\",\"messages\":[{\"role\":\"user\",\"content\":\"What is a popular landmark in the most populous city in the US?\"}],\"max_tokens\":1024,\"temperature\":0}" | ||
| }, | ||
| "queryString": [], | ||
| "url": "https://bedrock-runtime.us-east-1.amazonaws.com/model/us.anthropic.claude-3-7-sonnet-20250219-v1:0/invoke" | ||
| }, | ||
| "response": { | ||
| "bodySize": 636, | ||
| "content": { | ||
| "mimeType": "application/json", | ||
| "size": 636, | ||
| "text": "{\"id\":\"msg_bdrk_012QekNLTDnyWFKgKZZvt5bU\",\"type\":\"message\",\"role\":\"assistant\",\"model\":\"claude-3-7-sonnet-20250219\",\"content\":[{\"type\":\"text\",\"text\":\"One of the most popular landmarks in New York City (the most populous city in the US) is the Statue of Liberty. Other famous landmarks include the Empire State Building, Times Square, Central Park, and the Brooklyn Bridge. These iconic sites attract millions of visitors each year and are symbols of the city recognized worldwide.\"}],\"stop_reason\":\"end_turn\",\"stop_sequence\":null,\"usage\":{\"input_tokens\":21,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"output_tokens\":67}}" | ||
| }, | ||
| "cookies": [], | ||
| "headers": [ | ||
| { | ||
| "name": "connection", | ||
| "value": "keep-alive" | ||
| }, | ||
| { | ||
| "name": "content-length", | ||
| "value": "636" | ||
| }, | ||
| { | ||
| "name": "content-type", | ||
| "value": "application/json" | ||
| }, | ||
| { | ||
| "name": "date", | ||
| "value": "Sun, 17 Aug 2025 13:58:31 GMT" | ||
| }, | ||
| { | ||
| "name": "x-amzn-bedrock-input-token-count", | ||
| "value": "21" | ||
| }, | ||
| { | ||
| "name": "x-amzn-bedrock-invocation-latency", | ||
| "value": "1556" | ||
| }, | ||
| { | ||
| "name": "x-amzn-bedrock-output-token-count", | ||
| "value": "67" | ||
| }, | ||
| { | ||
| "name": "x-amzn-requestid", | ||
| "value": "05d04cc7-d04a-4303-ae05-764aae5b533a" | ||
| } | ||
| ], | ||
| "headersSize": 290, | ||
| "httpVersion": "HTTP/1.1", | ||
| "redirectURL": "", | ||
| "status": 200, | ||
| "statusText": "OK" | ||
| }, | ||
| "startedDateTime": "2025-08-17T13:58:29.310Z", | ||
| "time": 2038, | ||
| "timings": { | ||
| "blocked": -1, | ||
| "connect": -1, | ||
| "dns": -1, | ||
| "receive": 0, | ||
| "send": 0, | ||
| "ssl": -1, | ||
| "wait": 2038 | ||
| } | ||
| } | ||
| ], | ||
| "pages": [], | ||
| "version": "1.2" | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.