Skip to content

Commit f40df74

Browse files
authored
feat(anthropic): instrumentation (#188)
1 parent ac68a98 commit f40df74

File tree

23 files changed

+1279
-4
lines changed

23 files changed

+1279
-4
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ OpenLLMetry-JS can instrument everything that [OpenTelemetry already instruments
105105

106106
- ✅ OpenAI
107107
- ✅ Azure OpenAI
108-
- Anthropic
108+
- Anthropic
109109
- ✅ Cohere
110110
- ⏳ Replicate
111111
- ⏳ HuggingFace

package-lock.json

+132
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"extends": ["../../.eslintrc.json"],
3+
"ignorePatterns": ["!**/*"],
4+
"overrides": [
5+
{
6+
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
7+
"rules": {}
8+
},
9+
{
10+
"files": ["*.ts", "*.tsx"],
11+
"rules": {}
12+
},
13+
{
14+
"files": ["*.js", "*.jsx"],
15+
"rules": {}
16+
}
17+
]
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/dist
2+
/coverage
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# OpenTelemetry Anthropic instrumentation for Node.js
2+
3+
[![NPM Published Version][npm-img]][npm-url]
4+
[![Apache License][license-image]][license-image]
5+
6+
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.
7+
8+
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.
9+
10+
Compatible with OpenTelemetry JS API and SDK `1.0+`.
11+
12+
## Installation
13+
14+
```bash
15+
npm install --save @traceloop/instrumentation-anthropic
16+
```
17+
18+
## Supported Versions
19+
20+
- `>=0.9.1`
21+
22+
## Usage
23+
24+
To load a specific plugin, specify it in the registerInstrumentations's configuration:
25+
26+
```js
27+
const { NodeTracerProvider } = require("@opentelemetry/sdk-trace-node");
28+
const {
29+
AnthropicInstrumentation,
30+
} = require("@traceloop/instrumentation-anthropic");
31+
const { registerInstrumentations } = require("@opentelemetry/instrumentation");
32+
33+
const provider = new NodeTracerProvider();
34+
provider.register();
35+
36+
registerInstrumentations({
37+
instrumentations: [new AnthropicInstrumentation()],
38+
});
39+
```
40+
41+
## Useful links
42+
43+
- For more information on OpenTelemetry, visit: <https://opentelemetry.io/>
44+
- For more about OpenTelemetry JavaScript: <https://github.com/open-telemetry/opentelemetry-js>
45+
- For help or feedback on this project, join us on [Slack][slack-url]
46+
47+
## License
48+
49+
Apache 2.0 - See [LICENSE][license-url] for more information.
50+
51+
[slack-url]: https://traceloop.com/slack
52+
[license-url]: https://github.com/traceloop/openllmetry-js/blob/main/LICENSE
53+
[license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat
54+
[npm-url]: https://www.npmjs.com/package/@traceloop/instrumentation-anthropic
55+
[npm-img]: https://badge.fury.io/js/%40traceloop%2Finstrumentation-anthropic.svg
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"name": "@traceloop/instrumentation-anthropic",
3+
"version": "0.5.29",
4+
"description": "Anthropic Instrumentaion",
5+
"main": "dist/index.js",
6+
"module": "dist/index.mjs",
7+
"types": "dist/index.d.ts",
8+
"repository": "traceloop/openllmetry-js",
9+
"scripts": {
10+
"build": "rollup -c",
11+
"lint": "eslint . --ext .ts",
12+
"lint:fix": "eslint . --ext .ts --fix",
13+
"test": "ts-mocha -p tsconfig.json 'test/**/*.test.ts'"
14+
},
15+
"keywords": [
16+
"opentelemetry",
17+
"nodejs",
18+
"tracing",
19+
"openai",
20+
"anthropic"
21+
],
22+
"author": "Traceloop",
23+
"license": "Apache-2.0",
24+
"engines": {
25+
"node": ">=14"
26+
},
27+
"files": [
28+
"dist/**/*.js",
29+
"dist/**/*.js.map",
30+
"dist/**/*.d.ts",
31+
"doc",
32+
"LICENSE",
33+
"README.md",
34+
"package.json"
35+
],
36+
"publishConfig": {
37+
"access": "public"
38+
},
39+
"dependencies": {
40+
"@opentelemetry/core": "^1.22.0",
41+
"@opentelemetry/instrumentation": "^0.49.0",
42+
"@opentelemetry/semantic-conventions": "^1.22.0",
43+
"@traceloop/ai-semantic-conventions": "^0.5.29"
44+
},
45+
"devDependencies": {
46+
"@anthropic-ai/sdk": "^0.20.1",
47+
"@pollyjs/adapter-node-http": "^6.0.6",
48+
"@pollyjs/core": "^6.0.6",
49+
"@pollyjs/persister-fs": "^6.0.6",
50+
"@types/mocha": "^10.0.6",
51+
"ts-mocha": "^10.0.0"
52+
},
53+
"homepage": "https://github.com/traceloop/openllmetry-js/tree/main/packages/instrumentation-anthropic"
54+
}

0 commit comments

Comments
 (0)