-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
9 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,6 @@ const Sentry = require('@sentry/node'); | |
Sentry.init({ | ||
dsn: 'https://[email protected]/1337', | ||
transport: loggingTransport, | ||
debug: true, | ||
}); | ||
|
||
// express must be required after Sentry is initialized | ||
|
@@ -30,5 +29,4 @@ app.get('/test', (_req, res) => { | |
|
||
Sentry.setupExpressErrorHandler(app); | ||
|
||
// TODO: remove port again | ||
startExpressServerAndSendPortToRunner(app, 3000); | ||
startExpressServerAndSendPortToRunner(app); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,29 @@ | ||
import * as api from '@opentelemetry/api'; | ||
import { getCurrentScope } from '@sentry/core'; | ||
import type { SerializedTraceData } from '@sentry/types'; | ||
import { getPropagationContextFromSpan } from '../propagator'; | ||
import { generateSpanContextForPropagationContext } from './generateSpanContextForPropagationContext'; | ||
import { dropUndefinedKeys } from '@sentry/utils'; | ||
|
||
/** | ||
* Otel-specific implementation of `getTraceData`. | ||
* @see `@sentry/core` version of `getTraceData` for more information | ||
*/ | ||
export function getTraceData(): SerializedTraceData { | ||
const ctx = api.context.active(); | ||
const spanToUse = api.trace.getSpan(ctx); | ||
const context = api.context.active(); | ||
|
||
// This should never happen, given we always create an ambient non-recording span if there's no active span. | ||
if (!spanToUse) { | ||
if (!context) { | ||
return {}; | ||
} | ||
const headersObject: Record<string, string> = {}; | ||
|
||
const propagationContext = spanToUse | ||
? getPropagationContextFromSpan(spanToUse) | ||
: getCurrentScope().getPropagationContext(); | ||
|
||
const spanContext = generateSpanContextForPropagationContext(propagationContext); | ||
|
||
const context = api.trace.setSpanContext(ctx, spanContext); | ||
const headersObject: Record<string, string> = {}; | ||
|
||
api.propagation.inject(context, headersObject); | ||
|
||
if (!headersObject['sentry-trace']) { | ||
return {}; | ||
} | ||
|
||
return { | ||
return dropUndefinedKeys({ | ||
'sentry-trace': headersObject['sentry-trace'], | ||
baggage: headersObject['baggage'], | ||
}; | ||
baggage: headersObject.baggage, | ||
}); | ||
} |