-
-
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.
feat(core): Add OpenTelemetry-specific
getTraceData
implementation (#…
…13281) Add an Otel-specific implementation of `getTraceData` and add the `getTraceData` function to the `AsyncContextStrategy` interface. This allows us to dynamically choose either the default implementation (which works correctly for browser/non-POTEL SDKs) and the Otel-specific version.
- Loading branch information
Showing
12 changed files
with
192 additions
and
89 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
dev-packages/node-integration-tests/suites/tracing/meta-tags-twp/server.js
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
const { loggingTransport } = require('@sentry-internal/node-integration-tests'); | ||
const Sentry = require('@sentry/node'); | ||
|
||
Sentry.init({ | ||
dsn: 'https://[email protected]/1337', | ||
transport: loggingTransport, | ||
}); | ||
|
||
// express must be required after Sentry is initialized | ||
const express = require('express'); | ||
const { startExpressServerAndSendPortToRunner } = require('@sentry-internal/node-integration-tests'); | ||
|
||
const app = express(); | ||
|
||
app.get('/test', (_req, res) => { | ||
res.send({ | ||
response: ` | ||
<html> | ||
<head> | ||
${Sentry.getTraceMetaTags()} | ||
</head> | ||
<body> | ||
Hi :) | ||
</body> | ||
</html> | ||
`, | ||
}); | ||
}); | ||
|
||
Sentry.setupExpressErrorHandler(app); | ||
|
||
startExpressServerAndSendPortToRunner(app); |
31 changes: 31 additions & 0 deletions
31
dev-packages/node-integration-tests/suites/tracing/meta-tags-twp/test.ts
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { cleanupChildProcesses, createRunner } from '../../../utils/runner'; | ||
|
||
describe('getTraceMetaTags', () => { | ||
afterAll(() => { | ||
cleanupChildProcesses(); | ||
}); | ||
|
||
test('injects sentry tracing <meta> tags without sampled flag for Tracing Without Performance', async () => { | ||
const runner = createRunner(__dirname, 'server.js').start(); | ||
|
||
const response = await runner.makeRequest('get', '/test'); | ||
|
||
// @ts-ignore - response is defined, types just don't reflect it | ||
const html = response?.response as unknown as string; | ||
|
||
const [, traceId, spanId] = html.match(/<meta name="sentry-trace" content="([a-f0-9]{32})-([a-f0-9]{16})"\/>/) || [ | ||
undefined, | ||
undefined, | ||
undefined, | ||
]; | ||
|
||
expect(traceId).toBeDefined(); | ||
expect(spanId).toBeDefined(); | ||
|
||
const sentryBaggageContent = html.match(/<meta name="baggage" content="(.*)"\/>/)?.[1]; | ||
|
||
expect(sentryBaggageContent).toContain('sentry-environment=production'); | ||
expect(sentryBaggageContent).toContain('sentry-public_key=public'); | ||
expect(sentryBaggageContent).toContain(`sentry-trace_id=${traceId}`); | ||
}); | ||
}); |
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
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
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
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
Oops, something went wrong.