Skip to content
Open
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',
tracesSampleRate: 1.0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,14 @@ afterAll(() => {
test('sends a manually started root span with source custom', async () => {
await createRunner(__dirname, 'scenario.ts')
.expect({
transaction: {
transaction: 'test_span',
transaction_info: { source: 'custom' },
contexts: {
trace: {
span_id: expect.any(String),
trace_id: expect.any(String),
data: { [SENTRY_SEGMENT_NAME_SOURCE]: 'custom' },
},
},
},
})
.start()
.completed();
});

test("doesn't change the name for manually started spans even if attributes triggering inference are set", async () => {
await createRunner(__dirname, 'scenario.ts')
.expect({
transaction: {
transaction: 'test_span',
transaction_info: { source: 'custom' },
contexts: {
trace: {
span_id: expect.any(String),
trace_id: expect.any(String),
data: { [SENTRY_SEGMENT_NAME_SOURCE]: 'custom' },
},
},
span: container => {
const segment = container.items.find(span => span.is_segment);
expect(segment?.name).toBe('test_span');
expect(segment?.span_id).toEqual(expect.any(String));
expect(segment?.trace_id).toEqual(expect.any(String));
expect(segment?.start_timestamp).toEqual(expect.any(Number));
expect(segment?.end_timestamp).toEqual(expect.any(Number));
expect(segment?.attributes[SENTRY_SEGMENT_NAME_SOURCE]).toEqual({ type: 'string', value: 'custom' });
},
})
.start()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { loggingTransport } from '@sentry-internal/node-integration-tests';
Sentry.init({
dsn: 'https://public@dsn.ingest.sentry.io/1337',
tracesSampleRate: 1.0,
traceLifecycle: 'stream',
integrations: [Sentry.spanStreamingIntegration()],
transport: loggingTransport,
release: '1.0.0',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import {
SENTRY_ORIGIN,
} from '@sentry/conventions/attributes';
import { expect, test } from 'vitest';
import { createRunner } from '../../../../utils/runner';
import { EXPECTED_SDK_NAME } from '../../../../utils';
import { createRunner } from '../../../../../utils/runner';
import { EXPECTED_SDK_NAME } from '../../../../../utils';

test('sends a streamed span envelope with correct envelope header', async () => {
await createRunner(__dirname, 'scenario.ts')
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,45 +1,46 @@
import type { SpanJSON } from '@sentry/core';
import { afterAll, expect, test } from 'vitest';
import { assertSentryTransaction } from '../../../../utils/assertions';
import { cleanupChildProcesses, createRunner } from '../../../../utils/runner';

afterAll(() => {
cleanupChildProcesses();
});

test('should report finished spans as children of the root transaction.', async () => {
test('should report finished spans as children of the root span.', async () => {
await createRunner(__dirname, 'scenario.ts')
.expect({
transaction: transaction => {
const rootSpanId = transaction.contexts?.trace?.span_id;
const span3Id = transaction.spans?.[1]?.span_id;
span: container => {
const segment = container.items.find(span => span.is_segment);
// Streamed spans arrive in completion order; compare the original creation order.
const spans = container.items
.filter(span => !span.is_segment)
.sort((a, b) => a.start_timestamp - b.start_timestamp);
const rootSpanId = segment?.span_id;
const span3Id = spans.find(span => span.name === 'span_3')?.span_id;

expect(rootSpanId).toEqual(expect.any(String));
expect(span3Id).toEqual(expect.any(String));

assertSentryTransaction(transaction, {
transaction: 'root_span',
spans: [
{
description: 'span_1',
data: {
foo: 'bar',
baz: [1, 2, 3],
},
parent_span_id: rootSpanId,
expect(segment?.name).toBe('root_span');
expect(segment?.start_timestamp).toEqual(expect.any(Number));
expect(segment?.end_timestamp).toEqual(expect.any(Number));
expect(spans).toMatchObject([
{
name: 'span_1',
attributes: {
foo: { type: 'string', value: 'bar' },
baz: { type: 'array', value: [1, 2, 3] },
},
{
description: 'span_3',
parent_span_id: rootSpanId,
data: {},
},
{
description: 'span_5',
parent_span_id: span3Id,
data: {},
},
] as SpanJSON[],
});
parent_span_id: rootSpanId,
},
{
name: 'span_3',
parent_span_id: rootSpanId,
},
{
name: 'span_5',
parent_span_id: span3Id,
},
]);
},
})
.start()
Expand Down
Loading