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
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Deno.test('hapi instrumentation: orchestrion:@hapi/hapi:route channel wraps the

const hapiSpan = parent.spans?.find(s => s.op === 'router.hapi');
assertExists(hapiSpan, `expected a router.hapi span, got ops: ${parent.spans?.map(s => s.op).join(', ')}`);
assertEquals(hapiSpan!.description, 'route - /hello');
assertEquals(hapiSpan!.description, 'GET /hello');
assertEquals(hapiSpan!.data?.['hapi.type'], 'router');
assertEquals(hapiSpan!.data?.['http.route'], '/hello');
assertEquals(hapiSpan!.data?.['sentry.origin'], 'auto.http.orchestrion.hapi');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ Deno.test('mongodb instrumentation: orchestrion:mongodb:command channel produces

const mongoSpan = parent.spans?.find(s => s.op === 'db');
assertExists(mongoSpan, `expected a db child span, got ops: ${parent.spans?.map(s => s.op).join(', ')}`);
assertEquals(mongoSpan!.description, 'mongodb.find');
assertEquals(mongoSpan!.description, '{"find":"?","filter":{"name":"?"}}');
assertEquals(mongoSpan!.data?.['db.system'], 'mongodb');
assertEquals(mongoSpan!.data?.['db.statement'], '{"find":"?","filter":{"name":"?"}}');
assertEquals(mongoSpan!.data?.['db.name'], 'mydb');
assertEquals(mongoSpan!.data?.['db.mongodb.collection'], 'users');
assertEquals(mongoSpan!.data?.['db.operation'], 'find');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Deno.test('tedious instrumentation: orchestrion:tedious:execSql channel produces

const tediousSpan = parent.spans?.find(s => s.op === 'db');
assertExists(tediousSpan, `expected a db child span, got ops: ${parent.spans?.map(s => s.op).join(', ')}`);
assertEquals(tediousSpan!.description, 'execSql mydb');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

l/m: IIRC descriptions should be low cardinality and be sanitized. So the output should be SELECT ? in this case.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is fine because 1 is static - this is just the content of DB_STATEMENT!

assertEquals(tediousSpan!.description, 'SELECT 1');
assertEquals(tediousSpan!.data?.['db.system'], 'mssql');
assertEquals(tediousSpan!.data?.['db.name'], 'mydb');
assertEquals(tediousSpan!.data?.['db.user'], 'sa');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ test.describe('nested SSR routes (client, server, server request)', () => {

// Server page request transaction - parametrized transaction name with actual URL in data
expect(serverPageRequestTxn).toMatchObject({
transaction: 'GET /user-page/myUsername123',
transaction: 'GET /user-page/[userId]',
transaction_info: { source: 'route' },
contexts: {
trace: {
Expand Down Expand Up @@ -241,14 +241,13 @@ test.describe('nested SSR routes (client, server, server request)', () => {
data: {
'sentry.op': 'http.client',
'sentry.origin': 'auto.http.fetch',
'url.full': expect.stringContaining('/api/user/myUsername123.json'),
'url.full': 'http://localhost:3030/api/user/myUsername123.json',
},
});

// Server HTTP request transaction
expect(serverHTTPServerRequestTxn).toMatchObject({
transaction: 'GET /api/user/myUsername123.json',
transaction: 'GET /api/user/[userId].json',
transaction_info: { source: 'route' },
contexts: {
trace: {
Expand Down Expand Up @@ -300,7 +299,7 @@ test.describe('nested SSR routes (client, server, server request)', () => {
});

expect(serverPageRequestTxn).toMatchObject({
transaction: 'GET /catchAll/hell0/whatever-do',
transaction: 'GET /catchAll/[...path]',
transaction_info: { source: 'route' },
contexts: {
trace: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ test('Sends two linked transactions (server & client) to Sentry', async ({ page
const pageLoadSpanId = pageloadTransaction.contexts?.trace?.span_id;
const pageLoadParentSpanId = pageloadTransaction.contexts?.trace?.parent_span_id;

expect(httpServerTransaction.transaction).toBe('GET http://localhost:3030/');
expect(httpServerTransaction.transaction).toBe('GET /');
expect(pageloadTransaction.transaction).toBe('/');

expect(httpServerTraceId).toBeDefined();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ test('Sends two linked transactions (server & client) to Sentry', async ({ page
const pageLoadSpanId = pageloadTransaction.contexts?.trace?.span_id;
const pageLoadParentSpanId = pageloadTransaction.contexts?.trace?.parent_span_id;

expect(httpServerTransaction.transaction).toBe('GET http://localhost:3030/');
expect(httpServerTransaction.transaction).toBe('GET /');
expect(httpServerTransaction.contexts?.trace?.data?.['http.route']).toBeUndefined();
expect(pageloadTransaction.transaction).toBe('/');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ test('Sends two linked transactions (server & client) to Sentry', async ({ page
const pageLoadSpanId = pageloadTransaction.contexts?.trace?.span_id;
const pageLoadParentSpanId = pageloadTransaction.contexts?.trace?.parent_span_id;

expect(httpServerTransaction.transaction).toBe('GET http://localhost:3030/');
expect(httpServerTransaction.transaction).toBe('GET /');
expect(pageloadTransaction.transaction).toBe('routes/_index');

expect(httpServerTraceId).toBeDefined();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ test('Sends two linked transactions (server & client) to Sentry', async ({ page
const pageLoadSpanId = pageloadTransaction.contexts?.trace?.span_id;
const pageLoadParentSpanId = pageloadTransaction.contexts?.trace?.parent_span_id;

expect(httpServerTransaction.transaction).toBe('GET http://localhost:3030/');
expect(httpServerTransaction.transaction).toBe('GET /');
expect(pageloadTransaction.transaction).toBe('/');

expect(httpServerTraceId).toBeDefined();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,37 +115,34 @@ test('Should trace outgoing fetch requests inside middleware and create breadcru

if (hasHttpClientSpan) {
// Check if fetch is traced as a child span of the middleware transaction
expect(middlewareTransaction.spans).toEqual(
expect.arrayContaining([
{
data: {
'http.request.method': 'GET',
'http.request.method_original': 'GET',
'http.response.status_code': 200,
'network.peer.address': '::1',
'network.peer.port': 3030,
'sentry.kind': 'client',
'sentry.op': 'http.client',
'sentry.origin': 'auto.http.otel.node_fetch',
'server.address': 'localhost',
'server.port': 3030,
'url.full': 'http://localhost:3030/',
'url.path': '/',
'url.scheme': 'http',
'user_agent.original': 'node',
},
description: 'GET http://localhost:3030/',
op: 'http.client',
origin: 'auto.http.otel.node_fetch',
parent_span_id: expect.stringMatching(/[a-f0-9]{16}/),
span_id: expect.stringMatching(/[a-f0-9]{16}/),
start_timestamp: expect.any(Number),
status: 'ok',
timestamp: expect.any(Number),
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
},
]),
);
expect(middlewareTransaction.spans).toContainEqual({
data: {
'http.request.method': 'GET',
'http.request.method_original': 'GET',
'http.response.status_code': 200,
'network.peer.address': '::1',
'network.peer.port': 3030,
'sentry.kind': 'client',
'sentry.op': 'http.client',
'sentry.source': 'url',
'sentry.origin': 'auto.http.otel.node_fetch',
'server.address': 'localhost',
'server.port': 3030,
'url.full': 'http://localhost:3030/',
'url.path': '/',
'url.scheme': 'http',
'user_agent.original': 'node',
},
description: 'GET http://localhost:3030/',
op: 'http.client',
origin: 'auto.http.otel.node_fetch',
parent_span_id: expect.stringMatching(/[a-f0-9]{16}/),
span_id: expect.stringMatching(/[a-f0-9]{16}/),
start_timestamp: expect.any(Number),
status: 'ok',
timestamp: expect.any(Number),
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
});
} else {
// Alternatively, fetch is traced as a separate transaction, similar to Dev builds
const fetchTransaction = await fetchTransactionPromise;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ test.describe('distributed tracing', () => {
const baggageMetaTagContent = await page.locator('meta[name="baggage"]').getAttribute('content');

// Parametrization does not work in Nuxt 3.7 yet (only in newer versions)
expect(baggageMetaTagContent).toContain(`sentry-transaction=GET%20%2Ftest-param%2F${PARAM}`); // URL-encoded for 'GET /test-param/s0me-param'
// Without route attribute, the transaction name is not set on the baggage
expect(baggageMetaTagContent).not.toContain('sentry-transaction=');
Comment thread
chargome marked this conversation as resolved.
expect(baggageMetaTagContent).toContain(`sentry-trace_id=${serverTxnEvent.contexts?.trace?.trace_id}`);
expect(baggageMetaTagContent).toContain('sentry-sampled=true');
expect(baggageMetaTagContent).toContain('sentry-sample_rate=1');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ test('propagates trace context from server-timing header to client pageload', as
expect(pageloadTransaction).toBeDefined();
expect(pageloadTransaction.transaction).toBe('/');

expect(httpServerTransaction.transaction).toMatch(/^GET http:\/\/localhost:\d+\/$/);
expect(httpServerTransaction.transaction).toBe('GET /');

expect(pageloadTransaction.contexts?.trace?.trace_id).toEqual(headerTraceId);
expect(pageloadTransaction.contexts?.trace?.parent_span_id).toEqual(headerSpanId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,6 @@ app.get('/test/:id/span-updateName', (_req, res) => {
res.send({ response: 'response 1' });
});

app.get('/test/:id/span-updateName-source', (_req, res) => {
const span = Sentry.getActiveSpan();
const rootSpan = Sentry.getRootSpan(span);
rootSpan.updateName('new-name');
rootSpan.setAttribute(Sentry.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, 'custom');
res.send({ response: 'response 2' });
});

app.get('/test/:id/updateSpanName', (_req, res) => {
const span = Sentry.getActiveSpan();
const rootSpan = Sentry.getRootSpan(span);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,7 @@ describe('express tracing - updateName', () => {
// This test documents the unfortunate behaviour of using `span.updateName` on the server-side.
// For http.server root spans (which is the root span on the server 99% of the time), Otel's http instrumentation
// calls `span.updateName` and overwrites whatever the name was set to before (by us or by users).
test("calling just `span.updateName` doesn't update the final name in express (missing source)", async () => {
const runner = createRunner()
.expect({
transaction: {
transaction: 'GET /test/:id/span-updateName',
transaction_info: {
source: 'route',
},
},
})
.start();
runner.makeRequest('get', '/test/123/span-updateName');
await runner.completed();
});

// Also calling `updateName` AND setting a source doesn't change anything - Otel has no concept of source, this is sentry-internal.
// Therefore, only the source is updated but the name is still overwritten by Otel.
test('calling `span.updateName` and setting attribute source updates the final name in express', async () => {
test('calling just `span.updateName` updates the final name in express', async () => {
const runner = createRunner()
.expect({
transaction: {
Expand All @@ -40,7 +23,7 @@ describe('express tracing - updateName', () => {
},
})
.start();
runner.makeRequest('get', '/test/123/span-updateName-source');
runner.makeRequest('get', '/test/123/span-updateName');
await runner.completed();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ test('sends a streamed span envelope with correct spans for a manually started s
[SEMANTIC_ATTRIBUTE_SENTRY_RELEASE]: { type: 'string', value: '1.0.0' },
[SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT]: { type: 'string', value: 'production' },
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: { type: 'string', value: 'manual' },
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: { type: 'string', value: 'custom' },
},
name: 'test-child-span',
is_segment: false,
Expand All @@ -93,7 +92,6 @@ test('sends a streamed span envelope with correct spans for a manually started s
[SEMANTIC_ATTRIBUTE_SENTRY_RELEASE]: { type: 'string', value: '1.0.0' },
[SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT]: { type: 'string', value: 'production' },
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: { type: 'string', value: 'manual' },
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: { type: 'string', value: 'custom' },
},
links: [
{
Expand Down Expand Up @@ -130,7 +128,6 @@ test('sends a streamed span envelope with correct spans for a manually started s
[SEMANTIC_ATTRIBUTE_SENTRY_RELEASE]: { type: 'string', value: '1.0.0' },
[SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT]: { type: 'string', value: 'production' },
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: { type: 'string', value: 'manual' },
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: { type: 'string', value: 'custom' },
},
name: 'test-manual-span',
is_segment: false,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,31 +1,22 @@
import * as Sentry from '@sentry/node';

const tracer = Sentry.getClient().tracer;

async function run() {
const { createApolloServer } = await import('../../apollo-server.mjs');
const server = createApolloServer();

await tracer.startActiveSpan(
'test span name',
{
kind: 1,
attributes: { 'http.method': 'GET', 'http.route': '/test-graphql' },
},
async span => {
for (let i = 1; i < 10; i++) {
// Ref: https://www.apollographql.com/docs/apollo-server/testing/testing/#testing-using-executeoperation
await server.executeOperation({
query: `query GetHello${i} {hello}`,
});
}
await Sentry.startSpan({ name: 'test span name' }, async span => {
for (let i = 1; i < 10; i++) {
// Ref: https://www.apollographql.com/docs/apollo-server/testing/testing/#testing-using-executeoperation
await server.executeOperation({
query: `query GetHello${i} {hello}`,
});
}

setTimeout(() => {
span.end();
server.stop();
}, 500);
},
);
setTimeout(() => {
span.end();
server.stop();
}, 500);
});
}

run();
Original file line number Diff line number Diff line change
@@ -1,33 +1,24 @@
import * as Sentry from '@sentry/node';

const tracer = Sentry.getClient().tracer;

async function run() {
const { createApolloServer } = await import('../../apollo-server.mjs');
const server = createApolloServer();

await tracer.startActiveSpan(
'test span name',
{
kind: 1,
attributes: { 'http.method': 'GET', 'http.route': '/test-graphql' },
},
async span => {
// Ref: https://www.apollographql.com/docs/apollo-server/testing/testing/#testing-using-executeoperation
await server.executeOperation({
query: 'query GetWorld {world}',
});
await Sentry.startSpan({ name: 'test span name' }, async span => {
// Ref: https://www.apollographql.com/docs/apollo-server/testing/testing/#testing-using-executeoperation
await server.executeOperation({
query: 'query GetWorld {world}',
});

await server.executeOperation({
query: 'query GetHello {hello}',
});
await server.executeOperation({
query: 'query GetHello {hello}',
});

setTimeout(() => {
span.end();
server.stop();
}, 500);
},
);
setTimeout(() => {
span.end();
server.stop();
}, 500);
});
}

run();
Loading
Loading