From e8d71aaa9af6ebf5f7495799f882905ffea1ad62 Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Fri, 2 Aug 2024 18:27:52 +0200 Subject: [PATCH 01/10] feat(core): Add `getTracingMetaTags` function --- .../suites/tracing/meta-tags/server.js | 33 +++++++++++++++++++ .../suites/tracing/meta-tags/test.ts | 25 ++++++++++++++ packages/core/src/index.ts | 1 + packages/core/src/utils/meta.ts | 24 ++++++++++++++ packages/core/test/lib/utils/meta.test.ts | 30 +++++++++++++++++ packages/node/src/index.ts | 1 + 6 files changed, 114 insertions(+) create mode 100644 dev-packages/node-integration-tests/suites/tracing/meta-tags/server.js create mode 100644 dev-packages/node-integration-tests/suites/tracing/meta-tags/test.ts create mode 100644 packages/core/src/utils/meta.ts create mode 100644 packages/core/test/lib/utils/meta.test.ts diff --git a/dev-packages/node-integration-tests/suites/tracing/meta-tags/server.js b/dev-packages/node-integration-tests/suites/tracing/meta-tags/server.js new file mode 100644 index 000000000000..98c9392cfac3 --- /dev/null +++ b/dev-packages/node-integration-tests/suites/tracing/meta-tags/server.js @@ -0,0 +1,33 @@ +const { loggingTransport } = require('@sentry-internal/node-integration-tests'); +const Sentry = require('@sentry/node'); + +Sentry.init({ + dsn: 'https://public@dsn.ingest.sentry.io/1337', + tracesSampleRate: 1.0, + 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: ` + + + ${Sentry.getTracingMetaTags()} + + + Hi :) + + + `, + }); +}); + +Sentry.setupExpressErrorHandler(app); + +startExpressServerAndSendPortToRunner(app); diff --git a/dev-packages/node-integration-tests/suites/tracing/meta-tags/test.ts b/dev-packages/node-integration-tests/suites/tracing/meta-tags/test.ts new file mode 100644 index 000000000000..6c231b465e3d --- /dev/null +++ b/dev-packages/node-integration-tests/suites/tracing/meta-tags/test.ts @@ -0,0 +1,25 @@ +import { cleanupChildProcesses, createRunner } from '../../../utils/runner'; + +describe('getTracingMetaTags', () => { + afterAll(() => { + cleanupChildProcesses(); + }); + + test('injects sentry tracing tags', async () => { + const traceId = 'cd7ee7a6fe3ebe7ab9c3271559bc203c'; + const parentSpanId = '100ff0980e7a4ead'; + + const runner = createRunner(__dirname, 'server.js').start(); + + const response = await runner.makeRequest('get', '/test', { + 'sentry-trace': `${traceId}-${parentSpanId}-1`, + baggage: 'sentry-environment=production', + }); + + // @ts-expect-error - this is a string, types just don't work well + const html = response?.response as string; + + expect(html).toMatch(//); + expect(html).toContain(''); + }); +}); diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 5c21c8e484ed..958184a0a8a4 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -83,6 +83,7 @@ export { export { parseSampleRate } from './utils/parseSampleRate'; export { applySdkMetadata } from './utils/sdkMetadata'; export { getTraceData } from './utils/traceData'; +export { getTracingMetaTags } from './utils/meta'; export { DEFAULT_ENVIRONMENT } from './constants'; export { addBreadcrumb } from './breadcrumbs'; export { functionToStringIntegration } from './integrations/functiontostring'; diff --git a/packages/core/src/utils/meta.ts b/packages/core/src/utils/meta.ts new file mode 100644 index 000000000000..beb61600c62a --- /dev/null +++ b/packages/core/src/utils/meta.ts @@ -0,0 +1,24 @@ +import type { Client, Scope, Span } from '@sentry/types'; +import { getTraceData } from './traceData'; /** + * Returns a string of meta tags that represent the tracing data. + * + * You can use this to propagate a trace from your server-side rendered Html to the browser. + * Usage example: + * + * ```js + * function renderHtml() { + * return ` + * + * ${getTracingMetaTags()} + * + * `; + * } + * ``` + * + * @returns + */ +export function getTracingMetaTags(span?: Span, scope?: Scope, client?: Client): string { + return Object.entries(getTraceData(span, scope, client)) + .map(([key, value]) => ``) + .join('\n'); +} diff --git a/packages/core/test/lib/utils/meta.test.ts b/packages/core/test/lib/utils/meta.test.ts new file mode 100644 index 000000000000..4f244b5ceb0e --- /dev/null +++ b/packages/core/test/lib/utils/meta.test.ts @@ -0,0 +1,30 @@ +import { getTracingMetaTags } from '../../../src/utils/meta'; +import * as TraceDataModule from '../../../src/utils/traceData'; + +describe('getTracingMetaTags', () => { + it('renders baggage and sentry-trace values to stringified Html meta tags', () => { + jest.spyOn(TraceDataModule, 'getTraceData').mockReturnValueOnce({ + 'sentry-trace': '12345678901234567890123456789012-1234567890123456-1', + baggage: 'sentry-environment=production', + }); + + expect(getTracingMetaTags()).toBe(` +`); + }); + + it('renders just sentry-trace values to stringified Html meta tags', () => { + jest.spyOn(TraceDataModule, 'getTraceData').mockReturnValueOnce({ + 'sentry-trace': '12345678901234567890123456789012-1234567890123456-1', + }); + + expect(getTracingMetaTags()).toBe( + '', + ); + }); + + it('returns an empty string if neither sentry-trace nor baggage values are available', () => { + jest.spyOn(TraceDataModule, 'getTraceData').mockReturnValueOnce({}); + + expect(getTracingMetaTags()).toBe(''); + }); +}); diff --git a/packages/node/src/index.ts b/packages/node/src/index.ts index 3aa519c055d1..777a1f474ebc 100644 --- a/packages/node/src/index.ts +++ b/packages/node/src/index.ts @@ -96,6 +96,7 @@ export { getCurrentScope, getIsolationScope, getTraceData, + getTracingMetaTags, withScope, withIsolationScope, captureException, From 95fd6b13b79d7868f821507149291de2ee73df7b Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Fri, 2 Aug 2024 18:33:08 +0200 Subject: [PATCH 02/10] biome... --- packages/core/src/utils/meta.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/core/src/utils/meta.ts b/packages/core/src/utils/meta.ts index beb61600c62a..156db335dbb8 100644 --- a/packages/core/src/utils/meta.ts +++ b/packages/core/src/utils/meta.ts @@ -1,5 +1,7 @@ import type { Client, Scope, Span } from '@sentry/types'; -import { getTraceData } from './traceData'; /** +import { getTraceData } from './traceData'; + +/** * Returns a string of meta tags that represent the tracing data. * * You can use this to propagate a trace from your server-side rendered Html to the browser. From 478c23b780eaa9d3f9f926fa0822f7dfb66f102f Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Fri, 2 Aug 2024 18:39:27 +0200 Subject: [PATCH 03/10] re-export from framework sdks --- packages/astro/src/server/middleware.ts | 10 ++++------ packages/astro/test/server/middleware.test.ts | 10 ++++++---- packages/aws-serverless/src/index.ts | 1 + packages/bun/src/index.ts | 1 + packages/cloudflare/src/index.ts | 1 + packages/deno/src/index.ts | 1 + packages/google-cloud-serverless/src/index.ts | 1 + packages/sveltekit/src/server/index.ts | 1 + packages/vercel-edge/src/index.ts | 1 + 9 files changed, 17 insertions(+), 10 deletions(-) diff --git a/packages/astro/src/server/middleware.ts b/packages/astro/src/server/middleware.ts index 6b668f462489..a653fbc2bcee 100644 --- a/packages/astro/src/server/middleware.ts +++ b/packages/astro/src/server/middleware.ts @@ -6,6 +6,7 @@ import { getActiveSpan, getClient, getCurrentScope, + getTracingMetaTags, setHttpStatus, startSpan, withIsolationScope, @@ -189,16 +190,13 @@ function addMetaTagToHead(htmlChunk: string, scope: Scope, client: Client, span? if (typeof htmlChunk !== 'string') { return htmlChunk; } - const { 'sentry-trace': sentryTrace, baggage } = getTraceData(span, scope, client); + const metaTags = getTracingMetaTags(span, scope, client); - if (!sentryTrace) { + if (!metaTags) { return htmlChunk; } - const sentryTraceMeta = ``; - const baggageMeta = baggage && ``; - - const content = `\n${sentryTraceMeta}`.concat(baggageMeta ? `\n${baggageMeta}` : '', '\n'); + const content = `${metaTags}`; return htmlChunk.replace('', content); } diff --git a/packages/astro/test/server/middleware.test.ts b/packages/astro/test/server/middleware.test.ts index 58405c8d1c12..b2d7f00b4fc3 100644 --- a/packages/astro/test/server/middleware.test.ts +++ b/packages/astro/test/server/middleware.test.ts @@ -34,10 +34,12 @@ describe('sentryMiddleware', () => { }); vi.spyOn(SentryNode, 'getActiveSpan').mockImplementation(getSpanMock); vi.spyOn(SentryNode, 'getClient').mockImplementation(() => ({}) as Client); - vi.spyOn(SentryNode, 'getTraceData').mockImplementation(() => ({ - 'sentry-trace': '123', - baggage: 'abc', - })); + vi.spyOn(SentryNode, 'getTracingMetaTags').mockImplementation( + () => ` + + + `, + ); vi.spyOn(SentryCore, 'getDynamicSamplingContextFromSpan').mockImplementation(() => ({ transaction: 'test', })); diff --git a/packages/aws-serverless/src/index.ts b/packages/aws-serverless/src/index.ts index 95b2d553f2d4..475e4a56444a 100644 --- a/packages/aws-serverless/src/index.ts +++ b/packages/aws-serverless/src/index.ts @@ -21,6 +21,7 @@ export { getGlobalScope, getIsolationScope, getTraceData, + getTracingMetaTags, setCurrentClient, Scope, SDK_VERSION, diff --git a/packages/bun/src/index.ts b/packages/bun/src/index.ts index 287dbc26eeee..5d417c4ab007 100644 --- a/packages/bun/src/index.ts +++ b/packages/bun/src/index.ts @@ -41,6 +41,7 @@ export { getGlobalScope, getIsolationScope, getTraceData, + getTracingMetaTags, setCurrentClient, Scope, SDK_VERSION, diff --git a/packages/cloudflare/src/index.ts b/packages/cloudflare/src/index.ts index 867abd8e4a6e..db4643941580 100644 --- a/packages/cloudflare/src/index.ts +++ b/packages/cloudflare/src/index.ts @@ -56,6 +56,7 @@ export { getActiveSpan, getRootSpan, getTraceData, + getTracingMetaTags, startSpan, startInactiveSpan, startSpanManual, diff --git a/packages/deno/src/index.ts b/packages/deno/src/index.ts index 69b26bb1729a..4aad52e38d6c 100644 --- a/packages/deno/src/index.ts +++ b/packages/deno/src/index.ts @@ -56,6 +56,7 @@ export { getActiveSpan, getRootSpan, getTraceData, + getTracingMetaTags, startSpan, startInactiveSpan, startSpanManual, diff --git a/packages/google-cloud-serverless/src/index.ts b/packages/google-cloud-serverless/src/index.ts index 351f843d2c2d..4f49fc6075ec 100644 --- a/packages/google-cloud-serverless/src/index.ts +++ b/packages/google-cloud-serverless/src/index.ts @@ -21,6 +21,7 @@ export { getGlobalScope, getIsolationScope, getTraceData, + getTracingMetaTags, setCurrentClient, Scope, SDK_VERSION, diff --git a/packages/sveltekit/src/server/index.ts b/packages/sveltekit/src/server/index.ts index a74e5bb89dc0..ec9eac737223 100644 --- a/packages/sveltekit/src/server/index.ts +++ b/packages/sveltekit/src/server/index.ts @@ -52,6 +52,7 @@ export { getSpanDescendants, getSpanStatusFromHttpCode, getTraceData, + getTracingMetaTags, graphqlIntegration, hapiIntegration, httpIntegration, diff --git a/packages/vercel-edge/src/index.ts b/packages/vercel-edge/src/index.ts index a96fc15e35d2..77fd1ecbb81d 100644 --- a/packages/vercel-edge/src/index.ts +++ b/packages/vercel-edge/src/index.ts @@ -56,6 +56,7 @@ export { getActiveSpan, getRootSpan, getTraceData, + getTracingMetaTags, startSpan, startInactiveSpan, startSpanManual, From 1fcd07bebeae93f58bd5c69cfec06bf387bef195 Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Mon, 5 Aug 2024 11:31:14 +0200 Subject: [PATCH 04/10] s/getTracingMetaTags/getTraceMetaTags --- .../suites/tracing/meta-tags/server.js | 2 +- .../suites/tracing/meta-tags/test.ts | 2 +- packages/astro/src/server/middleware.ts | 6 ++---- packages/astro/test/server/middleware.test.ts | 2 +- packages/aws-serverless/src/index.ts | 2 +- packages/bun/src/index.ts | 2 +- packages/cloudflare/src/index.ts | 2 +- packages/core/src/index.ts | 2 +- packages/core/src/utils/meta.ts | 10 +++++++--- packages/core/test/lib/utils/meta.test.ts | 10 +++++----- packages/deno/src/index.ts | 2 +- packages/google-cloud-serverless/src/index.ts | 2 +- packages/node/src/index.ts | 2 +- packages/sveltekit/src/server/index.ts | 2 +- packages/vercel-edge/src/index.ts | 2 +- 15 files changed, 26 insertions(+), 24 deletions(-) diff --git a/dev-packages/node-integration-tests/suites/tracing/meta-tags/server.js b/dev-packages/node-integration-tests/suites/tracing/meta-tags/server.js index 98c9392cfac3..35e204a05d6b 100644 --- a/dev-packages/node-integration-tests/suites/tracing/meta-tags/server.js +++ b/dev-packages/node-integration-tests/suites/tracing/meta-tags/server.js @@ -18,7 +18,7 @@ app.get('/test', (_req, res) => { response: ` - ${Sentry.getTracingMetaTags()} + ${Sentry.getTraceMetaTags()} Hi :) diff --git a/dev-packages/node-integration-tests/suites/tracing/meta-tags/test.ts b/dev-packages/node-integration-tests/suites/tracing/meta-tags/test.ts index 6c231b465e3d..169118adcc72 100644 --- a/dev-packages/node-integration-tests/suites/tracing/meta-tags/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/meta-tags/test.ts @@ -1,6 +1,6 @@ import { cleanupChildProcesses, createRunner } from '../../../utils/runner'; -describe('getTracingMetaTags', () => { +describe('getTraceMetaTags', () => { afterAll(() => { cleanupChildProcesses(); }); diff --git a/packages/astro/src/server/middleware.ts b/packages/astro/src/server/middleware.ts index a653fbc2bcee..4b2f15eb3be4 100644 --- a/packages/astro/src/server/middleware.ts +++ b/packages/astro/src/server/middleware.ts @@ -6,7 +6,7 @@ import { getActiveSpan, getClient, getCurrentScope, - getTracingMetaTags, + getTraceMetaTags, setHttpStatus, startSpan, withIsolationScope, @@ -15,8 +15,6 @@ import type { Client, Scope, Span, SpanAttributes } from '@sentry/types'; import { addNonEnumerableProperty, objectify, stripUrlQueryAndFragment } from '@sentry/utils'; import type { APIContext, MiddlewareResponseHandler } from 'astro'; -import { getTraceData } from '@sentry/node'; - type MiddlewareOptions = { /** * If true, the client IP will be attached to the event by calling `setUser`. @@ -190,7 +188,7 @@ function addMetaTagToHead(htmlChunk: string, scope: Scope, client: Client, span? if (typeof htmlChunk !== 'string') { return htmlChunk; } - const metaTags = getTracingMetaTags(span, scope, client); + const metaTags = getTraceMetaTags(span, scope, client); if (!metaTags) { return htmlChunk; diff --git a/packages/astro/test/server/middleware.test.ts b/packages/astro/test/server/middleware.test.ts index b2d7f00b4fc3..bf96f6ef9046 100644 --- a/packages/astro/test/server/middleware.test.ts +++ b/packages/astro/test/server/middleware.test.ts @@ -34,7 +34,7 @@ describe('sentryMiddleware', () => { }); vi.spyOn(SentryNode, 'getActiveSpan').mockImplementation(getSpanMock); vi.spyOn(SentryNode, 'getClient').mockImplementation(() => ({}) as Client); - vi.spyOn(SentryNode, 'getTracingMetaTags').mockImplementation( + vi.spyOn(SentryNode, 'getTraceMetaTags').mockImplementation( () => ` diff --git a/packages/aws-serverless/src/index.ts b/packages/aws-serverless/src/index.ts index 475e4a56444a..20ef9eeaf09f 100644 --- a/packages/aws-serverless/src/index.ts +++ b/packages/aws-serverless/src/index.ts @@ -21,7 +21,7 @@ export { getGlobalScope, getIsolationScope, getTraceData, - getTracingMetaTags, + getTraceMetaTags, setCurrentClient, Scope, SDK_VERSION, diff --git a/packages/bun/src/index.ts b/packages/bun/src/index.ts index 5d417c4ab007..4de55fd1c5f7 100644 --- a/packages/bun/src/index.ts +++ b/packages/bun/src/index.ts @@ -41,7 +41,7 @@ export { getGlobalScope, getIsolationScope, getTraceData, - getTracingMetaTags, + getTraceMetaTags, setCurrentClient, Scope, SDK_VERSION, diff --git a/packages/cloudflare/src/index.ts b/packages/cloudflare/src/index.ts index db4643941580..1688b84448f9 100644 --- a/packages/cloudflare/src/index.ts +++ b/packages/cloudflare/src/index.ts @@ -56,7 +56,7 @@ export { getActiveSpan, getRootSpan, getTraceData, - getTracingMetaTags, + getTraceMetaTags, startSpan, startInactiveSpan, startSpanManual, diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 958184a0a8a4..73295f7df64c 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -83,7 +83,7 @@ export { export { parseSampleRate } from './utils/parseSampleRate'; export { applySdkMetadata } from './utils/sdkMetadata'; export { getTraceData } from './utils/traceData'; -export { getTracingMetaTags } from './utils/meta'; +export { getTraceMetaTags } from './utils/meta'; export { DEFAULT_ENVIRONMENT } from './constants'; export { addBreadcrumb } from './breadcrumbs'; export { functionToStringIntegration } from './integrations/functiontostring'; diff --git a/packages/core/src/utils/meta.ts b/packages/core/src/utils/meta.ts index 156db335dbb8..4511633e1629 100644 --- a/packages/core/src/utils/meta.ts +++ b/packages/core/src/utils/meta.ts @@ -2,16 +2,20 @@ import type { Client, Scope, Span } from '@sentry/types'; import { getTraceData } from './traceData'; /** - * Returns a string of meta tags that represent the tracing data. + * Returns a string of meta tags that represent the current trace data. * * You can use this to propagate a trace from your server-side rendered Html to the browser. + * This function returns up to two meta tags, `sentry-trace` and `baggage`, depending on the + * current trace data state. + * + * @example * Usage example: * * ```js * function renderHtml() { * return ` * - * ${getTracingMetaTags()} + * ${getTraceMetaTags()} * * `; * } @@ -19,7 +23,7 @@ import { getTraceData } from './traceData'; * * @returns */ -export function getTracingMetaTags(span?: Span, scope?: Scope, client?: Client): string { +export function getTraceMetaTags(span?: Span, scope?: Scope, client?: Client): string { return Object.entries(getTraceData(span, scope, client)) .map(([key, value]) => ``) .join('\n'); diff --git a/packages/core/test/lib/utils/meta.test.ts b/packages/core/test/lib/utils/meta.test.ts index 4f244b5ceb0e..3d78247b8951 100644 --- a/packages/core/test/lib/utils/meta.test.ts +++ b/packages/core/test/lib/utils/meta.test.ts @@ -1,14 +1,14 @@ -import { getTracingMetaTags } from '../../../src/utils/meta'; +import { getTraceMetaTags } from '../../../src/utils/meta'; import * as TraceDataModule from '../../../src/utils/traceData'; -describe('getTracingMetaTags', () => { +describe('getTraceMetaTags', () => { it('renders baggage and sentry-trace values to stringified Html meta tags', () => { jest.spyOn(TraceDataModule, 'getTraceData').mockReturnValueOnce({ 'sentry-trace': '12345678901234567890123456789012-1234567890123456-1', baggage: 'sentry-environment=production', }); - expect(getTracingMetaTags()).toBe(` + expect(getTraceMetaTags()).toBe(` `); }); @@ -17,7 +17,7 @@ describe('getTracingMetaTags', () => { 'sentry-trace': '12345678901234567890123456789012-1234567890123456-1', }); - expect(getTracingMetaTags()).toBe( + expect(getTraceMetaTags()).toBe( '', ); }); @@ -25,6 +25,6 @@ describe('getTracingMetaTags', () => { it('returns an empty string if neither sentry-trace nor baggage values are available', () => { jest.spyOn(TraceDataModule, 'getTraceData').mockReturnValueOnce({}); - expect(getTracingMetaTags()).toBe(''); + expect(getTraceMetaTags()).toBe(''); }); }); diff --git a/packages/deno/src/index.ts b/packages/deno/src/index.ts index 4aad52e38d6c..1f983b476b74 100644 --- a/packages/deno/src/index.ts +++ b/packages/deno/src/index.ts @@ -56,7 +56,7 @@ export { getActiveSpan, getRootSpan, getTraceData, - getTracingMetaTags, + getTraceMetaTags, startSpan, startInactiveSpan, startSpanManual, diff --git a/packages/google-cloud-serverless/src/index.ts b/packages/google-cloud-serverless/src/index.ts index 4f49fc6075ec..73f24f9cf39e 100644 --- a/packages/google-cloud-serverless/src/index.ts +++ b/packages/google-cloud-serverless/src/index.ts @@ -21,7 +21,7 @@ export { getGlobalScope, getIsolationScope, getTraceData, - getTracingMetaTags, + getTraceMetaTags, setCurrentClient, Scope, SDK_VERSION, diff --git a/packages/node/src/index.ts b/packages/node/src/index.ts index 777a1f474ebc..401a28e6fc70 100644 --- a/packages/node/src/index.ts +++ b/packages/node/src/index.ts @@ -96,7 +96,7 @@ export { getCurrentScope, getIsolationScope, getTraceData, - getTracingMetaTags, + getTraceMetaTags, withScope, withIsolationScope, captureException, diff --git a/packages/sveltekit/src/server/index.ts b/packages/sveltekit/src/server/index.ts index ec9eac737223..99813d01ceba 100644 --- a/packages/sveltekit/src/server/index.ts +++ b/packages/sveltekit/src/server/index.ts @@ -52,7 +52,7 @@ export { getSpanDescendants, getSpanStatusFromHttpCode, getTraceData, - getTracingMetaTags, + getTraceMetaTags, graphqlIntegration, hapiIntegration, httpIntegration, diff --git a/packages/vercel-edge/src/index.ts b/packages/vercel-edge/src/index.ts index 77fd1ecbb81d..8be93345fa3d 100644 --- a/packages/vercel-edge/src/index.ts +++ b/packages/vercel-edge/src/index.ts @@ -56,7 +56,7 @@ export { getActiveSpan, getRootSpan, getTraceData, - getTracingMetaTags, + getTraceMetaTags, startSpan, startInactiveSpan, startSpanManual, From 93b9ef0170b00e88d6818ca9780edce8e8e6b471 Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Mon, 5 Aug 2024 18:08:06 +0200 Subject: [PATCH 05/10] Update packages/core/src/utils/meta.ts Co-authored-by: Andrei <168741329+andreiborza@users.noreply.github.com> --- packages/core/src/utils/meta.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/core/src/utils/meta.ts b/packages/core/src/utils/meta.ts index 4511633e1629..339dfcee2f28 100644 --- a/packages/core/src/utils/meta.ts +++ b/packages/core/src/utils/meta.ts @@ -21,7 +21,6 @@ import { getTraceData } from './traceData'; * } * ``` * - * @returns */ export function getTraceMetaTags(span?: Span, scope?: Scope, client?: Client): string { return Object.entries(getTraceData(span, scope, client)) From 54c1cac6c717e9d1c3642702e3a154408db8646b Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Tue, 6 Aug 2024 11:20:44 +0200 Subject: [PATCH 06/10] add missing export in astro --- packages/astro/src/index.server.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/astro/src/index.server.ts b/packages/astro/src/index.server.ts index 1084643584d6..7f52ad0dc0bb 100644 --- a/packages/astro/src/index.server.ts +++ b/packages/astro/src/index.server.ts @@ -56,6 +56,7 @@ export { getSpanDescendants, getSpanStatusFromHttpCode, getTraceData, + getTraceMetaTags, graphqlIntegration, hapiIntegration, httpIntegration, From f6b757f39804e54d565ec0bb42df1e263393f22f Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Tue, 6 Aug 2024 13:26:16 +0200 Subject: [PATCH 07/10] fix ts 3.8 test pls? --- .../node-integration-tests/suites/tracing/meta-tags/test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev-packages/node-integration-tests/suites/tracing/meta-tags/test.ts b/dev-packages/node-integration-tests/suites/tracing/meta-tags/test.ts index 169118adcc72..5529fbf5dd49 100644 --- a/dev-packages/node-integration-tests/suites/tracing/meta-tags/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/meta-tags/test.ts @@ -17,7 +17,7 @@ describe('getTraceMetaTags', () => { }); // @ts-expect-error - this is a string, types just don't work well - const html = response?.response as string; + const html = response?.response as unknown as string; expect(html).toMatch(//); expect(html).toContain(''); From a6d7a69240c94a992fd1fc3253c81281d41f4ab7 Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Tue, 6 Aug 2024 13:43:07 +0200 Subject: [PATCH 08/10] maybe now? --- .../node-integration-tests/suites/tracing/meta-tags/test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev-packages/node-integration-tests/suites/tracing/meta-tags/test.ts b/dev-packages/node-integration-tests/suites/tracing/meta-tags/test.ts index 5529fbf5dd49..afdb39c2f8a5 100644 --- a/dev-packages/node-integration-tests/suites/tracing/meta-tags/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/meta-tags/test.ts @@ -17,7 +17,7 @@ describe('getTraceMetaTags', () => { }); // @ts-expect-error - this is a string, types just don't work well - const html = response?.response as unknown as string; + const html = typeof response === 'object' && (response?.response as unknown as string); expect(html).toMatch(//); expect(html).toContain(''); From 0b44b9d7cbd03ed343ef42d188c3407f819a52f1 Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Tue, 6 Aug 2024 13:45:53 +0200 Subject: [PATCH 09/10] remove ts-expect-error --- .../node-integration-tests/suites/tracing/meta-tags/test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dev-packages/node-integration-tests/suites/tracing/meta-tags/test.ts b/dev-packages/node-integration-tests/suites/tracing/meta-tags/test.ts index afdb39c2f8a5..6a5356fa79e8 100644 --- a/dev-packages/node-integration-tests/suites/tracing/meta-tags/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/meta-tags/test.ts @@ -16,8 +16,8 @@ describe('getTraceMetaTags', () => { baggage: 'sentry-environment=production', }); - // @ts-expect-error - this is a string, types just don't work well - const html = typeof response === 'object' && (response?.response as unknown as string); + const html = + typeof response === 'object' && response && 'response' in response && (response?.response as unknown as string); expect(html).toMatch(//); expect(html).toContain(''); From 44cadee91f37d954a088f99568dea5c9fdc1e4f2 Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Tue, 6 Aug 2024 14:12:04 +0200 Subject: [PATCH 10/10] use ts-ignore --- .../node-integration-tests/suites/tracing/meta-tags/test.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dev-packages/node-integration-tests/suites/tracing/meta-tags/test.ts b/dev-packages/node-integration-tests/suites/tracing/meta-tags/test.ts index 6a5356fa79e8..22bef9d2b1b9 100644 --- a/dev-packages/node-integration-tests/suites/tracing/meta-tags/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/meta-tags/test.ts @@ -16,8 +16,9 @@ describe('getTraceMetaTags', () => { baggage: 'sentry-environment=production', }); - const html = - typeof response === 'object' && response && 'response' in response && (response?.response as unknown as string); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + const html = response?.response as unknown as string; expect(html).toMatch(//); expect(html).toContain('');