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 @@ -2,7 +2,6 @@ import * as Sentry from '@sentry/node';
import { loggingTransport } from '@sentry-internal/node-integration-tests';

Sentry.init({
traceLifecycle: 'static',
dsn: 'https://public@dsn.ingest.sentry.io/1337',
release: '1.0',
// explicitly not setting tracesSampleRate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ describe('double baggage prevention', () => {

await createRunner()
.withEnv({ SERVER_URL })
.ignore('transaction')
.expect({
event: {
exception: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as Sentry from '@sentry/node';
import { loggingTransport } from '@sentry-internal/node-integration-tests';

Sentry.init({
traceLifecycle: 'static',
dsn: 'https://public@dsn.ingest.sentry.io/1337',
release: '1.0',
tracesSampleRate: 1.0,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { SENTRY_OP, URL_FULL } from '@sentry/conventions/attributes';
import { HTTP_CLIENT } from '@sentry/conventions/op';
import { createTestServer } from '@sentry-internal/test-utils';
import { describe, expect } from 'vitest';
import { createEsmAndCjsTests } from '../../../../utils/runner';
Expand Down Expand Up @@ -31,13 +33,28 @@ describe('double baggage prevention', () => {

await createRunner()
.withEnv({ SERVER_URL })
.unordered()
.expect({
event: {
exception: {
values: [{ type: 'Error', value: 'done' }],
},
},
})
.expect({
span: container => {
const spans = container.items;
expect(spans.map(span => span.attributes[URL_FULL]?.value).sort()).toEqual([
`${SERVER_URL}/api/fetch`,
`${SERVER_URL}/api/fetch-custom-headers`,
]);
for (const span of spans) {
expect(span.attributes[SENTRY_OP]?.value).toBe(HTTP_CLIENT);
expect(span.is_segment).toBe(true);
expect(span.parent_span_id).toBeUndefined();
}
},
})
.start()
.completed();
closeTestServer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as Sentry from '@sentry/node';
import { loggingTransport } from '@sentry-internal/node-integration-tests';

Sentry.init({
traceLifecycle: 'static',
dsn: 'https://public@dsn.ingest.sentry.io/1337',
release: '1.0',
tracesSampleRate: 1.0,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { SENTRY_OP, URL_FULL } from '@sentry/conventions/attributes';
import { HTTP_CLIENT } from '@sentry/conventions/op';
import { createTestServer } from '@sentry-internal/test-utils';
import { describe, expect } from 'vitest';
import { createEsmAndCjsTests } from '../../../../utils/runner';
Expand All @@ -6,7 +8,7 @@ import { expectConsistentTraceId, expectNoDuplicateSentryBaggageKeys, expectUser

describe('double baggage prevention - http.client spans with parent span', () => {
createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument.mjs', (createRunner, test) => {
let transactionTraceId = '000';
let traceId = '000';
let fetchSpanId = '000';
let httpCustomHeadersSpanId = '000';
let fetchCustomHeadersSpanId = '000';
Expand All @@ -16,7 +18,7 @@ describe('double baggage prevention - http.client spans with parent span', () =>
.get('/api/fetch-custom-headers', headers => {
// fetch with manual getTraceData() headers — core reproduction case
const sentryTrace = extractTraceparentData(headers['sentry-trace'] as string);
transactionTraceId = sentryTrace!.traceId!;
traceId = sentryTrace!.traceId!;
fetchCustomHeadersSpanId = sentryTrace!.parentSpanId!;
expectNoDuplicateSentryBaggageKeys(headers['baggage']);
expect(headers['sentry-trace']).not.toContain(',');
Expand Down Expand Up @@ -46,42 +48,46 @@ describe('double baggage prevention - http.client spans with parent span', () =>
.withEnv({ SERVER_URL })
.ignore('event')
.expect({
transaction: txn => {
expect(transactionTraceId).toMatch(/^[a-f0-9]{32}$/);
span: container => {
expect(traceId).toMatch(/^[a-f0-9]{32}$/);

expect(txn).toMatchObject({
transaction: 'parent_span',
spans: [
{
op: 'http.client',
description: expect.stringMatching(/^GET .*\/api\/fetch-custom-headers$/),
data: {},
// span id is expected to be different since users call getTraceData() before the
// http.client span is created
span_id: expect.not.stringContaining(fetchCustomHeadersSpanId),
start_timestamp: expect.any(Number),
trace_id: transactionTraceId,
expect(container.items.find(span => span.is_segment)?.name).toBe('parent_span');
expect(container.items.filter(span => !span.is_segment)).toMatchObject([
{
name: 'GET localhost',
attributes: {
[SENTRY_OP]: { type: 'string', value: HTTP_CLIENT },
[URL_FULL]: { type: 'string', value: expect.stringMatching(/^.*\/api\/fetch-custom-headers$/) },
},
{
op: 'http.client',
description: expect.stringMatching(/^GET .*\/api\/fetch$/),
data: {},
span_id: fetchSpanId,
start_timestamp: expect.any(Number),
trace_id: transactionTraceId,
// span id is expected to be different since users call getTraceData() before the
// http.client span is created
span_id: expect.not.stringContaining(fetchCustomHeadersSpanId),
start_timestamp: expect.any(Number),
trace_id: traceId,
},
{
name: 'GET localhost',
attributes: {
[SENTRY_OP]: { type: 'string', value: HTTP_CLIENT },
[URL_FULL]: { type: 'string', value: expect.stringMatching(/^.*\/api\/fetch$/) },
},
{
op: 'http.client',
description: expect.stringMatching(/^GET .*\/api\/http-custom-headers$/),
data: {},
// span id is expected to be different since users call getTraceData() before the
// http.client span is created
span_id: expect.not.stringContaining(httpCustomHeadersSpanId),
start_timestamp: expect.any(Number),
trace_id: transactionTraceId,
span_id: fetchSpanId,
start_timestamp: expect.any(Number),
trace_id: traceId,
},
{
name: 'GET localhost',
attributes: {
[SENTRY_OP]: { type: 'string', value: HTTP_CLIENT },
[URL_FULL]: { type: 'string', value: expect.stringMatching(/^.*\/api\/http-custom-headers$/) },
},
],
});
// span id is expected to be different since users call getTraceData() before the
// http.client span is created
span_id: expect.not.stringContaining(httpCustomHeadersSpanId),
start_timestamp: expect.any(Number),
trace_id: traceId,
},
]);
},
})
.start()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import * as Sentry from '@sentry/node';
import { loggingTransport } from '@sentry-internal/node-integration-tests';

Sentry.init({
traceLifecycle: 'static',
dsn: 'https://public@dsn.ingest.sentry.io/1337',
release: '1.0',
tracesSampleRate: 1.0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import * as Sentry from '@sentry/node';
import { loggingTransport } from '@sentry-internal/node-integration-tests';

Sentry.init({
traceLifecycle: 'static',
dsn: 'https://public@dsn.ingest.sentry.io/1337',
release: '1.0',
tracesSampleRate: 1.0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ test('adds current transaction name to baggage when the txn name is high-quality
await createRunner(__dirname, 'scenario-headers.ts')
.withEnv({ SERVER_URL })
.expect({
transaction: {},
span: {},
})
.start()
.completed();
Expand Down Expand Up @@ -106,7 +106,7 @@ test('adds current transaction name to trace envelope header when the txn name i
},
})
.expectHeader({
transaction: {
span: {
trace: {
environment: 'production',
public_key: 'public',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const { loggingTransport } = require('@sentry-internal/node-integration-tests');
const Sentry = require('@sentry/node');

Sentry.init({
traceLifecycle: 'static',
dsn: 'https://public@dsn.ingest.sentry.io/1337',
release: '1.0',
transport: loggingTransport,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const { loggingTransport, startExpressServerAndSendPortToRunner } = require('@se
const Sentry = require('@sentry/node');

Sentry.init({
traceLifecycle: 'static',
dsn: 'https://public@dsn.ingest.sentry.io/1337',
transport: loggingTransport,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const { loggingTransport } = require('@sentry-internal/node-integration-tests');
const Sentry = require('@sentry/node');

Sentry.init({
traceLifecycle: 'static',
dsn: 'https://public@dsn.ingest.sentry.io/1337',
transport: loggingTransport,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const { loggingTransport } = require('@sentry-internal/node-integration-tests');
const Sentry = require('@sentry/node');

Sentry.init({
traceLifecycle: 'static',
dsn: 'https://public@dsn.ingest.sentry.io/1337',
tracesSampleRate: 1.0,
transport: loggingTransport,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const { loggingTransport } = require('@sentry-internal/node-integration-tests');
const Sentry = require('@sentry/node');

Sentry.init({
traceLifecycle: 'static',
dsn: 'https://public@dsn.ingest.sentry.io/1337',
tracesSampleRate: 0,
transport: loggingTransport,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const { loggingTransport } = require('@sentry-internal/node-integration-tests');
const Sentry = require('@sentry/node');

Sentry.init({
traceLifecycle: 'static',
dsn: 'https://public@dsn.ingest.sentry.io/1337',
tracesSampleRate: 1.0,
transport: loggingTransport,
Expand Down
Loading