diff --git a/dev-packages/node-core-integration-tests/suites/public-api/startSpan/basic-usage-streamed/test.ts b/dev-packages/node-core-integration-tests/suites/public-api/startSpan/basic-usage-streamed/test.ts index 6e4de612fa8e..b3e84ce4fed3 100644 --- a/dev-packages/node-core-integration-tests/suites/public-api/startSpan/basic-usage-streamed/test.ts +++ b/dev-packages/node-core-integration-tests/suites/public-api/startSpan/basic-usage-streamed/test.ts @@ -13,6 +13,7 @@ import { SENTRY_SDK_NAME, SENTRY_SDK_VERSION, SENTRY_TRACE_LIFECYCLE, + SENTRY_ORIGIN, } from '@sentry/conventions/attributes'; import { expect, test } from 'vitest'; import { createRunner } from '../../../../utils/runner'; @@ -65,6 +66,7 @@ test('sends a streamed span envelope with correct spans for a manually started s [SENTRY_SDK_VERSION]: { type: 'string', value: SDK_VERSION }, [SENTRY_SEGMENT_ID]: { type: 'string', value: segmentSpanId }, [SENTRY_SEGMENT_NAME]: { type: 'string', value: 'test-span' }, + [SENTRY_ORIGIN]: { type: 'string', value: 'manual' }, [SEMANTIC_ATTRIBUTE_SENTRY_RELEASE]: { type: 'string', value: '1.0.0' }, [SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT]: { type: 'string', value: 'production' }, [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: { type: 'string', value: 'custom' }, @@ -89,6 +91,7 @@ test('sends a streamed span envelope with correct spans for a manually started s [SENTRY_SDK_VERSION]: { type: 'string', value: SDK_VERSION }, [SENTRY_SEGMENT_ID]: { type: 'string', value: segmentSpanId }, [SENTRY_SEGMENT_NAME]: { type: 'string', value: 'test-span' }, + [SENTRY_ORIGIN]: { type: 'string', value: 'manual' }, [SEMANTIC_ATTRIBUTE_SENTRY_RELEASE]: { type: 'string', value: '1.0.0' }, [SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT]: { type: 'string', value: 'production' }, [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: { type: 'string', value: 'custom' }, @@ -126,6 +129,7 @@ test('sends a streamed span envelope with correct spans for a manually started s [SENTRY_SDK_VERSION]: { type: 'string', value: SDK_VERSION }, [SENTRY_SEGMENT_ID]: { type: 'string', value: segmentSpanId }, [SENTRY_SEGMENT_NAME]: { type: 'string', value: 'test-span' }, + [SENTRY_ORIGIN]: { type: 'string', value: 'manual' }, [SEMANTIC_ATTRIBUTE_SENTRY_RELEASE]: { type: 'string', value: '1.0.0' }, [SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT]: { type: 'string', value: 'production' }, [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: { type: 'string', value: 'custom' }, @@ -143,6 +147,7 @@ test('sends a streamed span envelope with correct spans for a manually started s const expectedAttributes: Record = { [SENTRY_TRACE_LIFECYCLE]: { type: 'string', value: 'stream' }, + [SENTRY_ORIGIN]: { type: 'string', value: 'manual' }, [SEMANTIC_ATTRIBUTE_SENTRY_OP]: { type: 'string', value: 'test' }, [SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE]: { type: 'integer', value: 1 }, [SENTRY_SDK_NAME]: { type: 'string', value: 'sentry.javascript.node-core' }, diff --git a/packages/opentelemetry/src/utils/backfillStreamedSpanData.ts b/packages/opentelemetry/src/utils/backfillStreamedSpanData.ts index 298aadcff5da..dc215d95e7db 100644 --- a/packages/opentelemetry/src/utils/backfillStreamedSpanData.ts +++ b/packages/opentelemetry/src/utils/backfillStreamedSpanData.ts @@ -7,6 +7,7 @@ import { spanKindToName, } from '@sentry/core'; import { inferSpanData } from './parseSpanDescription'; +import { SENTRY_ORIGIN } from '@sentry/conventions/attributes'; /** * Backfill op, source, name and data on a streamed span JSON from OTel semantic conventions. @@ -30,6 +31,11 @@ export function backfillStreamedSpanDataFromOtel(spanJSON: StreamedSpanJSON, hin safeSetSpanJSONAttributes(spanJSON, { [SEMANTIC_ATTRIBUTE_SENTRY_OP]: op, [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: source, + // If nothing in the chain previously set an origin, we now default it to 'manual' + // For transactions, this is done in the SpanExporter. + // TODO (v11): Remove this again once we fully moved away from OTel's TracerProvider. + // at this point, we use `SentrySpan` everywhere, which defaults its origin to 'manual'. + [SENTRY_ORIGIN]: 'manual', ...data, });