-
Notifications
You must be signed in to change notification settings - Fork 222
feat(js): Add OTEL support #1814
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 all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
448898a
Port OTEL to JS
jacoblee93 cebcdc2
Implement in traceable
jacoblee93 5c0be2f
Fix tests
jacoblee93 24ff81c
Implement OTEL translator and client, plumb into traceable
jacoblee93 8cfaac6
More progress
jacoblee93 a6d3458
Progress
jacoblee93 7e6247e
Simplify by creating span in traceable directly
jacoblee93 ba9fa3f
Refactor
jacoblee93 fa639f3
Fix lint
jacoblee93 cd9570b
Split out OTEL deps
jacoblee93 b1cb3c9
remove unused
jacoblee93 dc8ffbe
Merge branch 'main' of github.com:langchain-ai/langsmith-sdk into jac…
jacoblee93 fa549b4
Isolate types
jacoblee93 2894cb7
Fix deps
jacoblee93 c4a2fa9
Lint
jacoblee93 5de6792
Add entrypoint
jacoblee93 d7d12af
Format
jacoblee93 428ca53
Fix awaitPendingTraceBatches()
jacoblee93 70724bc
Don't use LangSmith exporter if tracing is disabled, adds more tests
jacoblee93 c0e7d13
Fix build
jacoblee93 6210c51
Remove unused import
jacoblee93 5d77bc4
Fix
jacoblee93 738998a
Call result callback if tracing is not enabled
jacoblee93 ade8a9a
Avoid populating span map with already ended spans
jacoblee93 d5b7a10
Simplify logic and setup
jacoblee93 1215e92
Export defaults
jacoblee93 dc563e8
Names
jacoblee93 96ffde6
Make setup code imperative, move defaults into exporter
jacoblee93 bc434a7
Add docstring
jacoblee93 86f67ab
Update docstring
jacoblee93 bf67dfb
Allow passing in a context manager on setup
jacoblee93 ddc8582
Merge branch 'main' of github.com:langchain-ai/langsmith-sdk into jac…
jacoblee93 31104e8
Version bump
jacoblee93 c20d305
Add extra check for OTEL
jacoblee93 159c029
Fix
jacoblee93 57daafc
Remove unused method
jacoblee93 1cf3d53
Fix lint
jacoblee93 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
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
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,62 @@ | ||
| // OpenTelemetry GenAI semantic convention attribute names | ||
| export const GEN_AI_OPERATION_NAME = "gen_ai.operation.name"; | ||
| export const GEN_AI_SYSTEM = "gen_ai.system"; | ||
| export const GEN_AI_REQUEST_MODEL = "gen_ai.request.model"; | ||
| export const GEN_AI_RESPONSE_MODEL = "gen_ai.response.model"; | ||
| export const GEN_AI_USAGE_INPUT_TOKENS = "gen_ai.usage.input_tokens"; | ||
| export const GEN_AI_USAGE_OUTPUT_TOKENS = "gen_ai.usage.output_tokens"; | ||
| export const GEN_AI_USAGE_TOTAL_TOKENS = "gen_ai.usage.total_tokens"; | ||
| export const GEN_AI_REQUEST_MAX_TOKENS = "gen_ai.request.max_tokens"; | ||
| export const GEN_AI_REQUEST_TEMPERATURE = "gen_ai.request.temperature"; | ||
| export const GEN_AI_REQUEST_TOP_P = "gen_ai.request.top_p"; | ||
| export const GEN_AI_REQUEST_FREQUENCY_PENALTY = | ||
| "gen_ai.request.frequency_penalty"; | ||
| export const GEN_AI_REQUEST_PRESENCE_PENALTY = | ||
| "gen_ai.request.presence_penalty"; | ||
| export const GEN_AI_RESPONSE_FINISH_REASONS = "gen_ai.response.finish_reasons"; | ||
| export const GENAI_PROMPT = "gen_ai.prompt"; | ||
| export const GENAI_COMPLETION = "gen_ai.completion"; | ||
|
|
||
| export const GEN_AI_REQUEST_EXTRA_QUERY = "gen_ai.request.extra_query"; | ||
| export const GEN_AI_REQUEST_EXTRA_BODY = "gen_ai.request.extra_body"; | ||
| export const GEN_AI_SERIALIZED_NAME = "gen_ai.serialized.name"; | ||
| export const GEN_AI_SERIALIZED_SIGNATURE = "gen_ai.serialized.signature"; | ||
| export const GEN_AI_SERIALIZED_DOC = "gen_ai.serialized.doc"; | ||
| export const GEN_AI_RESPONSE_ID = "gen_ai.response.id"; | ||
| export const GEN_AI_RESPONSE_SERVICE_TIER = "gen_ai.response.service_tier"; | ||
| export const GEN_AI_RESPONSE_SYSTEM_FINGERPRINT = | ||
| "gen_ai.response.system_fingerprint"; | ||
| export const GEN_AI_USAGE_INPUT_TOKEN_DETAILS = | ||
| "gen_ai.usage.input_token_details"; | ||
| export const GEN_AI_USAGE_OUTPUT_TOKEN_DETAILS = | ||
| "gen_ai.usage.output_token_details"; | ||
|
|
||
| // LangSmith custom attributes | ||
| export const LANGSMITH_SESSION_ID = "langsmith.trace.session_id"; | ||
| export const LANGSMITH_SESSION_NAME = "langsmith.trace.session_name"; | ||
| export const LANGSMITH_RUN_TYPE = "langsmith.span.kind"; | ||
| export const LANGSMITH_NAME = "langsmith.trace.name"; | ||
| export const LANGSMITH_METADATA = "langsmith.metadata"; | ||
| export const LANGSMITH_TAGS = "langsmith.span.tags"; | ||
| export const LANGSMITH_RUNTIME = "langsmith.span.runtime"; | ||
| export const LANGSMITH_REQUEST_STREAMING = "langsmith.request.streaming"; | ||
| export const LANGSMITH_REQUEST_HEADERS = "langsmith.request.headers"; | ||
| export const LANGSMITH_RUN_ID = "langsmith.span.id"; | ||
| export const LANGSMITH_TRACE_ID = "langsmith.trace.id"; | ||
| export const LANGSMITH_DOTTED_ORDER = "langsmith.span.dotted_order"; | ||
| export const LANGSMITH_PARENT_RUN_ID = "langsmith.span.parent_id"; | ||
|
|
||
| // GenAI event names | ||
| export const GEN_AI_SYSTEM_MESSAGE = "gen_ai.system.message"; | ||
| export const GEN_AI_USER_MESSAGE = "gen_ai.user.message"; | ||
| export const GEN_AI_ASSISTANT_MESSAGE = "gen_ai.assistant.message"; | ||
| export const GEN_AI_CHOICE = "gen_ai.choice"; | ||
|
|
||
| export const AI_SDK_LLM_OPERATIONS = [ | ||
| "ai.generateText.doGenerate", | ||
| "ai.streamText.doStream", | ||
| "ai.generateObject.doGenerate", | ||
| "ai.streamObject.doStream", | ||
| ]; | ||
|
|
||
| export const AI_SDK_TOOL_OPERATIONS = ["ai.toolCall"]; |
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.