Skip to content

Commit 636d955

Browse files
committed
Merge branch 'timfish/feat/node-system-error-integration' of github.com:getsentry/sentry-javascript into timfish/feat/node-system-error-integration
2 parents 5a93302 + 0bc0789 commit 636d955

File tree

130 files changed

+2510
-482
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+2510
-482
lines changed

CHANGELOG.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
- "You miss 100 percent of the chances you don't take. — Wayne Gretzky" — Michael Scott
66

7+
## 10.2.0
8+
79
### Important Changes
810

911
- **feat(core): Add `ignoreSpans` option ([#17078](https://github.com/getsentry/sentry-javascript/pull/17078))**
@@ -25,6 +27,44 @@ Sentry.init({
2527

2628
Spans matching the filter criteria will not be recorded. Potential child spans of filtered spans will be re-parented, if possible.
2729

30+
- **feat(cloudflare,vercel-edge): Add support for OpenAI instrumentation ([#17338](https://github.com/getsentry/sentry-javascript/pull/17338))**
31+
32+
Adds support for OpenAI manual instrumentation in `@sentry/cloudflare` and `@sentry/vercel-edge`.
33+
34+
To instrument the OpenAI client, wrap it with `Sentry.instrumentOpenAiClient` and set recording settings.
35+
36+
```js
37+
import * as Sentry from '@sentry/cloudflare';
38+
import OpenAI from 'openai';
39+
40+
const openai = new OpenAI();
41+
const client = Sentry.instrumentOpenAiClient(openai, { recordInputs: true, recordOutputs: true });
42+
43+
// use the wrapped client
44+
```
45+
46+
- **ref(aws): Remove manual span creation ([#17310](https://github.com/getsentry/sentry-javascript/pull/17310))**
47+
48+
The `startTrace` option is deprecated and will be removed in a future major version. If you want to disable tracing, set `SENTRY_TRACES_SAMPLE_RATE` to `0.0`. instead. As of today, the flag does not affect traces anymore.
49+
50+
### Other Changes
51+
52+
- feat(astro): Streamline build logs ([#17301](https://github.com/getsentry/sentry-javascript/pull/17301))
53+
- feat(browser): Handles data URIs in chrome stack frames ([#17292](https://github.com/getsentry/sentry-javascript/pull/17292))
54+
- feat(core): Accumulate tokens for `gen_ai.invoke_agent` spans from child LLM calls ([#17281](https://github.com/getsentry/sentry-javascript/pull/17281))
55+
- feat(deps): Bump @prisma/instrumentation from 6.12.0 to 6.13.0 ([#17315](https://github.com/getsentry/sentry-javascript/pull/17315))
56+
- feat(deps): Bump @sentry/cli from 2.50.0 to 2.50.2 ([#17316](https://github.com/getsentry/sentry-javascript/pull/17316))
57+
- feat(deps): Bump @sentry/rollup-plugin from 4.0.0 to 4.0.2 ([#17317](https://github.com/getsentry/sentry-javascript/pull/17317))
58+
- feat(deps): Bump @sentry/webpack-plugin from 4.0.0 to 4.0.2 ([#17314](https://github.com/getsentry/sentry-javascript/pull/17314))
59+
- feat(nuxt): Do not inject trace meta-tags on cached HTML pages ([#17305](https://github.com/getsentry/sentry-javascript/pull/17305))
60+
- feat(nuxt): Streamline build logs ([#17308](https://github.com/getsentry/sentry-javascript/pull/17308))
61+
- feat(react-router): Add support for Hydrogen with RR7 ([#17145](https://github.com/getsentry/sentry-javascript/pull/17145))
62+
- feat(react-router): Streamline build logs ([#17303](https://github.com/getsentry/sentry-javascript/pull/17303))
63+
- feat(solidstart): Streamline build logs ([#17304](https://github.com/getsentry/sentry-javascript/pull/17304))
64+
- fix(nestjs): Add missing `sentry.origin` span attribute to `SentryTraced` decorator ([#17318](https://github.com/getsentry/sentry-javascript/pull/17318))
65+
- fix(node): Assign default export of `openai` to the instrumented fn ([#17320](https://github.com/getsentry/sentry-javascript/pull/17320))
66+
- fix(replay): Call `sendBufferedReplayOrFlush` when opening/sending feedback ([#17236](https://github.com/getsentry/sentry-javascript/pull/17236))
67+
2868
## 10.1.0
2969

3070
- feat(nuxt): Align build-time options to follow bundler plugins structure ([#17255](https://github.com/getsentry/sentry-javascript/pull/17255))

dev-packages/browser-integration-tests/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sentry-internal/browser-integration-tests",
3-
"version": "10.1.0",
3+
"version": "10.2.0",
44
"main": "index.js",
55
"license": "MIT",
66
"engines": {
@@ -43,7 +43,7 @@
4343
"@babel/preset-typescript": "^7.16.7",
4444
"@playwright/test": "~1.53.2",
4545
"@sentry-internal/rrweb": "2.34.0",
46-
"@sentry/browser": "10.1.0",
46+
"@sentry/browser": "10.2.0",
4747
"@supabase/supabase-js": "2.49.3",
4848
"axios": "1.8.2",
4949
"babel-loader": "^8.2.2",

dev-packages/bundle-analyzer-scenarios/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sentry-internal/bundle-analyzer-scenarios",
3-
"version": "10.1.0",
3+
"version": "10.2.0",
44
"description": "Scenarios to test bundle analysis with",
55
"repository": "git://github.com/getsentry/sentry-javascript.git",
66
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/dev-packages/bundle-analyzer-scenarios",

dev-packages/clear-cache-gh-action/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@sentry-internal/clear-cache-gh-action",
33
"description": "An internal Github Action to clear GitHub caches.",
4-
"version": "10.1.0",
4+
"version": "10.2.0",
55
"license": "MIT",
66
"engines": {
77
"node": ">=18"

dev-packages/cloudflare-integration-tests/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sentry-internal/cloudflare-integration-tests",
3-
"version": "10.1.0",
3+
"version": "10.2.0",
44
"license": "MIT",
55
"engines": {
66
"node": ">=18"
@@ -13,7 +13,7 @@
1313
"test:watch": "yarn test --watch"
1414
},
1515
"dependencies": {
16-
"@sentry/cloudflare": "10.1.0"
16+
"@sentry/cloudflare": "10.2.0"
1717
},
1818
"devDependencies": {
1919
"@cloudflare/workers-types": "^4.20250708.0",
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import * as Sentry from '@sentry/cloudflare';
2+
import { MockOpenAi } from './mocks';
3+
4+
interface Env {
5+
SENTRY_DSN: string;
6+
}
7+
8+
const mockClient = new MockOpenAi({
9+
apiKey: 'mock-api-key',
10+
});
11+
12+
const client = Sentry.instrumentOpenAiClient(mockClient);
13+
14+
export default Sentry.withSentry(
15+
(env: Env) => ({
16+
dsn: env.SENTRY_DSN,
17+
tracesSampleRate: 1.0,
18+
}),
19+
{
20+
async fetch(_request, _env, _ctx) {
21+
const response = await client.chat?.completions?.create({
22+
model: 'gpt-3.5-turbo',
23+
messages: [
24+
{ role: 'system', content: 'You are a helpful assistant.' },
25+
{ role: 'user', content: 'What is the capital of France?' },
26+
],
27+
temperature: 0.7,
28+
max_tokens: 100,
29+
});
30+
31+
return new Response(JSON.stringify(response));
32+
},
33+
},
34+
);
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import type { OpenAiClient } from '@sentry/core';
2+
3+
export class MockOpenAi implements OpenAiClient {
4+
public chat?: Record<string, unknown>;
5+
public apiKey: string;
6+
7+
public constructor(config: { apiKey: string }) {
8+
this.apiKey = config.apiKey;
9+
10+
this.chat = {
11+
completions: {
12+
create: async (...args: unknown[]) => {
13+
const params = args[0] as { model: string; stream?: boolean };
14+
// Simulate processing time
15+
await new Promise(resolve => setTimeout(resolve, 10));
16+
17+
if (params.model === 'error-model') {
18+
const error = new Error('Model not found');
19+
(error as unknown as { status: number }).status = 404;
20+
(error as unknown as { headers: Record<string, string> }).headers = { 'x-request-id': 'mock-request-123' };
21+
throw error;
22+
}
23+
24+
return {
25+
id: 'chatcmpl-mock123',
26+
object: 'chat.completion',
27+
created: 1677652288,
28+
model: params.model,
29+
system_fingerprint: 'fp_44709d6fcb',
30+
choices: [
31+
{
32+
index: 0,
33+
message: {
34+
role: 'assistant',
35+
content: 'Hello from OpenAI mock!',
36+
},
37+
finish_reason: 'stop',
38+
},
39+
],
40+
usage: {
41+
prompt_tokens: 10,
42+
completion_tokens: 15,
43+
total_tokens: 25,
44+
},
45+
};
46+
},
47+
},
48+
};
49+
}
50+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { expect, it } from 'vitest';
2+
import { createRunner } from '../../../runner';
3+
4+
// These tests are not exhaustive because the instrumentation is
5+
// already tested in the node integration tests and we merely
6+
// want to test that the instrumentation does not break in our
7+
// cloudflare SDK.
8+
9+
it('traces a basic chat completion request', async () => {
10+
const runner = createRunner(__dirname)
11+
.ignore('event')
12+
.expect(envelope => {
13+
const transactionEvent = envelope[1]?.[0]?.[1];
14+
15+
expect(transactionEvent.transaction).toBe('GET /');
16+
expect(transactionEvent.spans).toEqual(
17+
expect.arrayContaining([
18+
expect.objectContaining({
19+
data: expect.objectContaining({
20+
'gen_ai.operation.name': 'chat',
21+
'sentry.op': 'gen_ai.chat',
22+
'gen_ai.system': 'openai',
23+
'gen_ai.request.model': 'gpt-3.5-turbo',
24+
'gen_ai.request.temperature': 0.7,
25+
'gen_ai.response.model': 'gpt-3.5-turbo',
26+
'gen_ai.response.id': 'chatcmpl-mock123',
27+
'gen_ai.usage.input_tokens': 10,
28+
'gen_ai.usage.output_tokens': 15,
29+
'gen_ai.usage.total_tokens': 25,
30+
'gen_ai.response.finish_reasons': '["stop"]',
31+
}),
32+
description: 'chat gpt-3.5-turbo',
33+
op: 'gen_ai.chat',
34+
origin: 'manual',
35+
}),
36+
]),
37+
);
38+
})
39+
.start();
40+
await runner.makeRequest('get', '/');
41+
await runner.completed();
42+
});
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "worker-name",
3+
"compatibility_date": "2025-06-17",
4+
"main": "index.ts",
5+
"compatibility_flags": ["nodejs_compat"]
6+
}

dev-packages/cloudflare-integration-tests/vite.config.mts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ export default defineConfig({
2222
// already run in their own processes. We use threads instead because the
2323
// overhead is significantly less.
2424
pool: 'threads',
25+
// Run tests sequentially to avoid port conflicts with wrangler dev processes
26+
poolOptions: {
27+
threads: {
28+
singleThread: true,
29+
},
30+
},
2531
reporters: process.env.DEBUG
2632
? ['default', { summary: false }]
2733
: process.env.GITHUB_ACTIONS

0 commit comments

Comments
 (0)