Skip to content

Commit 219b070

Browse files
committed
s/getTracingMetaTags/getTracingMetaTagValues
1 parent 6be5f22 commit 219b070

File tree

11 files changed

+32
-22
lines changed

11 files changed

+32
-22
lines changed

packages/astro/src/index.server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export {
5555
getSentryRelease,
5656
getSpanDescendants,
5757
getSpanStatusFromHttpCode,
58-
getTracingMetaTags,
58+
getTracingMetaTagValues,
5959
graphqlIntegration,
6060
hapiIntegration,
6161
httpIntegration,

packages/astro/src/server/middleware.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import type { Client, Scope, Span, SpanAttributes } from '@sentry/types';
1414
import { addNonEnumerableProperty, objectify, stripUrlQueryAndFragment } from '@sentry/utils';
1515
import type { APIContext, MiddlewareResponseHandler } from 'astro';
1616

17-
import { getTracingMetaTags } from '@sentry/node';
17+
import { getTracingMetaTagValues } from '@sentry/node';
1818

1919
type MiddlewareOptions = {
2020
/**
@@ -189,7 +189,7 @@ function addMetaTagToHead(htmlChunk: string, scope: Scope, client: Client, span?
189189
if (typeof htmlChunk !== 'string') {
190190
return htmlChunk;
191191
}
192-
const { 'sentry-trace': sentryTrace, baggage } = getTracingMetaTags(span, scope, client);
192+
const { 'sentry-trace': sentryTrace, baggage } = getTracingMetaTagValues(span, scope, client);
193193

194194
const sentryTraceMeta = `<meta name="sentry-trace" content="${sentryTrace}"/>`;
195195
const baggageMeta = baggage && `<meta name="baggage" content="${baggage}"/>`;

packages/astro/test/integration/middleware/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { describe, expect, it, vi } from 'vitest';
33
import { onRequest } from '../../../src/integration/middleware';
44

55
vi.mock('../../../src/server/meta', () => ({
6-
getTracingMetaTags: () => ({
6+
getTracingMetaTagValues: () => ({
77
sentryTrace: '<meta name="sentry-trace" content="123">',
88
baggage: '<meta name="baggage" content="abc">',
99
}),

packages/astro/test/server/middleware.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
77
import { handleRequest, interpolateRouteFromUrlAndParams } from '../../src/server/middleware';
88

99
vi.mock('../../src/server/meta', () => ({
10-
getTracingMetaTags: () => ({
10+
getTracingMetaTagValues: () => ({
1111
sentryTrace: '<meta name="sentry-trace" content="123">',
1212
baggage: '<meta name="baggage" content="abc">',
1313
}),

packages/aws-serverless/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export {
2020
getCurrentScope,
2121
getGlobalScope,
2222
getIsolationScope,
23-
getTracingMetaTags,
23+
getTracingMetaTagValues,
2424
setCurrentClient,
2525
Scope,
2626
SDK_VERSION,

packages/bun/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export {
4040
getCurrentScope,
4141
getGlobalScope,
4242
getIsolationScope,
43-
getTracingMetaTags,
43+
getTracingMetaTagValues,
4444
setCurrentClient,
4545
Scope,
4646
SDK_VERSION,

packages/google-cloud-serverless/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export {
2020
getCurrentScope,
2121
getGlobalScope,
2222
getIsolationScope,
23-
getTracingMetaTags,
23+
getTracingMetaTagValues,
2424
setCurrentClient,
2525
Scope,
2626
SDK_VERSION,

packages/node/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export { initOpenTelemetry, preloadOpenTelemetry } from './sdk/initOtel';
4040
export { getAutoPerformanceIntegrations } from './integrations/tracing';
4141
export { getSentryRelease, defaultStackParser } from './sdk/api';
4242
export { createGetModuleFromFilename } from './utils/module';
43-
export { getTracingMetaTags } from './utils/meta';
43+
export { getTracingMetaTagValues } from './utils/meta';
4444
export { makeNodeTransport } from './transports';
4545
export { NodeClient } from './sdk/client';
4646
export { cron } from './cron';

packages/node/src/utils/meta.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,29 @@ import {
1313
} from '@sentry/utils';
1414

1515
/**
16-
* Extracts the tracing data from the current span or from the client's scope (via transaction or propagation context)
17-
* and serializes the data to <meta> tag contents.
16+
* Extracts trace propagation data from the current span or from the client's scope (via transaction or propagation
17+
* context) and serializes it to meta tag content values.
1818
*
19-
* Use this function to obtain the tracing meta tags you can inject when rendering an HTML response to continue
20-
* the server-initiated trace on the client.
19+
* Use this function to obtain data for the tracing meta tags you can inject when rendering an HTML response to
20+
* continue the server-initiated trace on the client.
21+
*
22+
* Example usage:
23+
*
24+
* ```js
25+
* // render meta tags as html
26+
* const tagValues = getTracingMetaTagValues(span, scope, client);
27+
* return `
28+
* <meta name="sentry-trace" content="${tagValues['sentry-trace']}"/>
29+
* ${tagValues.baggage ? `<meta name="baggage" content="${tagValues.baggage}"/>` : ''}`
30+
* ```
2131
*
2232
* @param span the currently active span
2333
* @param client the SDK's client
2434
*
25-
* @returns an object with the two meta tags. The object keys are the name of the meta tag,
35+
* @returns an object with the values of the tracing meta tags. The object keys are the name of the meta tag,
2636
* the respective value is the content.
2737
*/
28-
export function getTracingMetaTags(
38+
export function getTracingMetaTagValues(
2939
span: Span | undefined,
3040
scope: Scope,
3141
client: Client | undefined,

packages/node/test/utils/meta.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as SentryCore from '@sentry/core';
22
import { SentrySpan } from '@sentry/core';
33

4-
import { getTracingMetaTags, isValidBaggageString } from '../../src/utils/meta';
4+
import { getTracingMetaTagValues, isValidBaggageString } from '../../src/utils/meta';
55

66
const TRACE_FLAG_SAMPLED = 1;
77

@@ -19,14 +19,14 @@ const mockedScope = {
1919
}),
2020
} as any;
2121

22-
describe('getTracingMetaTags', () => {
22+
describe('getTracingMetaTagValues', () => {
2323
it('returns the tracing meta tags from the span, if it is provided', () => {
2424
{
2525
jest.spyOn(SentryCore, 'getDynamicSamplingContextFromSpan').mockReturnValueOnce({
2626
environment: 'production',
2727
});
2828

29-
const tags = getTracingMetaTags(mockedSpan, mockedScope, mockedClient);
29+
const tags = getTracingMetaTagValues(mockedSpan, mockedScope, mockedClient);
3030

3131
expect(tags).toEqual({
3232
'sentry-trace': '12345678901234567890123456789012-1234567890123456-1',
@@ -36,7 +36,7 @@ describe('getTracingMetaTags', () => {
3636
});
3737

3838
it('returns propagationContext DSC data if no span is available', () => {
39-
const tags = getTracingMetaTags(
39+
const tags = getTracingMetaTagValues(
4040
undefined,
4141
{
4242
getPropagationContext: () => ({
@@ -65,7 +65,7 @@ describe('getTracingMetaTags', () => {
6565
public_key: undefined,
6666
});
6767

68-
const tags = getTracingMetaTags(
68+
const tags = getTracingMetaTagValues(
6969
// @ts-expect-error - we don't need to provide all the properties
7070
{
7171
isRecording: () => true,
@@ -92,7 +92,7 @@ describe('getTracingMetaTags', () => {
9292
public_key: undefined,
9393
});
9494

95-
const tags = getTracingMetaTags(
95+
const tags = getTracingMetaTagValues(
9696
// @ts-expect-error - we don't need to provide all the properties
9797
{
9898
isRecording: () => true,

packages/sveltekit/src/server/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export {
5151
getSentryRelease,
5252
getSpanDescendants,
5353
getSpanStatusFromHttpCode,
54-
getTracingMetaTags,
54+
getTracingMetaTagValues,
5555
graphqlIntegration,
5656
hapiIntegration,
5757
httpIntegration,

0 commit comments

Comments
 (0)