Skip to content

Commit 4d684a6

Browse files
committed
ref: better tree shaking...
1 parent 311a29a commit 4d684a6

File tree

19 files changed

+79
-100
lines changed

19 files changed

+79
-100
lines changed

packages/angular/src/sdk.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {
1212
dedupeIntegration,
1313
functionToStringIntegration,
1414
inboundFiltersIntegration,
15-
spanLoggerIntegration,
1615
} from '@sentry/core';
1716
import type { Integration } from '@sentry/types';
1817
import { logger } from '@sentry/utils';
@@ -31,7 +30,7 @@ export function getDefaultIntegrations(): Integration[] {
3130
// see:
3231
// - https://github.com/getsentry/sentry-javascript/issues/5417#issuecomment-1453407097
3332
// - https://github.com/getsentry/sentry-javascript/issues/2744
34-
const integrations: Integration[] = [
33+
return [
3534
inboundFiltersIntegration(),
3635
functionToStringIntegration(),
3736
breadcrumbsIntegration(),
@@ -40,12 +39,6 @@ export function getDefaultIntegrations(): Integration[] {
4039
dedupeIntegration(),
4140
httpContextIntegration(),
4241
];
43-
44-
if (IS_DEBUG_BUILD) {
45-
integrations.push(spanLoggerIntegration());
46-
}
47-
48-
return integrations;
4942
}
5043

5144
/**

packages/aws-serverless/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ export {
9999
extraErrorDataIntegration,
100100
rewriteFramesIntegration,
101101
sessionTimingIntegration,
102-
spanLoggerIntegration,
103102
} from '@sentry/core';
104103

105104
export { getDefaultIntegrations, init, tryPatchHandler, wrapHandler } from './awslambda';

packages/browser/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ export {
1010
extraErrorDataIntegration,
1111
rewriteFramesIntegration,
1212
sessionTimingIntegration,
13-
spanLoggerIntegration,
1413
} from '@sentry/core';
1514

1615
export {

packages/browser/src/sdk.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getCurrentScope, spanLoggerIntegration } from '@sentry/core';
1+
import { getCurrentScope } from '@sentry/core';
22
import { functionToStringIntegration, inboundFiltersIntegration } from '@sentry/core';
33
import {
44
captureSession,
@@ -36,7 +36,7 @@ export function getDefaultIntegrations(_options: Options): Integration[] {
3636
* Note: Please make sure this stays in sync with Angular SDK, which re-exports
3737
* `getDefaultIntegrations` but with an adjusted set of integrations.
3838
*/
39-
const integrations: Integration[] = [
39+
return [
4040
inboundFiltersIntegration(),
4141
functionToStringIntegration(),
4242
browserApiErrorsIntegration(),
@@ -46,12 +46,6 @@ export function getDefaultIntegrations(_options: Options): Integration[] {
4646
dedupeIntegration(),
4747
httpContextIntegration(),
4848
];
49-
50-
if (DEBUG_BUILD) {
51-
integrations.push(spanLoggerIntegration());
52-
}
53-
54-
return integrations;
5549
}
5650

5751
function applyDefaultOptions(optionsArg: BrowserOptions = {}): BrowserOptions {

packages/bun/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ export {
120120
extraErrorDataIntegration,
121121
rewriteFramesIntegration,
122122
sessionTimingIntegration,
123-
spanLoggerIntegration,
124123
} from '@sentry/core';
125124

126125
export type { BunOptions } from './types';

packages/bun/src/sdk.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {
33
inboundFiltersIntegration,
44
linkedErrorsIntegration,
55
requestDataIntegration,
6-
spanLoggerIntegration,
76
} from '@sentry/core';
87
import {
98
consoleIntegration,
@@ -30,7 +29,6 @@ export function getDefaultIntegrations(_options: Options): Integration[] {
3029
functionToStringIntegration(),
3130
linkedErrorsIntegration(),
3231
requestDataIntegration(),
33-
spanLoggerIntegration(),
3432
// Native Wrappers
3533
consoleIntegration(),
3634
httpIntegration(),

packages/core/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ export { dedupeIntegration } from './integrations/dedupe';
9999
export { extraErrorDataIntegration } from './integrations/extraerrordata';
100100
export { rewriteFramesIntegration } from './integrations/rewriteframes';
101101
export { sessionTimingIntegration } from './integrations/sessiontiming';
102-
export { spanLoggerIntegration } from './integrations/spanlogger';
103102
export { metrics } from './metrics/exports';
104103
export type { MetricData } from './metrics/exports';
105104
export { metricsDefault } from './metrics/exports-default';

packages/core/src/integrations/spanlogger.ts

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

packages/core/src/tracing/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ export {
1818
export { getDynamicSamplingContextFromClient, getDynamicSamplingContextFromSpan } from './dynamicSamplingContext';
1919
export { setMeasurement } from './measurement';
2020
export { sampleSpan } from './sampling';
21+
export { logSpanEnd, logSpanStart } from './logSpans';

packages/core/src/tracing/logSpans.ts

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import type { Span } from '@sentry/types';
2+
import { logger } from '@sentry/utils';
3+
import { DEBUG_BUILD } from '../debug-build';
4+
import { getRootSpan, spanIsSampled, spanToJSON } from '../utils/spanUtils';
5+
6+
/**
7+
* Print a log message for a started span.
8+
*/
9+
export function logSpanStart(span: Span): void {
10+
if (!DEBUG_BUILD) return;
11+
12+
const { description = '< unknown name >', op = '< unknown op >', parent_span_id: parentSpanId } = spanToJSON(span);
13+
const { spanId } = span.spanContext();
14+
15+
const sampled = spanIsSampled(span);
16+
const rootSpan = getRootSpan(span);
17+
const isRootSpan = rootSpan === span;
18+
19+
const header = `[Tracing] Starting ${sampled ? 'sampled' : 'unsampled'} ${isRootSpan ? 'root ' : ''}span`;
20+
21+
const infoParts: string[] = [`op: ${op}`, `name: ${description}`, `ID: ${spanId}`];
22+
23+
if (parentSpanId) {
24+
infoParts.push(`parent ID: ${parentSpanId}`);
25+
}
26+
27+
if (!isRootSpan) {
28+
const { op, description } = spanToJSON(rootSpan);
29+
infoParts.push(`root ID: ${rootSpan.spanContext().spanId}`);
30+
if (op) {
31+
infoParts.push(`root op: ${op}`);
32+
}
33+
if (description) {
34+
infoParts.push(`root description: ${description}`);
35+
}
36+
}
37+
38+
logger.log(`${header}
39+
${infoParts.join('\n ')}`);
40+
}
41+
42+
/**
43+
* Print a log message for an ended span.
44+
*/
45+
export function logSpanEnd(span: Span): void {
46+
if (!DEBUG_BUILD) return;
47+
48+
const { description = '< unknown name >', op = '< unknown op >' } = spanToJSON(span);
49+
const { spanId } = span.spanContext();
50+
const rootSpan = getRootSpan(span);
51+
const isRootSpan = rootSpan === span;
52+
53+
const msg = `[Tracing] Finishing "${op}" ${isRootSpan ? 'root ' : ''}span "${description}" with ID ${spanId}`;
54+
logger.log(msg);
55+
}

packages/core/src/tracing/sentrySpan.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
spanTimeInputToSeconds,
2424
spanToTraceContext,
2525
} from '../utils/spanUtils';
26+
import { logSpanEnd } from './logSpans';
2627

2728
/**
2829
* Span contains all data about a span
@@ -177,6 +178,7 @@ export class SentrySpan implements Span {
177178
}
178179

179180
this._endTime = spanTimeInputToSeconds(endTimestamp);
181+
logSpanEnd(this);
180182

181183
this._onSpanEnded();
182184
}

packages/core/src/tracing/trace.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import {
2626
spanToJSON,
2727
} from '../utils/spanUtils';
2828
import { getDynamicSamplingContextFromSpan } from './dynamicSamplingContext';
29+
import { logSpanStart } from './logSpans';
2930
import { sampleSpan } from './sampling';
3031
import { SentryNonRecordingSpan } from './sentryNonRecordingSpan';
3132
import { SentrySpan } from './sentrySpan';
@@ -269,6 +270,8 @@ function createChildSpanOrTransaction({
269270
});
270271
}
271272

273+
logSpanStart(span);
274+
272275
// TODO v8: Technically `startTransaction` can return undefined, which is not reflected by the types
273276
// This happens if tracing extensions have not been added
274277
// In this case, we just want to return a non-recording span

packages/deno/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ export {
6868
extraErrorDataIntegration,
6969
rewriteFramesIntegration,
7070
sessionTimingIntegration,
71-
spanLoggerIntegration,
7271
SEMANTIC_ATTRIBUTE_SENTRY_OP,
7372
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
7473
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,

packages/deno/src/sdk.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import type { ServerRuntimeClientOptions } from '@sentry/core';
2-
import { spanLoggerIntegration } from '@sentry/core';
32
import {
43
dedupeIntegration,
54
functionToStringIntegration,
@@ -28,7 +27,6 @@ export function getDefaultIntegrations(_options: Options): Integration[] {
2827
functionToStringIntegration(),
2928
linkedErrorsIntegration(),
3029
dedupeIntegration(),
31-
spanLoggerIntegration(),
3230
// Deno Specific
3331
breadcrumbsIntegration(),
3432
denoContextIntegration(),

packages/google-cloud-serverless/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ export {
9999
extraErrorDataIntegration,
100100
rewriteFramesIntegration,
101101
sessionTimingIntegration,
102-
spanLoggerIntegration,
103102
} from '@sentry/core';
104103

105104
export { getDefaultIntegrations, init } from './sdk';

packages/node/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ export {
9393
extraErrorDataIntegration,
9494
rewriteFramesIntegration,
9595
sessionTimingIntegration,
96-
spanLoggerIntegration,
9796
metricsDefault as metrics,
9897
startSession,
9998
captureSession,

packages/node/src/sdk/init.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
inboundFiltersIntegration,
1010
linkedErrorsIntegration,
1111
requestDataIntegration,
12-
spanLoggerIntegration,
1312
startSession,
1413
} from '@sentry/core';
1514
import { openTelemetrySetupCheck, setOpenTelemetryContextAsyncContextStrategy } from '@sentry/opentelemetry';
@@ -52,7 +51,6 @@ export function getDefaultIntegrations(options: Options): Integration[] {
5251
functionToStringIntegration(),
5352
linkedErrorsIntegration(),
5453
requestDataIntegration(),
55-
spanLoggerIntegration(),
5654
// Native Wrappers
5755
consoleIntegration(),
5856
httpIntegration(),

packages/opentelemetry/src/spanProcessor.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
import type { Context } from '@opentelemetry/api';
22
import { ROOT_CONTEXT, trace } from '@opentelemetry/api';
33
import type { ReadableSpan, Span, SpanProcessor as SpanProcessorInterface } from '@opentelemetry/sdk-trace-base';
4-
import { addChildSpanToSpan, getClient, getDefaultCurrentScope, getDefaultIsolationScope } from '@sentry/core';
4+
import {
5+
addChildSpanToSpan,
6+
getClient,
7+
getDefaultCurrentScope,
8+
getDefaultIsolationScope,
9+
logSpanEnd,
10+
logSpanStart,
11+
} from '@sentry/core';
512
import { SEMANTIC_ATTRIBUTE_SENTRY_PARENT_IS_REMOTE } from './semanticAttributes';
613
import { SentrySpanExporter } from './spanExporter';
714
import { getScopesFromContext } from './utils/contextData';
@@ -38,13 +45,17 @@ function onSpanStart(span: Span, parentContext: Context): void {
3845
setSpanScopes(span, scopes);
3946
}
4047

48+
logSpanStart(span);
49+
4150
const client = getClient();
4251
client?.emit('spanStart', span);
4352
}
4453

45-
function onSpanEnd(span: ReadableSpan): void {
54+
function onSpanEnd(span: Span): void {
55+
logSpanEnd(span);
56+
4657
const client = getClient();
47-
client?.emit('spanEnd', span as Span);
58+
client?.emit('spanEnd', span);
4859
}
4960

5061
/**
@@ -81,7 +92,7 @@ export class SentrySpanProcessor implements SpanProcessorInterface {
8192
}
8293

8394
/** @inheritDoc */
84-
public onEnd(span: ReadableSpan): void {
95+
public onEnd(span: Span & ReadableSpan): void {
8596
onSpanEnd(span);
8697

8798
this._exporter.export(span);

packages/vercel-edge/src/sdk.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
initAndBind,
66
linkedErrorsIntegration,
77
requestDataIntegration,
8-
spanLoggerIntegration,
98
} from '@sentry/core';
109
import type { Integration, Options } from '@sentry/types';
1110
import { GLOBAL_OBJ, createStackParser, nodeStackLineParser, stackParserFromStackParserOptions } from '@sentry/utils';
@@ -28,7 +27,6 @@ export function getDefaultIntegrations(options: Options): Integration[] {
2827
return [
2928
inboundFiltersIntegration(),
3029
functionToStringIntegration(),
31-
spanLoggerIntegration(),
3230
linkedErrorsIntegration(),
3331
winterCGFetchIntegration(),
3432
...(options.sendDefaultPii ? [requestDataIntegration()] : []),

0 commit comments

Comments
 (0)