Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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 @@ -3,11 +3,6 @@ import { Span } from '@sentry/types';
import axios from 'axios';
import { waitForTransaction } from '../event-proxy-server';

const authToken = process.env.E2E_TEST_AUTH_TOKEN;
const sentryTestOrgSlug = process.env.E2E_TEST_SENTRY_ORG_SLUG;
const sentryTestProject = process.env.E2E_TEST_SENTRY_TEST_PROJECT;
const EVENT_POLLING_TIMEOUT = 90_000;

test('Propagates trace for outgoing http requests', async ({ baseURL }) => {
const inboundTransactionPromise = waitForTransaction('node-experimental-fastify-app', transactionEvent => {
return (
Expand Down Expand Up @@ -55,56 +50,77 @@ test('Propagates trace for outgoing http requests', async ({ baseURL }) => {
]),
);

expect(outboundTransaction).toEqual(
expect.objectContaining({
contexts: expect.objectContaining({
trace: {
data: {
url: 'http://localhost:3030/test-outgoing-http',
'otel.kind': 'SERVER',
'http.response.status_code': 200,
'sentry.op': 'http.server',
'sentry.origin': 'auto.http.otel.http',
'sentry.source': 'route',
},
op: 'http.server',
span_id: expect.any(String),
status: 'ok',
tags: {
'http.status_code': '200',
},
trace_id: traceId,
origin: 'auto.http.otel.http',
},
}),
}),
);
expect(outboundTransaction.contexts?.trace).toEqual({
data: {
'sentry.source': 'route',
'sentry.origin': 'auto.http.otel.http',
'sentry.op': 'http.server',
'sentry.sample_rate': 1,
url: 'http://localhost:3030/test-outgoing-http',
'otel.kind': 'SERVER',
'http.response.status_code': 200,
'http.url': 'http://localhost:3030/test-outgoing-http',
'http.host': 'localhost:3030',
'net.host.name': 'localhost',
'http.method': 'GET',
'http.scheme': 'http',
'http.target': '/test-outgoing-http',
'http.user_agent': 'axios/1.6.7',
'http.flavor': '1.1',
'net.transport': 'ip_tcp',
'net.host.ip': expect.any(String),
'net.host.port': expect.any(Number),
'net.peer.ip': expect.any(String),
'net.peer.port': expect.any(Number),
'http.status_code': 200,
'http.status_text': 'OK',
'http.route': '/test-outgoing-http',
},
op: 'http.server',
span_id: expect.any(String),
status: 'ok',
tags: {
'http.status_code': '200',
},
trace_id: traceId,
origin: 'auto.http.otel.http',
});

expect(inboundTransaction).toEqual(
expect.objectContaining({
contexts: expect.objectContaining({
trace: {
data: {
url: 'http://localhost:3030/test-inbound-headers',
'otel.kind': 'SERVER',
'http.response.status_code': 200,
'sentry.op': 'http.server',
'sentry.origin': 'auto.http.otel.http',
'sentry.source': 'route',
},
op: 'http.server',
parent_span_id: outgoingHttpSpanId,
span_id: expect.any(String),
status: 'ok',
tags: {
'http.status_code': '200',
},
trace_id: traceId,
origin: 'auto.http.otel.http',
},
}),
}),
);
expect(inboundTransaction.contexts?.trace).toEqual({
data: {
'sentry.source': 'route',
'sentry.origin': 'auto.http.otel.http',
'sentry.op': 'http.server',
'sentry.sample_rate': 1,
url: 'http://localhost:3030/test-inbound-headers',
'otel.kind': 'SERVER',
'http.response.status_code': 200,
'http.url': 'http://localhost:3030/test-inbound-headers',
'http.host': 'localhost:3030',
'net.host.name': 'localhost',
'http.method': 'GET',
'http.scheme': 'http',
'http.target': '/test-inbound-headers',
'http.flavor': '1.1',
'net.transport': 'ip_tcp',
'net.host.ip': expect.any(String),
'net.host.port': expect.any(Number),
'net.peer.ip': expect.any(String),
'net.peer.port': expect.any(Number),
'http.status_code': 200,
'http.status_text': 'OK',
'http.route': '/test-inbound-headers',
},
op: 'http.server',
parent_span_id: outgoingHttpSpanId,
span_id: expect.any(String),
status: 'ok',
tags: {
'http.status_code': '200',
},
trace_id: traceId,
origin: 'auto.http.otel.http',
});
});

test('Propagates trace for outgoing fetch requests', async ({ baseURL }) => {
Expand Down Expand Up @@ -154,54 +170,75 @@ test('Propagates trace for outgoing fetch requests', async ({ baseURL }) => {
]),
);

expect(outboundTransaction).toEqual(
expect.objectContaining({
contexts: expect.objectContaining({
trace: {
data: {
url: 'http://localhost:3030/test-outgoing-fetch',
'otel.kind': 'SERVER',
'http.response.status_code': 200,
'sentry.op': 'http.server',
'sentry.origin': 'auto.http.otel.http',
'sentry.source': 'route',
},
op: 'http.server',
span_id: expect.any(String),
status: 'ok',
tags: {
'http.status_code': '200',
},
trace_id: traceId,
origin: 'auto.http.otel.http',
},
}),
}),
);
expect(outboundTransaction.contexts?.trace).toEqual({
data: {
'sentry.source': 'route',
'sentry.origin': 'auto.http.otel.http',
'sentry.op': 'http.server',
'sentry.sample_rate': 1,
url: 'http://localhost:3030/test-outgoing-fetch',
'otel.kind': 'SERVER',
'http.response.status_code': 200,
'http.url': 'http://localhost:3030/test-outgoing-fetch',
'http.host': 'localhost:3030',
'net.host.name': 'localhost',
'http.method': 'GET',
'http.scheme': 'http',
'http.target': '/test-outgoing-fetch',
'http.user_agent': 'axios/1.6.7',
'http.flavor': '1.1',
'net.transport': 'ip_tcp',
'net.host.ip': expect.any(String),
'net.host.port': expect.any(Number),
'net.peer.ip': expect.any(String),
'net.peer.port': expect.any(Number),
'http.status_code': 200,
'http.status_text': 'OK',
'http.route': '/test-outgoing-fetch',
},
op: 'http.server',
span_id: expect.any(String),
status: 'ok',
tags: {
'http.status_code': '200',
},
trace_id: traceId,
origin: 'auto.http.otel.http',
});

expect(inboundTransaction).toEqual(
expect.objectContaining({
contexts: expect.objectContaining({
trace: {
data: {
url: 'http://localhost:3030/test-inbound-headers',
'otel.kind': 'SERVER',
'http.response.status_code': 200,
'sentry.op': 'http.server',
'sentry.origin': 'auto.http.otel.http',
'sentry.source': 'route',
},
op: 'http.server',
parent_span_id: outgoingHttpSpanId,
span_id: expect.any(String),
status: 'ok',
tags: {
'http.status_code': '200',
},
trace_id: traceId,
origin: 'auto.http.otel.http',
},
}),
}),
);
expect(inboundTransaction.contexts?.trace).toEqual({
data: {
'sentry.source': 'route',
'sentry.origin': 'auto.http.otel.http',
'sentry.op': 'http.server',
'sentry.sample_rate': 1,
url: 'http://localhost:3030/test-inbound-headers',
'otel.kind': 'SERVER',
'http.response.status_code': 200,
'http.url': 'http://localhost:3030/test-inbound-headers',
'http.host': 'localhost:3030',
'net.host.name': 'localhost',
'http.method': 'GET',
'http.scheme': 'http',
'http.target': '/test-inbound-headers',
'http.flavor': '1.1',
'net.transport': 'ip_tcp',
'net.host.ip': expect.any(String),
'net.host.port': expect.any(Number),
'net.peer.ip': expect.any(String),
'net.peer.port': expect.any(Number),
'http.status_code': 200,
'http.status_text': 'OK',
'http.route': '/test-inbound-headers',
},
op: 'http.server',
parent_span_id: outgoingHttpSpanId,
span_id: expect.any(String),
status: 'ok',
tags: {
'http.status_code': '200',
},
trace_id: traceId,
origin: 'auto.http.otel.http',
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,44 @@ test('Sends an API route transaction', async ({ baseURL }) => {
const transactionEvent = await pageloadTransactionEventPromise;
const transactionEventId = transactionEvent.event_id;

expect(transactionEvent.contexts?.trace).toEqual({
data: {
'sentry.source': 'route',
'sentry.origin': 'auto.http.otel.http',
'sentry.op': 'http.server',
'sentry.sample_rate': 1,
url: 'http://localhost:3030/test-transaction',
'otel.kind': 'SERVER',
'http.response.status_code': 200,
'http.url': 'http://localhost:3030/test-transaction',
'http.host': 'localhost:3030',
'net.host.name': 'localhost',
'http.method': 'GET',
'http.scheme': 'http',
'http.target': '/test-transaction',
'http.user_agent': 'axios/1.6.7',
'http.flavor': '1.1',
'net.transport': 'ip_tcp',
'net.host.ip': expect.any(String),
'net.host.port': expect.any(Number),
'net.peer.ip': expect.any(String),
'net.peer.port': expect.any(Number),
'http.status_code': 200,
'http.status_text': 'OK',
'http.route': '/test-transaction',
},
op: 'http.server',
span_id: expect.any(String),
status: 'ok',
tags: {
'http.status_code': '200',
},
trace_id: expect.any(String),
origin: 'auto.http.otel.http',
});

expect(transactionEvent).toEqual(
expect.objectContaining({
contexts: expect.objectContaining({
trace: {
data: {
url: 'http://localhost:3030/test-transaction',
'otel.kind': 'SERVER',
'http.response.status_code': 200,
'sentry.op': 'http.server',
'sentry.origin': 'auto.http.otel.http',
'sentry.source': 'route',
},
op: 'http.server',
span_id: expect.any(String),
status: 'ok',
tags: {
'http.status_code': '200',
},
trace_id: expect.any(String),
origin: 'auto.http.otel.http',
},
}),

spans: [
{
data: {
Expand Down
1 change: 0 additions & 1 deletion packages/core/src/tracing/dynamicSamplingContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ export function getDynamicSamplingContextFromSpan(span: Span): Readonly<Partial<
return {};
}

// passing emit=false here to only emit later once the DSC is actually populated
const dsc = getDynamicSamplingContextFromClient(spanToJSON(span).trace_id || '', client);

// TODO (v8): Remove v7FrozenDsc as a Transaction will no longer have _frozenDynamicSamplingContext
Expand Down
Loading