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+
}

0 commit comments

Comments
 (0)