-
Notifications
You must be signed in to change notification settings - Fork 144
feat: anthropic js instrumentation #2261
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
Conversation
@arizeai/openinference-core
@arizeai/openinference-instrumentation-anthropic
@arizeai/openinference-instrumentation-bedrock
@arizeai/openinference-instrumentation-bedrock-agent-runtime
@arizeai/openinference-instrumentation-beeai
@arizeai/openinference-instrumentation-langchain
@arizeai/openinference-instrumentation-mcp
@arizeai/openinference-instrumentation-openai
@arizeai/openinference-mastra
@arizeai/openinference-semantic-conventions
@arizeai/openinference-vercel
commit: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed we will follow up with a fix for token counts and prices on streaming and then do a changeset
anthropicInstrumentation.manuallyInstrument(Anthropic.default || Anthropic); | ||
|
||
async function main() { | ||
const anthropic = new Anthropic.default({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
attributes[ | ||
`${toolCallIndexPrefix}${SemanticConventions.TOOL_CALL_FUNCTION_ARGUMENTS_JSON}` | ||
] = JSON.stringify(part.input); | ||
} else if (part.type === "tool_result") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resolves #2231
Note
Adds a new JS package that instruments
@anthropic-ai/sdk
messages.create()
with OpenTelemetry/OpenInference, including streaming, tool use, token usage, examples, and tests.js/packages/openinference-instrumentation-anthropic
src/instrumentation.ts
patches@anthropic-ai/sdk
messages.create()
to emit OpenInference-compliant LLM spans, capturing model, inputs/outputs, tools, and usage; supports both promise and streaming responses.src/index.ts
re-exports instrumentation class.package.json
,tsconfig*.json
,vitest.config.ts
set up build, types, and tests.examples/basic-usage.ts
,examples/streaming.ts
,examples/tool-use.ts
showing setup, streaming, and tool-calling flows.test/instrumentation.test.ts
covers enable/disable, custom tracer provider, and trace config.README.md
with install/quickstart/config andCHANGELOG.md
for initial release.Written by Cursor Bugbot for commit da65058. This will update automatically on new commits. Configure here.