Skip to content
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

feat(anthropic): instrumentation #188

Merged
merged 2 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ OpenLLMetry-JS can instrument everything that [OpenTelemetry already instruments

- ✅ OpenAI
- ✅ Azure OpenAI
- Anthropic
- Anthropic
- ✅ Cohere
- ⏳ Replicate
- ⏳ HuggingFace
Expand Down
132 changes: 132 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/instrumentation-anthropic/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
18 changes: 18 additions & 0 deletions packages/instrumentation-anthropic/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}
2 changes: 2 additions & 0 deletions packages/instrumentation-anthropic/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/dist
/coverage
55 changes: 55 additions & 0 deletions packages/instrumentation-anthropic/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# OpenTelemetry Anthropic instrumentation for Node.js

[![NPM Published Version][npm-img]][npm-url]
[![Apache License][license-image]][license-image]

This module provides automatic instrumentation for [`Anthropic Typescript SDK`](https://github.com/anthropics/anthropic-sdk-typescript) module, which may be loaded using the [`@opentelemetry/sdk-trace-node`](https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-sdk-trace-node) package and is included in the [`@traceloop/node-server-sdk`](https://www.npmjs.com/package/@traceloop/node-server-sdk) bundle.

If total installation size is not constrained, it is recommended to use the [`@traceloop/node-server-sdk`](https://www.npmjs.com/package/@traceloop/node-server-sdk) bundle for the most seamless instrumentation experience.

Compatible with OpenTelemetry JS API and SDK `1.0+`.

## Installation

```bash
npm install --save @traceloop/instrumentation-anthropic
```

## Supported Versions

- `>=0.9.1`

## Usage

To load a specific plugin, specify it in the registerInstrumentations's configuration:

```js
const { NodeTracerProvider } = require("@opentelemetry/sdk-trace-node");
const {
AnthropicInstrumentation,
} = require("@traceloop/instrumentation-anthropic");
const { registerInstrumentations } = require("@opentelemetry/instrumentation");

const provider = new NodeTracerProvider();
provider.register();

registerInstrumentations({
instrumentations: [new AnthropicInstrumentation()],
});
```

## Useful links

- For more information on OpenTelemetry, visit: <https://opentelemetry.io/>
- For more about OpenTelemetry JavaScript: <https://github.com/open-telemetry/opentelemetry-js>
- For help or feedback on this project, join us on [Slack][slack-url]

## License

Apache 2.0 - See [LICENSE][license-url] for more information.

[slack-url]: https://traceloop.com/slack
[license-url]: https://github.com/traceloop/openllmetry-js/blob/main/LICENSE
[license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat
[npm-url]: https://www.npmjs.com/package/@traceloop/instrumentation-anthropic
[npm-img]: https://badge.fury.io/js/%40traceloop%2Finstrumentation-anthropic.svg
54 changes: 54 additions & 0 deletions packages/instrumentation-anthropic/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"name": "@traceloop/instrumentation-anthropic",
"version": "0.5.29",
"description": "Anthropic Instrumentaion",
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"repository": "traceloop/openllmetry-js",
"scripts": {
"build": "rollup -c",
"lint": "eslint . --ext .ts",
"lint:fix": "eslint . --ext .ts --fix",
"test": "ts-mocha -p tsconfig.json 'test/**/*.test.ts'"
},
"keywords": [
"opentelemetry",
"nodejs",
"tracing",
"openai",
"anthropic"
],
"author": "Traceloop",
"license": "Apache-2.0",
"engines": {
"node": ">=14"
},
"files": [
"dist/**/*.js",
"dist/**/*.js.map",
"dist/**/*.d.ts",
"doc",
"LICENSE",
"README.md",
"package.json"
],
"publishConfig": {
"access": "public"
},
"dependencies": {
"@opentelemetry/core": "^1.22.0",
"@opentelemetry/instrumentation": "^0.49.0",
"@opentelemetry/semantic-conventions": "^1.22.0",
"@traceloop/ai-semantic-conventions": "^0.5.29"
},
"devDependencies": {
"@anthropic-ai/sdk": "^0.20.1",
"@pollyjs/adapter-node-http": "^6.0.6",
"@pollyjs/core": "^6.0.6",
"@pollyjs/persister-fs": "^6.0.6",
"@types/mocha": "^10.0.6",
"ts-mocha": "^10.0.0"
},
"homepage": "https://github.com/traceloop/openllmetry-js/tree/main/packages/instrumentation-anthropic"
}
Loading
Loading