-
Notifications
You must be signed in to change notification settings - Fork 37
feat(cerebras): new instrumentation package #595
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
Open
airhorns
wants to merge
2
commits into
traceloop:main
Choose a base branch
from
gadget-inc:cerebras
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,005
−0
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/dist | ||
/coverage |
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,4 @@ | ||
# Change Log | ||
|
||
All notable changes to this project will be documented in this file. | ||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. |
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,53 @@ | ||
# OpenTelemetry Cerebras instrumentation for Node.js | ||
|
||
[![NPM Published Version][npm-img]][npm-url] | ||
[![Apache License][license-image]][license-image] | ||
|
||
This module provides automatic instrumentation for the [`Cerebras Node API Library`](https://www.npmjs.com/package/@cerebras/cerebras_cloud_sdk) 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. | ||
|
||
Compatible with OpenTelemetry JS API and SDK `1.0+`. | ||
|
||
## Installation | ||
|
||
```bash | ||
npm install --save @traceloop/instrumentation-cerebras | ||
``` | ||
|
||
## Supported Versions | ||
|
||
- `>=1.29.0` | ||
|
||
## Usage | ||
|
||
To load a specific plugin, specify it in the registerInstrumentations's configuration: | ||
|
||
```js | ||
const { NodeTracerProvider } = require("@opentelemetry/sdk-trace-node"); | ||
const { | ||
CerebrasInstrumentation, | ||
} = require("@traceloop/instrumentation-cerebras"); | ||
const { registerInstrumentations } = require("@opentelemetry/instrumentation"); | ||
|
||
const provider = new NodeTracerProvider(); | ||
provider.register(); | ||
|
||
registerInstrumentations({ | ||
instrumentations: [new CerebrasInstrumentation()], | ||
}); | ||
``` | ||
|
||
## 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-cerebras | ||
[npm-img]: https://badge.fury.io/js/%40traceloop%2Finstrumentation-cerebras.svg |
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,29 @@ | ||
const js = require("@eslint/js"); | ||
const rootConfig = require("../../eslint.config.cjs"); | ||
|
||
const { FlatCompat } = require("@eslint/eslintrc"); | ||
|
||
const compat = new FlatCompat({ | ||
baseDirectory: __dirname, | ||
recommendedConfig: js.configs.recommended, | ||
allConfig: js.configs.all, | ||
}); | ||
|
||
module.exports = [ | ||
{ | ||
ignores: ["!**/*", "**/node_modules", "dist/**/*"], | ||
}, | ||
...rootConfig, | ||
{ | ||
files: ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx"], | ||
rules: {}, | ||
}, | ||
{ | ||
files: ["**/*.ts", "**/*.tsx"], | ||
rules: {}, | ||
}, | ||
{ | ||
files: ["**/*.js", "**/*.jsx"], | ||
rules: {}, | ||
}, | ||
]; |
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,54 @@ | ||
{ | ||
"name": "@traceloop/instrumentation-cerebras", | ||
"version": "0.13.0", | ||
"description": "Cerebras Instrumentation", | ||
"main": "dist/index.js", | ||
"module": "dist/index.mjs", | ||
"types": "dist/index.d.ts", | ||
"repository": "traceloop/openllmetry-js", | ||
"scripts": { | ||
"build": "rollup -c", | ||
"lint": "eslint .", | ||
"lint:fix": "eslint . --fix", | ||
"test": "ts-mocha -p tsconfig.json 'tests/**/*.test.ts' --timeout 20000" | ||
}, | ||
"keywords": [ | ||
"opentelemetry", | ||
"nodejs", | ||
"tracing", | ||
"attributes", | ||
"semantic conventions" | ||
], | ||
"author": "Harry <harry@gadget.dev>", | ||
"license": "Apache-2.0", | ||
"engines": { | ||
"node": ">=14" | ||
}, | ||
"files": [ | ||
"dist/**/*.js", | ||
"dist/**/*.mjs", | ||
"dist/**/*.js.map", | ||
"dist/**/*.d.ts", | ||
"doc", | ||
"LICENSE", | ||
"README.md", | ||
"package.json" | ||
], | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"dependencies": { | ||
"@opentelemetry/core": "^1.29.0", | ||
"@opentelemetry/instrumentation": "^0.56.0", | ||
"@opentelemetry/semantic-conventions": "^1.28.0", | ||
"@traceloop/ai-semantic-conventions": "^0.12.0", | ||
"tslib": "^2.8.1" | ||
}, | ||
"devDependencies": { | ||
"@cerebras/cerebras_cloud_sdk": "^1.29.0", | ||
"@pollyjs/adapter-node-http": "^6.0.6", | ||
"@pollyjs/core": "^6.0.6", | ||
"@pollyjs/persister-fs": "^6.0.6" | ||
}, | ||
"homepage": "https://github.com/traceloop/openllmetry-js/tree/main/packages/instrumentation-cerebras" | ||
} |
223 changes: 223 additions & 0 deletions
223
...71951548/should-set-attributes-in-span-for-completions-streaming_2198009633/recording.har
Large diffs are not rendered by default.
Oops, something went wrong.
228 changes: 228 additions & 0 deletions
228
...ntation_3871951548/should-set-attributes-in-span-for-completions_1224394582/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,228 @@ | ||
{ | ||
"log": { | ||
"_recordingName": "Test Cerebras instrumentation/should set attributes in span for completions", | ||
"creator": { | ||
"comment": "persister:fs", | ||
"name": "Polly.JS", | ||
"version": "6.0.6" | ||
}, | ||
"entries": [ | ||
{ | ||
"_id": "d55bd9b854a427f6c4811664fee287af", | ||
"_order": 0, | ||
"cache": {}, | ||
"request": { | ||
"bodySize": 100, | ||
"cookies": [], | ||
"headers": [ | ||
{ | ||
"_fromType": "array", | ||
"name": "content-length", | ||
"value": "100" | ||
}, | ||
{ | ||
"_fromType": "array", | ||
"name": "accept", | ||
"value": "application/json" | ||
}, | ||
{ | ||
"_fromType": "array", | ||
"name": "content-type", | ||
"value": "application/json" | ||
}, | ||
{ | ||
"_fromType": "array", | ||
"name": "user-agent", | ||
"value": "Cerebras/JS 1.29.0" | ||
}, | ||
{ | ||
"_fromType": "array", | ||
"name": "x-stainless-lang", | ||
"value": "js" | ||
}, | ||
{ | ||
"_fromType": "array", | ||
"name": "x-stainless-package-version", | ||
"value": "1.29.0" | ||
}, | ||
{ | ||
"_fromType": "array", | ||
"name": "x-stainless-os", | ||
"value": "MacOS" | ||
}, | ||
{ | ||
"_fromType": "array", | ||
"name": "x-stainless-arch", | ||
"value": "arm64" | ||
}, | ||
{ | ||
"_fromType": "array", | ||
"name": "x-stainless-runtime", | ||
"value": "node" | ||
}, | ||
{ | ||
"_fromType": "array", | ||
"name": "x-stainless-runtime-version", | ||
"value": "v22.10.0" | ||
}, | ||
{ | ||
"_fromType": "array", | ||
"name": "x-stainless-retry-count", | ||
"value": "0" | ||
}, | ||
{ | ||
"_fromType": "array", | ||
"name": "x-stainless-timeout", | ||
"value": "60" | ||
}, | ||
{ | ||
"_fromType": "array", | ||
"name": "accept-encoding", | ||
"value": "gzip,deflate" | ||
}, | ||
{ | ||
"name": "host", | ||
"value": "api.cerebras.ai" | ||
} | ||
], | ||
"headersSize": 523, | ||
"httpVersion": "HTTP/1.1", | ||
"method": "POST", | ||
"postData": { | ||
"mimeType": "application/json", | ||
"params": [], | ||
"text": "{\n \"model\": \"llama-3.1-8b\",\n \"max_tokens\": 300,\n \"prompt\": \"Tell me a joke about OpenTelemetry\"\n}" | ||
}, | ||
"queryString": [], | ||
"url": "https://api.cerebras.ai/v1/completions" | ||
}, | ||
"response": { | ||
"bodySize": 1243, | ||
"content": { | ||
"encoding": "base64", | ||
"mimeType": "application/json", | ||
"size": 1243, | ||
"text": "[\"H4sIAAAAAAAAA5SUUWvjRhDHv8p485AXOUi249h6CSmUNgflCrlyHFVxRquRtZfVjm53VMeEQL7GQfvl8knKyk4ct1dK38Tu7P8/85vRPChTqVzpBkW3nR0vFkjllGZjwrkez8pJOcb5ksYXM5rqWYU411OVKN2w0RRU/uuDqo0zoVl5wsBO5cqSW0ujEmVcRfcqTxMldC8qV6PCfeIeNugEhOHO8QYQPvMdAZbcC7zvyH0gSy2J317ClfVm3UgCDXl6fvoagB3lhfvYbKEyFUhDx0/gpkMHa47q0pDHbntZuO9IYx8IjMAGA9RE1rg1IFgjYgkKFTprpFAj+IEEjFzCtZwGQAgdugSsiQmCNY4SKHsBtIGBWhbDDi1odrU=\",\"NVrCCK6h4Y5AGpSYKzw//SEeNVXPT39GvdZYisltufdQo6YzuGHvtwlc73Dsc0QojQDXgFEi1mZ0iBpcQ4kVNH3L/gwKV7gfyVNM1nGs+D8J/URC/oAIOvTyDUgtYeh9xNR3L6GsNQbDbhRtr1yVgCWBliDqxmpb9jtzlH9x12wtaWEPAbcvukPT9r6dZ00hGLe+LFyhPnF/6glOg+aOqlOo2cPaE4qjEEaFipm8v8OBH1atkQSun5++tnuApcFAFQhv0FdhMDMuiO9bcoKxfXD18zV4sii0p7pr8WsjKdAwoSE24vD4bT/ZHfo5sHnfJICuAlPHi928RzYxS41u4CUcBem+Yz+IBW53AP9GrOtdGMG7PsgL7TgnIyjc7e1tNDs5OYEboQ6yHH5xFfkg0Xvoree2k8J9eP0GM4w1eUMhztKx11Dn2ZHoJIfvf0fbowwwwNOXnoIU7sY4TZF6CzVby5s4KwfAOsINLx22JEI+gXYLju4FQpQ2w/XGm730jnKcAfL/UDrOaprDx9d3mqv9H9cSSTiqPP4cgP6tQTmMBLs3cXkUH4C26O8q3kQveBf3Uvb/to16/C1ROg4oVSrPLmbn6WQ+X1wkquWKbNyOFlucnmXjRakSFbZBqF3Vxq3Jd964uCbrbjXXOFsulufLtDrPJmWZLapMJYrLz6RjSFyoK81tZyniUYnqA65J5Q9qV9JK+I5cUPkyUYe419NpGrcyC9o3R8vHRIlpaWVczVHqS089reKRytOzNE0n8/QieXU4nJ+nWTadHjvtb7PpcjGbTSKCvd/LxSxbZpPl9CKbz6bpfD77JrjHx78AAAD//wMAQy/WrqIGAAA=\"]" | ||
}, | ||
"cookies": [ | ||
{ | ||
"domain": ".api.cerebras.ai", | ||
"expires": "2025-04-19T02:08:10.000Z", | ||
"httpOnly": true, | ||
"name": "__cf_bm", | ||
"path": "/", | ||
"sameSite": "None", | ||
"secure": true, | ||
"value": "oHs6p5Fn_rDuMzQ.0uzyYx49MeWog91dV537k2eJouE-1745026690-1.0.1.1-hjaRXujLd_V73iEz4.MOn7Xj9cFKTdeaQ2FjlE3LrnIlZiwJOkziuqWBYCv_D6bIPVCQlQmfh.NiltXxK8Q4bl9KNfT.LeEZgt102ae_BSc" | ||
} | ||
], | ||
"headers": [ | ||
{ | ||
"name": "date", | ||
"value": "Sat, 19 Apr 2025 01:38:10 GMT" | ||
}, | ||
{ | ||
"name": "content-type", | ||
"value": "application/json" | ||
}, | ||
{ | ||
"name": "transfer-encoding", | ||
"value": "chunked" | ||
}, | ||
{ | ||
"name": "connection", | ||
"value": "keep-alive" | ||
}, | ||
{ | ||
"name": "x-request-id", | ||
"value": "9328ae4b2a4797d2-EWR" | ||
}, | ||
{ | ||
"name": "x-ratelimit-limit-requests-day", | ||
"value": "100000" | ||
}, | ||
{ | ||
"name": "x-ratelimit-limit-tokens-minute", | ||
"value": "300000" | ||
}, | ||
{ | ||
"name": "x-ratelimit-remaining-requests-day", | ||
"value": "99997" | ||
}, | ||
{ | ||
"name": "x-ratelimit-remaining-tokens-minute", | ||
"value": "300000" | ||
}, | ||
{ | ||
"name": "x-ratelimit-reset-requests-day", | ||
"value": "80509.97288775444" | ||
}, | ||
{ | ||
"name": "x-ratelimit-reset-tokens-minute", | ||
"value": "49.97288775444031" | ||
}, | ||
{ | ||
"name": "inference-id", | ||
"value": "chatcmpl-88aeb3e4-ea6c-4b2b-a69e-74e3c4daa6c3" | ||
}, | ||
{ | ||
"name": "referrer-policy", | ||
"value": "strict-origin-when-cross-origin" | ||
}, | ||
{ | ||
"name": "x-content-type-options", | ||
"value": "nosniff" | ||
}, | ||
{ | ||
"name": "strict-transport-security", | ||
"value": "max-age=3600; includeSubDomains" | ||
}, | ||
{ | ||
"name": "cf-cache-status", | ||
"value": "DYNAMIC" | ||
}, | ||
{ | ||
"_fromType": "array", | ||
"name": "set-cookie", | ||
"value": "__cf_bm=oHs6p5Fn_rDuMzQ.0uzyYx49MeWog91dV537k2eJouE-1745026690-1.0.1.1-hjaRXujLd_V73iEz4.MOn7Xj9cFKTdeaQ2FjlE3LrnIlZiwJOkziuqWBYCv_D6bIPVCQlQmfh.NiltXxK8Q4bl9KNfT.LeEZgt102ae_BSc; path=/; expires=Sat, 19-Apr-25 02:08:10 GMT; domain=.api.cerebras.ai; HttpOnly; Secure; SameSite=None" | ||
}, | ||
{ | ||
"name": "server", | ||
"value": "cloudflare" | ||
}, | ||
{ | ||
"name": "cf-ray", | ||
"value": "9328ae4b2a4797d2-EWR" | ||
}, | ||
{ | ||
"name": "content-encoding", | ||
"value": "gzip" | ||
}, | ||
{ | ||
"name": "alt-svc", | ||
"value": "h3=\":443\"; ma=86400" | ||
} | ||
], | ||
"headersSize": 1060, | ||
"httpVersion": "HTTP/1.1", | ||
"redirectURL": "", | ||
"status": 200, | ||
"statusText": "OK" | ||
}, | ||
"startedDateTime": "2025-04-19T01:38:09.714Z", | ||
"time": 341, | ||
"timings": { | ||
"blocked": -1, | ||
"connect": -1, | ||
"dns": -1, | ||
"receive": 0, | ||
"send": 0, | ||
"ssl": -1, | ||
"wait": 341 | ||
} | ||
} | ||
], | ||
"pages": [], | ||
"version": "1.2" | ||
} | ||
} |
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.