Skip to content
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
13 changes: 7 additions & 6 deletions dev-packages/bun-integration-tests/node-suites/excludes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export const NO_AUTO_INSTRUMENTATION = [
'suites/tracing/langchain/**',
'suites/tracing/langgraph/**',
'suites/tracing/lru-memoizer/test.ts',
'suites/tracing/mastra/test.ts',
'suites/tracing/mastra/**',
'suites/tracing/mcp-handler-exact-once/test.ts',
'suites/tracing/mcp-server/**',
'suites/tracing/mistral-v2/test.ts',
Expand All @@ -116,7 +116,7 @@ export const NO_AUTO_INSTRUMENTATION = [
'suites/tracing/mysql2-tracing-channel/test.ts',
'suites/tracing/mysql2/test.ts',
'suites/tracing/neon/test.ts',
'suites/tracing/openai/test.ts',
'suites/tracing/openai/v5/**',
'suites/tracing/openai/v6/test.ts',
'suites/tracing/openai/v7/test.ts',
'suites/tracing/orchestrion-lazy-registration/test.ts',
Expand Down Expand Up @@ -235,15 +235,16 @@ const BUN_BUILD_UNBUNDLEABLE_DEPENDENCY = ['suites/tracing/mistral/test.ts'];
// `@sentry/bun` the request body comes from `bunHttpServerIntegration`.
const BUN_BUILD_NOT_TRIAGED = [
'suites/express/sentry-trace/test.ts',
'suites/express/tracing/test.ts',
'suites/express/tracing/routing/test.ts',
'suites/express/tracing/request-data/test.ts',
'suites/express/with-http/**',
'suites/hono-sdk/test.ts',
'suites/pino/test.ts',
'suites/tracing/google-genai-v2/test.ts',
'suites/tracing/google-genai/test.ts',
'suites/tracing/langchain/v1/test.ts',
'suites/tracing/langchain/v1/**',
'suites/tracing/langgraph/v1/test.ts',
'suites/tracing/mastra/test.ts',
'suites/tracing/mastra/**',
'suites/tracing/mcp-handler-exact-once/test.ts',
'suites/tracing/mcp-server-streamed/test.ts',
'suites/tracing/mongodb-v4/test.ts',
Expand All @@ -260,7 +261,7 @@ const BUN_BUILD_NOT_TRIAGED = [
'suites/tracing/mysql/test.ts',
'suites/tracing/prisma-orm-v8/test.ts',
'suites/tracing/together-ai/test.ts',
'suites/tracing/vercelai/v6_v7/test.ts',
'suites/tracing/vercelai/v6_v7/**',
];

export const BUN_BUILD_EXCLUDE = [
Expand Down
6 changes: 3 additions & 3 deletions dev-packages/deno-integration-tests/node-suites/excludes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const PRISMA_ESM_INTEROP = ['suites/tracing/prisma-orm-v5/test.ts', 'suites/trac
// which any module load hook breaks on Deno 2.8.3 (the CI version); it passes on Deno 2.9.0.
const REQUIRE_OF_ESM_ONLY_DEPENDENCY = [
'suites/tracing/graphql-tracing-channel/**',
'suites/tracing/mastra/test.ts',
'suites/tracing/mastra/**',
'suites/tracing/prisma-orm-v8/test.ts',
];

Expand All @@ -72,12 +72,12 @@ const NOT_TRIAGED = [
'suites/tracing/mongodb/test.ts',
'suites/tracing/mongoose-v5/test.ts',
'suites/tracing/mysql/test.ts',
'suites/tracing/openai/test.ts',
'suites/tracing/openai/v5/**',
'suites/tracing/openai/v7/test.ts',
'suites/tracing/orchestrion-lazy-registration/test.ts',
'suites/tracing/prisma-orm-v7/test.ts',
'suites/tracing/together-ai/test.ts',
'suites/tracing/vercelai/v6_v7/test.ts',
'suites/tracing/vercelai/v6_v7/**',
];

// Passes on Deno when run alone, but failed in about 1 of 3 full runs of this package.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import type { SerializedStreamedSpan, SerializedStreamedSpanContainer } from '@sentry/core';

export function findSegmentSpan(container: SerializedStreamedSpanContainer): SerializedStreamedSpan | undefined {
return container.items.find(item => item.is_segment);
}

export function findExpressSpan(
container: SerializedStreamedSpanContainer,
type: string,
): SerializedStreamedSpan | undefined {
return container.items.find(item => item.attributes['express.type']?.value === type);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
import { afterAll, describe, expect } from 'vitest';
import { cleanupChildProcesses, createEsmAndCjsTests } from '../../../../utils/runner';
import { join } from 'node:path';
import { findSegmentSpan } from '../helpers';

describe('express tracing', () => {
afterAll(() => {
cleanupChildProcesses();
});
createEsmAndCjsTests(join(__dirname, '..'), 'scenario.mjs', 'instrument.mjs', (createRunner, test) => {
describe('request data', () => {
test('correctly captures JSON request data', async () => {
const runner = createRunner()
.expect({
span: container => {
expect(findSegmentSpan(container)).toMatchObject({
name: 'POST /test-post',
attributes: expect.objectContaining({
'url.full': { type: 'string', value: expect.stringMatching(/^http:\/\/localhost:(\d+)\/test-post$/) },
'http.request.method': { type: 'string', value: 'POST' },
'http.request.header.user-agent': { type: 'array', value: [expect.stringContaining('')] },
'http.request.header.content-type': { type: 'array', value: ['application/json'] },
'http.request.body.data': { type: 'string', value: JSON.stringify({ foo: 'bar', other: 1 }) },
}),
});
},
})
.start();

runner.makeRequest('post', '/test-post', {
headers: {
'Content-Type': 'application/json',
},
data: JSON.stringify({ foo: 'bar', other: 1 }),
});
await runner.completed();
});

test('correctly captures plain text request data', async () => {
const runner = createRunner()
.expect({
span: container => {
expect(findSegmentSpan(container)).toMatchObject({
name: 'POST /test-post',
attributes: expect.objectContaining({
'url.full': { type: 'string', value: expect.stringMatching(/^http:\/\/localhost:(\d+)\/test-post$/) },
'http.request.method': { type: 'string', value: 'POST' },
'http.request.header.user-agent': { type: 'array', value: [expect.stringContaining('')] },
'http.request.header.content-type': { type: 'array', value: ['text/plain'] },
'http.request.body.data': { type: 'string', value: 'some plain text' },
}),
});
},
})
.start();

runner.makeRequest('post', '/test-post', {
headers: { 'Content-Type': 'text/plain' },
data: 'some plain text',
});
await runner.completed();
});

test('correctly captures text buffer request data', async () => {
const runner = createRunner()
.expect({
span: container => {
expect(findSegmentSpan(container)).toMatchObject({
name: 'POST /test-post',
attributes: expect.objectContaining({
'url.full': { type: 'string', value: expect.stringMatching(/^http:\/\/localhost:(\d+)\/test-post$/) },
'http.request.method': { type: 'string', value: 'POST' },
'http.request.header.user-agent': { type: 'array', value: [expect.stringContaining('')] },
'http.request.header.content-type': { type: 'array', value: ['application/octet-stream'] },
'http.request.body.data': { type: 'string', value: 'some plain text in buffer' },
}),
});
},
})
.start();

runner.makeRequest('post', '/test-post', {
headers: { 'Content-Type': 'application/octet-stream' },
data: Buffer.from('some plain text in buffer'),
});
await runner.completed();
});

test('correctly captures non-text buffer request data', async () => {
const runner = createRunner()
.expect({
span: container => {
expect(findSegmentSpan(container)).toMatchObject({
name: 'POST /test-post',
attributes: expect.objectContaining({
'url.full': { type: 'string', value: expect.stringMatching(/^http:\/\/localhost:(\d+)\/test-post$/) },
'http.request.method': { type: 'string', value: 'POST' },
'http.request.header.user-agent': { type: 'array', value: [expect.stringContaining('')] },
'http.request.header.content-type': { type: 'array', value: ['application/octet-stream'] },
// This is some non-ascii string representation
'http.request.body.data': { type: 'string', value: expect.any(String) },
}),
});
},
})
.start();

const body = new Uint8Array([1, 2, 3, 4, 5]).buffer;

runner.makeRequest('post', '/test-post', {
headers: { 'Content-Type': 'application/octet-stream' },
data: body,
});
await runner.completed();
});

test('correctly ignores request data', async () => {
const runner = createRunner()
.expect({
span: container => {
const serverSpan = findSegmentSpan(container);
expect(serverSpan).toMatchObject({
name: 'POST /test-post-ignore-body',
attributes: expect.objectContaining({
'url.full': {
type: 'string',
value: expect.stringMatching(/^http:\/\/localhost:(\d+)\/test-post-ignore-body$/),
},
'http.request.method': { type: 'string', value: 'POST' },
'http.request.header.user-agent': { type: 'array', value: [expect.stringContaining('')] },
'http.request.header.content-type': { type: 'array', value: ['application/octet-stream'] },
}),
});
// Ensure the request body has been ignored
expect(serverSpan?.attributes['http.request.body.data']).toBeUndefined();
},
})
.start();

runner.makeRequest('post', '/test-post-ignore-body', {
headers: { 'Content-Type': 'application/octet-stream' },
data: Buffer.from('some plain text in buffer'),
});
await runner.completed();
});
});
});
});
Loading
Loading