Skip to content
Draft
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 @@ -12,6 +12,7 @@ import {
SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_NAME,
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
SEMANTIC_ATTRIBUTE_SENTRY_STATUS_MESSAGE,
SEMANTIC_ATTRIBUTE_SENTRY_TRACE_LIFECYCLE,
} from '@sentry/core';
import { sentryTest } from '../../../../utils/fixtures';
import { shouldSkipTracingTest } from '../../../../utils/helpers';
Expand Down Expand Up @@ -100,6 +101,10 @@ sentryTest(
type: 'string',
value: 'production',
},
[SEMANTIC_ATTRIBUTE_SENTRY_TRACE_LIFECYCLE]: {
type: 'string',
value: 'stream',
},
},
end_timestamp: expect.any(Number),
is_segment: false,
Expand Down Expand Up @@ -136,6 +141,10 @@ sentryTest(
type: 'string',
value: 'production',
},
[SEMANTIC_ATTRIBUTE_SENTRY_TRACE_LIFECYCLE]: {
type: 'string',
value: 'stream',
},
},
end_timestamp: expect.any(Number),
is_segment: false,
Expand Down Expand Up @@ -176,6 +185,10 @@ sentryTest(
type: 'string',
value: 'Connection Refused',
},
[SEMANTIC_ATTRIBUTE_SENTRY_TRACE_LIFECYCLE]: {
type: 'string',
value: 'stream',
},
},
end_timestamp: expect.any(Number),
is_segment: false,
Expand Down Expand Up @@ -252,6 +265,10 @@ sentryTest(
type: 'string',
value: 'production',
},
[SEMANTIC_ATTRIBUTE_SENTRY_TRACE_LIFECYCLE]: {
type: 'string',
value: 'stream',
},
},
end_timestamp: expect.any(Number),
is_segment: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_ID,
SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_NAME,
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
SEMANTIC_ATTRIBUTE_SENTRY_TRACE_LIFECYCLE,
} from '@sentry/core';
import { sentryTest } from '../../../../utils/fixtures';
import { shouldSkipTracingTest } from '../../../../utils/helpers';
Expand Down Expand Up @@ -42,6 +43,10 @@ sentryTest('captures streamed interaction span tree. @firefox', async ({ browser

expect(interactionSegmentSpan).toEqual({
attributes: {
[SEMANTIC_ATTRIBUTE_SENTRY_TRACE_LIFECYCLE]: {
type: 'string',
value: 'stream',
},
'culture.calendar': {
type: 'string',
value: expect.any(String),
Expand Down Expand Up @@ -122,6 +127,10 @@ sentryTest('captures streamed interaction span tree. @firefox', async ({ browser
const interactionSpan = interactionSpanTree.find(span => getSpanOp(span) === 'ui.interaction.click');
expect(interactionSpan).toEqual({
attributes: {
[SEMANTIC_ATTRIBUTE_SENTRY_TRACE_LIFECYCLE]: {
type: 'string',
value: 'stream',
},
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: {
type: 'string',
value: 'ui.interaction.click',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE,
SEMANTIC_ATTRIBUTE_SENTRY_SDK_INTEGRATIONS,
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
SEMANTIC_ATTRIBUTE_SENTRY_TRACE_LIFECYCLE,
} from '@sentry/core';
import { sentryTest } from '../../../../utils/fixtures';
import { shouldSkipTracingTest } from '../../../../utils/helpers';
Expand Down Expand Up @@ -71,6 +72,10 @@ sentryTest('starts a streamed navigation span on page navigation', async ({ brow

expect(navigationSpan).toEqual({
attributes: {
[SEMANTIC_ATTRIBUTE_SENTRY_TRACE_LIFECYCLE]: {
type: 'string',
value: 'stream',
},
'culture.calendar': {
type: 'string',
value: expect.any(String),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_ID,
SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_NAME,
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
SEMANTIC_ATTRIBUTE_SENTRY_TRACE_LIFECYCLE,
} from '@sentry/core';
import { sentryTest } from '../../../../utils/fixtures';
import { shouldSkipTracingTest } from '../../../../utils/helpers';
Expand Down Expand Up @@ -64,6 +65,10 @@ sentryTest(

expect(pageloadSpan).toEqual({
attributes: {
[SEMANTIC_ATTRIBUTE_SENTRY_TRACE_LIFECYCLE]: {
type: 'string',
value: 'stream',
},
'culture.calendar': {
type: 'string',
value: expect.any(String),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_ID,
SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_NAME,
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
SEMANTIC_ATTRIBUTE_SENTRY_TRACE_LIFECYCLE,
} from '@sentry/core';
import { expect, it } from 'vitest';
import { createRunner } from '../../../runner';
Expand Down Expand Up @@ -77,6 +78,7 @@ it('sends a streamed span envelope with correct spans for a manually started spa
expect(childSpan).toBeDefined();
expect(childSpan).toEqual({
attributes: {
[SEMANTIC_ATTRIBUTE_SENTRY_TRACE_LIFECYCLE]: { type: 'string', value: 'stream' },
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: {
type: 'string',
value: 'test-child',
Expand All @@ -103,6 +105,7 @@ it('sends a streamed span envelope with correct spans for a manually started spa
expect(inactiveSpan).toBeDefined();
expect(inactiveSpan).toEqual({
attributes: {
[SEMANTIC_ATTRIBUTE_SENTRY_TRACE_LIFECYCLE]: { type: 'string', value: 'stream' },
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: { type: 'string', value: 'manual' },
[SEMANTIC_ATTRIBUTE_SENTRY_SDK_NAME]: { type: 'string', value: CLOUDFLARE_SDK },
[SEMANTIC_ATTRIBUTE_SENTRY_SDK_VERSION]: { type: 'string', value: SDK_VERSION },
Expand Down Expand Up @@ -138,6 +141,7 @@ it('sends a streamed span envelope with correct spans for a manually started spa
expect(manualSpan).toBeDefined();
expect(manualSpan).toEqual({
attributes: {
[SEMANTIC_ATTRIBUTE_SENTRY_TRACE_LIFECYCLE]: { type: 'string', value: 'stream' },
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: { type: 'string', value: 'manual' },
[SEMANTIC_ATTRIBUTE_SENTRY_SDK_NAME]: { type: 'string', value: CLOUDFLARE_SDK },
[SEMANTIC_ATTRIBUTE_SENTRY_SDK_VERSION]: { type: 'string', value: SDK_VERSION },
Expand All @@ -158,6 +162,7 @@ it('sends a streamed span envelope with correct spans for a manually started spa

expect(parentTestSpan).toEqual({
attributes: {
[SEMANTIC_ATTRIBUTE_SENTRY_TRACE_LIFECYCLE]: { type: 'string', value: 'stream' },
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: { type: 'string', value: 'test' },
[SEMANTIC_ATTRIBUTE_SENTRY_SDK_NAME]: { type: 'string', value: CLOUDFLARE_SDK },
[SEMANTIC_ATTRIBUTE_SENTRY_SDK_VERSION]: { type: 'string', value: SDK_VERSION },
Expand All @@ -179,6 +184,7 @@ it('sends a streamed span envelope with correct spans for a manually started spa

expect(segmentSpan).toEqual({
attributes: {
[SEMANTIC_ATTRIBUTE_SENTRY_TRACE_LIFECYCLE]: { type: 'string', value: 'stream' },
[SEMANTIC_ATTRIBUTE_SENTRY_SDK_NAME]: { type: 'string', value: CLOUDFLARE_SDK },
[SEMANTIC_ATTRIBUTE_SENTRY_SDK_VERSION]: { type: 'string', value: SDK_VERSION },
[SEMANTIC_ATTRIBUTE_SENTRY_SDK_INTEGRATIONS]: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import { waitForStreamedSpans, getSpanOp } from '@sentry-internal/test-utils';

const SEGMENT_SPAN = {
attributes: {
[SEMANTIC_ATTRIBUTE_SENTRY_TRACE_LIFECYCLE]: {
type: 'string',
value: 'stream',
},
'app.start_time': {
type: 'string',
value: expect.any(String),
Expand Down Expand Up @@ -170,6 +174,10 @@ test('Sends streamed spans (http.server and manual with Sentry.startSpan)', asyn
expect(spans).toEqual([
{
attributes: {
[SEMANTIC_ATTRIBUTE_SENTRY_TRACE_LIFECYCLE]: {
type: 'string',
value: 'stream',
},
'sentry.environment': {
type: 'string',
value: 'qa',
Expand Down Expand Up @@ -238,6 +246,10 @@ test('OTel span appears as child of Sentry span (interop)', async ({ baseURL })

expect(sentrySpan).toEqual({
attributes: {
[SEMANTIC_ATTRIBUTE_SENTRY_TRACE_LIFECYCLE]: {
type: 'string',
value: 'stream',
},
'sentry.environment': {
type: 'string',
value: 'qa',
Expand Down Expand Up @@ -275,6 +287,10 @@ test('OTel span appears as child of Sentry span (interop)', async ({ baseURL })

expect(otelSpan).toEqual({
attributes: {
[SEMANTIC_ATTRIBUTE_SENTRY_TRACE_LIFECYCLE]: {
type: 'string',
value: 'stream',
},
'sentry.environment': {
type: 'string',
value: 'qa',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_ID,
SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_NAME,
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
SEMANTIC_ATTRIBUTE_SENTRY_TRACE_LIFECYCLE,
} from '@sentry/core';
import { expect, test } from 'vitest';
import { createRunner } from '../../../../utils/runner';
Expand Down Expand Up @@ -53,6 +54,7 @@ test('sends a streamed span envelope with correct spans for a manually started s
expect(childSpan).toBeDefined();
expect(childSpan).toEqual({
attributes: {
[SEMANTIC_ATTRIBUTE_SENTRY_TRACE_LIFECYCLE]: { type: 'string', value: 'stream' },
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: {
type: 'string',
value: 'test-child',
Expand Down Expand Up @@ -80,6 +82,7 @@ test('sends a streamed span envelope with correct spans for a manually started s
expect(inactiveSpan).toBeDefined();
expect(inactiveSpan).toEqual({
attributes: {
[SEMANTIC_ATTRIBUTE_SENTRY_TRACE_LIFECYCLE]: { type: 'string', value: 'stream' },
[SEMANTIC_ATTRIBUTE_SENTRY_SDK_NAME]: { type: 'string', value: 'sentry.javascript.node-core' },
[SEMANTIC_ATTRIBUTE_SENTRY_SDK_VERSION]: { type: 'string', value: SDK_VERSION },
[SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_ID]: { type: 'string', value: segmentSpanId },
Expand Down Expand Up @@ -116,6 +119,7 @@ test('sends a streamed span envelope with correct spans for a manually started s
expect(manualSpan).toBeDefined();
expect(manualSpan).toEqual({
attributes: {
[SEMANTIC_ATTRIBUTE_SENTRY_TRACE_LIFECYCLE]: { type: 'string', value: 'stream' },
[SEMANTIC_ATTRIBUTE_SENTRY_SDK_NAME]: { type: 'string', value: 'sentry.javascript.node-core' },
[SEMANTIC_ATTRIBUTE_SENTRY_SDK_VERSION]: { type: 'string', value: SDK_VERSION },
[SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_ID]: { type: 'string', value: segmentSpanId },
Expand All @@ -136,6 +140,7 @@ test('sends a streamed span envelope with correct spans for a manually started s
});

const expectedAttributes: Record<string, unknown> = {
[SEMANTIC_ATTRIBUTE_SENTRY_TRACE_LIFECYCLE]: { type: 'string', value: 'stream' },
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: { type: 'string', value: 'test' },
[SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE]: { type: 'integer', value: 1 },
[SEMANTIC_ATTRIBUTE_SENTRY_SDK_NAME]: { type: 'string', value: 'sentry.javascript.node-core' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_ID,
SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_NAME,
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
SEMANTIC_ATTRIBUTE_SENTRY_TRACE_LIFECYCLE,
} from '@sentry/core';
import { expect, test } from 'vitest';
import { createRunner } from '../../../../utils/runner';
Expand Down Expand Up @@ -53,6 +54,7 @@ test('sends a streamed span envelope with correct spans for a manually started s
expect(childSpan).toBeDefined();
expect(childSpan).toEqual({
attributes: {
[SEMANTIC_ATTRIBUTE_SENTRY_TRACE_LIFECYCLE]: { type: 'string', value: 'stream' },
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: {
type: 'string',
value: 'test-child',
Expand Down Expand Up @@ -80,6 +82,7 @@ test('sends a streamed span envelope with correct spans for a manually started s
expect(inactiveSpan).toBeDefined();
expect(inactiveSpan).toEqual({
attributes: {
[SEMANTIC_ATTRIBUTE_SENTRY_TRACE_LIFECYCLE]: { type: 'string', value: 'stream' },
[SEMANTIC_ATTRIBUTE_SENTRY_SDK_NAME]: { type: 'string', value: 'sentry.javascript.node' },
[SEMANTIC_ATTRIBUTE_SENTRY_SDK_VERSION]: { type: 'string', value: SDK_VERSION },
[SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_ID]: { type: 'string', value: segmentSpanId },
Expand Down Expand Up @@ -116,6 +119,7 @@ test('sends a streamed span envelope with correct spans for a manually started s
expect(manualSpan).toBeDefined();
expect(manualSpan).toEqual({
attributes: {
[SEMANTIC_ATTRIBUTE_SENTRY_TRACE_LIFECYCLE]: { type: 'string', value: 'stream' },
[SEMANTIC_ATTRIBUTE_SENTRY_SDK_NAME]: { type: 'string', value: 'sentry.javascript.node' },
[SEMANTIC_ATTRIBUTE_SENTRY_SDK_VERSION]: { type: 'string', value: SDK_VERSION },
[SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_ID]: { type: 'string', value: segmentSpanId },
Expand All @@ -136,6 +140,7 @@ test('sends a streamed span envelope with correct spans for a manually started s
});

const expectedAttributes: Record<string, unknown> = {
[SEMANTIC_ATTRIBUTE_SENTRY_TRACE_LIFECYCLE]: { type: 'string', value: 'stream' },
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: { type: 'string', value: 'test' },
[SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE]: { type: 'integer', value: 1 },
[SEMANTIC_ATTRIBUTE_SENTRY_SDK_NAME]: { type: 'string', value: 'sentry.javascript.node' },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SEMANTIC_ATTRIBUTE_SENTRY_OP } from '@sentry/core';
import { SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_TRACE_LIFECYCLE } from '@sentry/core';
import type { SerializedStreamedSpanContainer } from '@sentry/core';
import { afterAll, describe, expect } from 'vitest';
import { cleanupChildProcesses } from '../../../utils/runner';
Expand Down Expand Up @@ -90,6 +90,10 @@ describe('mysql auto instrumentation (streamed)', () => {
...(isNode18 && {
'sentry.status.message': { type: 'string', value: expect.stringMatching(/^connect ECONNREFUSED/) },
}),
[SEMANTIC_ATTRIBUTE_SENTRY_TRACE_LIFECYCLE]: {
type: 'string',
value: 'stream',
},
};

const COMMON_SPAN_PROPS = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SEMANTIC_ATTRIBUTE_SENTRY_OP } from '@sentry/core';
import { SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_TRACE_LIFECYCLE } from '@sentry/core';
import type { SerializedStreamedSpanContainer } from '@sentry/core';
import { afterAll, describe, expect } from 'vitest';
import { conditionalTest } from '../../../utils';
Expand Down Expand Up @@ -69,6 +69,10 @@ const COMMON_DB_ATTRIBUTES = {
type: 'string',
value: 'task',
},
[SEMANTIC_ATTRIBUTE_SENTRY_TRACE_LIFECYCLE]: {
type: 'string',
value: 'stream',
},
};

/**
Expand Down
5 changes: 5 additions & 0 deletions packages/browser/test/integrations/spanstreaming.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
debug,
SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT,
SEMANTIC_ATTRIBUTE_SENTRY_SDK_INTEGRATIONS,
SEMANTIC_ATTRIBUTE_SENTRY_TRACE_LIFECYCLE,
} from '@sentry/core/browser';
import { beforeEach, describe, expect, it, vi } from 'vitest';
import { BrowserClient, spanStreamingIntegration } from '../../src';
Expand Down Expand Up @@ -137,6 +138,10 @@ describe('spanStreamingIntegration', () => {
start_timestamp: expect.any(Number),
status: 'ok',
attributes: {
[SEMANTIC_ATTRIBUTE_SENTRY_TRACE_LIFECYCLE]: {
type: 'string',
value: 'stream',
},
'sentry.origin': {
type: 'string',
value: 'manual',
Expand Down
6 changes: 6 additions & 0 deletions packages/core/src/semanticAttributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ export const SEMANTIC_ATTRIBUTE_SENTRY_SDK_VERSION = 'sentry.sdk.version';
/** The list of integrations enabled in the Sentry SDK (e.g., ["InboundFilters", "BrowserTracing"]) */
export const SEMANTIC_ATTRIBUTE_SENTRY_SDK_INTEGRATIONS = 'sentry.sdk.integrations';

/**
* Indicates the trace lifecycle mode with which a span was sent by the SDK.
* Either "stream" (streamed span) or "static" (transaction-sent span).
*/
export const SEMANTIC_ATTRIBUTE_SENTRY_TRACE_LIFECYCLE = 'sentry.trace_lifecycle';

/** The user ID */
export const SEMANTIC_ATTRIBUTE_USER_ID = 'user.id';
/** The user email */
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/tracing/spans/captureSpan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_ID,
SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_NAME,
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
SEMANTIC_ATTRIBUTE_SENTRY_TRACE_LIFECYCLE,
SEMANTIC_ATTRIBUTE_USER_EMAIL,
SEMANTIC_ATTRIBUTE_USER_ID,
SEMANTIC_ATTRIBUTE_USER_IP_ADDRESS,
Expand Down Expand Up @@ -138,6 +139,7 @@ function applyCommonSpanAttributes(

// avoid overwriting any previously set attributes (from users or potentially our SDK instrumentation)
safeSetSpanJSONAttributes(spanJSON, {
[SEMANTIC_ATTRIBUTE_SENTRY_TRACE_LIFECYCLE]: 'stream',
[SEMANTIC_ATTRIBUTE_SENTRY_RELEASE]: release,
[SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT]: environment || DEFAULT_ENVIRONMENT,
[SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_NAME]: serializedSegmentSpan.name,
Expand Down
Loading
Loading