Skip to content

Commit 876bc8a

Browse files
committed
fix stuff
1 parent f32e970 commit 876bc8a

File tree

8 files changed

+26
-19
lines changed

8 files changed

+26
-19
lines changed

packages/apm/src/hubextensions.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { getMainCarrier, Hub } from '@sentry/hub';
22
import { SpanContext, TransactionContext } from '@sentry/types';
33
import { logger } from '@sentry/utils';
44

5-
import { IdleTransaction } from './idletransaction';
65
import { Span } from './span';
76
import { Transaction } from './transaction';
87

@@ -23,8 +22,8 @@ function traceHeaders(this: Hub): { [key: string]: string } {
2322
/**
2423
* {@see Hub.startTransaction}
2524
*/
26-
function startTransaction(this: Hub, context: TransactionContext, idleTimeout?: number): Transaction {
27-
const transaction = idleTimeout ? new IdleTransaction(context, this, idleTimeout) : new Transaction(context, this);
25+
function startTransaction(this: Hub, context: TransactionContext): Transaction {
26+
const transaction = new Transaction(context, this);
2827

2928
const client = this.getClient();
3029
// Roll the dice for sampling transaction, all child spans inherit the sampling decision.

packages/apm/src/index.bundle.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ import { Integrations as BrowserIntegrations } from '@sentry/browser';
5353
import { getGlobalObject } from '@sentry/utils';
5454

5555
import { addExtensionMethods } from './hubextensions';
56-
import * as TracingIntegrations from './integrations';
56+
import * as ApmIntegrations from './integrations';
5757

5858
export { Span, TRACEPARENT_REGEXP } from './span';
5959

@@ -70,7 +70,7 @@ if (_window.Sentry && _window.Sentry.Integrations) {
7070
const INTEGRATIONS = {
7171
...windowIntegrations,
7272
...BrowserIntegrations,
73-
Tracing: TracingIntegrations.Tracing,
73+
Tracing: ApmIntegrations.Tracing,
7474
};
7575

7676
export { INTEGRATIONS as Integrations };

packages/apm/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { addExtensionMethods } from './hubextensions';
2-
import * as TracingIntegrations from './integrations';
2+
import * as ApmIntegrations from './integrations';
33

4-
export { TracingIntegrations as Integrations };
4+
export { ApmIntegrations as Integrations };
55
export { Span, TRACEPARENT_REGEXP } from './span';
66
export { Transaction } from './transaction';
77

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export { Express } from './express';
2+
export { Tracing } from './tracing';

packages/apm/src/integrations/tracing.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Event, EventProcessor, Integration, Severity, Span, SpanContext, Transa
44
import {
55
addInstrumentationHandler,
66
getGlobalObject,
7+
isInstanceOf,
78
isMatchingPattern,
89
logger,
910
safeJoin,
@@ -1019,19 +1020,24 @@ function fetchCallback(handlerData: { [key: string]: any }): void {
10191020
if (activity) {
10201021
const span = activity.span;
10211022
if (span) {
1023+
const request = (handlerData.args[0] = handlerData.args[0] as string | Request);
10221024
const options = (handlerData.args[1] = (handlerData.args[1] as { [key: string]: any }) || {});
1023-
if (options.headers) {
1024-
if (Array.isArray(options.headers)) {
1025-
options.headers = [...options.headers, { 'sentry-trace': span.toTraceparent() }];
1025+
let headers = options.headers;
1026+
if (isInstanceOf(request, Request)) {
1027+
headers = (request as Request).headers;
1028+
}
1029+
if (headers) {
1030+
if (typeof headers.append === 'function') {
1031+
headers.append('sentry-trace', span.toTraceparent());
1032+
} else if (Array.isArray(headers)) {
1033+
headers = [...headers, ['sentry-trace', span.toTraceparent()]];
10261034
} else {
1027-
options.headers = {
1028-
...options.headers,
1029-
'sentry-trace': span.toTraceparent(),
1030-
};
1035+
headers = { ...headers, 'sentry-trace': span.toTraceparent() };
10311036
}
10321037
} else {
1033-
options.headers = { 'sentry-trace': span.toTraceparent() };
1038+
headers = { 'sentry-trace': span.toTraceparent() };
10341039
}
1040+
options.headers = headers;
10351041
}
10361042
}
10371043
}

packages/tracing/src/index.bundle.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ import { Integrations as BrowserIntegrations } from '@sentry/browser';
5353
import { getGlobalObject } from '@sentry/utils';
5454

5555
import { addExtensionMethods } from './hubextensions';
56-
import * as ApmIntegrations from './integrations';
56+
import * as TracingIntegrations from './integrations';
5757

5858
export { Span, TRACEPARENT_REGEXP } from './span';
5959

@@ -70,7 +70,7 @@ if (_window.Sentry && _window.Sentry.Integrations) {
7070
const INTEGRATIONS = {
7171
...windowIntegrations,
7272
...BrowserIntegrations,
73-
Tracing: ApmIntegrations.Tracing,
73+
Tracing: TracingIntegrations.BrowserTracing,
7474
};
7575

7676
export { INTEGRATIONS as Integrations };

packages/tracing/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { addExtensionMethods } from './hubextensions';
2-
import * as ApmIntegrations from './integrations';
2+
import * as TracingIntegrations from './integrations';
33

4-
export { ApmIntegrations as Integrations };
4+
export { TracingIntegrations as Integrations };
55
export { Span, TRACEPARENT_REGEXP } from './span';
66
export { Transaction } from './transaction';
77

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export { Express } from './express';
2+
export { BrowserTracing } from './browsertracing';

0 commit comments

Comments
 (0)