Skip to content

Commit 922ccf3

Browse files
committed
reduce to standalone: boolean; remove segment
1 parent 8b3627a commit 922ccf3

File tree

11 files changed

+15
-168
lines changed

11 files changed

+15
-168
lines changed

dev-packages/browser-integration-tests/suites/public-api/startSpan/standalone/segment-false/subject.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

dev-packages/browser-integration-tests/suites/public-api/startSpan/standalone/segment-false/test.ts

Lines changed: 0 additions & 47 deletions
This file was deleted.

dev-packages/browser-integration-tests/suites/public-api/startSpan/standalone/segment-true/subject.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

dev-packages/browser-integration-tests/suites/public-api/startSpan/standalone/segment-undefined/test.ts

Lines changed: 0 additions & 46 deletions
This file was deleted.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { expect } from '@playwright/test';
22
import type { SpanEnvelope } from '@sentry/types';
33

4-
import { sentryTest } from '../../../../../utils/fixtures';
4+
import { sentryTest } from '../../../../utils/fixtures';
55
import {
66
getFirstSentryEnvelopeRequest,
77
properFullEnvelopeRequestParser,
88
shouldSkipTracingTest,
9-
} from '../../../../../utils/helpers';
9+
} from '../../../../utils/helpers';
1010

1111
sentryTest('sends a segment span envelope', async ({ getLocalTestPath, page }) => {
1212
if (shouldSkipTracingTest()) {

packages/core/src/tracing/sentrySpan.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,6 @@ export class SentrySpan implements Span {
6363
/** if true, treat span as a standalone span (not part of a transaction) */
6464
private _isStandaloneSpan?: boolean;
6565

66-
/** send standalone span as segment span */
67-
private _isSegmentSpan?: boolean;
68-
6966
/**
7067
* You should never call the constructor manually, always use `Sentry.startSpan()`
7168
* or other span methods.
@@ -106,7 +103,6 @@ export class SentrySpan implements Span {
106103
}
107104

108105
this._isStandaloneSpan = spanContext.isStandalone;
109-
this._isSegmentSpan = spanContext.isStandalone && spanContext.isSegment;
110106
}
111107

112108
/** @inheritdoc */
@@ -199,8 +195,8 @@ export class SentrySpan implements Span {
199195
profile_id: this._attributes[SEMANTIC_ATTRIBUTE_PROFILE_ID] as string | undefined,
200196
exclusive_time: this._attributes[SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME] as number | undefined,
201197
measurements: timedEventsToMeasurements(this._events),
202-
is_segment: !this._isStandaloneSpan ? undefined : this._isSegmentSpan,
203-
segment_id: this._isStandaloneSpan && this._isSegmentSpan ? this._spanId : undefined,
198+
is_segment: this._isStandaloneSpan || undefined,
199+
segment_id: this._isStandaloneSpan ? this._spanId : undefined,
204200
});
205201
}
206202

@@ -240,7 +236,8 @@ export class SentrySpan implements Span {
240236
client.emit('spanEnd', this);
241237
}
242238

243-
// If this is not a root span, we're done, otherwise, we send it when it is ended
239+
// If this is not a root span (== segment span) and we don't want to send it standalone, we're done.
240+
// otherwise, we send it
244241
if (this !== getRootSpan(this)) {
245242
return;
246243
}
@@ -289,6 +286,7 @@ export class SentrySpan implements Span {
289286
// The transaction span itself should be filtered out
290287
const finishedSpans = getSpanDescendants(this).filter(span => span !== this);
291288

289+
// TODO: filter out standalone spans!
292290
const spans = finishedSpans.map(span => spanToJSON(span)).filter(isFullFinishedSpan);
293291

294292
const source = this._attributes[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE] as TransactionSource | undefined;

packages/core/src/tracing/trace.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,6 @@ function normalizeContext(context: StartSpanOptions): SentrySpanArguments {
294294
const exp = context.experimental || {};
295295
const initialCtx: SentrySpanArguments = {
296296
isStandalone: exp.standalone,
297-
isSegment: exp.standalone && exp.segment,
298297
...context,
299298
};
300299

packages/core/test/lib/tracing/trace.test.ts

Lines changed: 5 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -552,12 +552,12 @@ describe('startSpan', () => {
552552
expect(result).toBe('aha');
553553
});
554554

555-
describe('[experimental] standalone and segment', () => {
556-
it('starts a standalone segment span if both options are set', () => {
555+
describe('[experimental] standalone spans', () => {
556+
it('starts a standalone segment span if standalone is set', () => {
557557
const span = startSpan(
558558
{
559559
name: 'test span',
560-
experimental: { standalone: true, segment: true },
560+
experimental: { standalone: true },
561561
},
562562
span => {
563563
return span;
@@ -570,43 +570,11 @@ describe('startSpan', () => {
570570
expect(spanJson.segment_id).toMatch(/^[a-f0-9]{16}$/);
571571
});
572572

573-
it('starts a non-segment span if standalone is set and segment is false', () => {
574-
const span = startSpan(
575-
{
576-
name: 'test span',
577-
experimental: { standalone: true, segment: false },
578-
},
579-
span => {
580-
return span;
581-
},
582-
);
583-
584-
const spanJson = spanToJSON(span);
585-
expect(spanJson.is_segment).toBe(false);
586-
expect(spanJson.segment_id).toBeUndefined();
587-
});
588-
589-
it('starts a standalone span (no data about segment) if only standalone is set ', () => {
590-
const span = startSpan(
591-
{
592-
name: 'test span',
593-
experimental: { standalone: true },
594-
},
595-
span => {
596-
return span;
597-
},
598-
);
599-
600-
const spanJson = spanToJSON(span);
601-
expect(spanJson.is_segment).toBeUndefined();
602-
expect(spanJson.segment_id).toBeUndefined();
603-
});
604-
605-
it.each([undefined, false])('ignores segment if standalone is falsy (%s)', standalone => {
573+
it.each([undefined, false])("doesn't set segment properties if standalone is falsy (%s)", standalone => {
606574
const span = startSpan(
607575
{
608576
name: 'test span',
609-
experimental: { standalone, segment: true },
577+
experimental: { standalone },
610578
},
611579
span => {
612580
return span;

packages/types/src/span.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -191,23 +191,13 @@ export interface SentrySpanArguments {
191191
endTimestamp?: number | undefined;
192192

193193
/**
194-
* Set to `true` if this span should be sent as a standalone span as
195-
* opposed to a transaction.
194+
* Set to `true` if this span should be sent as a standalone segment span
195+
* as opposed to a transaction.
196196
*
197197
* @experimental this option is currently experimental and should only be
198198
* used within SDK code. It might be removed or changed in the future.
199199
*/
200200
isStandalone?: boolean | undefined;
201-
202-
/**
203-
* Set to `true` if this span is a segment span. For now, this is used for
204-
* standalone single spans that are not part of a transaction but should
205-
* show up in the Sentry UI (as opposed to a non-segment standalone span).
206-
*
207-
* @experimental this option is currently experimental and should only be
208-
* used within SDK code. It might be removed or changed in the future.
209-
*/
210-
isSegment?: boolean | undefined;
211201
}
212202

213203
/**

packages/types/src/startSpanOptions.ts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export interface StartSpanOptions {
3333
experimental?: {
3434
/**
3535
* If set to true, always start a standalone span which will be sent as a
36-
* standalone span envelope instead of a transaction envelope.
36+
* standalone segment span envelope instead of a transaction envelope.
3737
*
3838
* @internal this option is currently experimental and should only be
3939
* used within SDK code. It might be removed or changed in the future.
@@ -43,18 +43,5 @@ export interface StartSpanOptions {
4343
* @hidden
4444
*/
4545
standalone?: boolean;
46-
47-
/**
48-
* If set to true and `standalone` is also set to `true`, the span will be
49-
* sent as a standalone segment span (with `is_segment: true` and `segment_id`).
50-
*
51-
* If `standalone` is not set to `true`, this option has no effect.
52-
*
53-
* @internal this option is currently experimental and should only be
54-
* used within SDK code. It might be removed or changed in the future.
55-
*
56-
* @hidden
57-
*/
58-
segment?: boolean;
5946
};
6047
}

0 commit comments

Comments
 (0)