Skip to content

Commit fd6bc27

Browse files
committed
Added IS_SYNTHETIC_REQUEST window.env used to set the span web attribute in FrontendTracer.ts
1 parent e556c4a commit fd6bc27

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

src/frontend/pages/_app.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ declare global {
1717
NEXT_PUBLIC_PLATFORM?: string;
1818
NEXT_PUBLIC_OTEL_SERVICE_NAME?: string;
1919
NEXT_PUBLIC_OTEL_EXPORTER_OTLP_TRACES_ENDPOINT?: string;
20+
IS_SYNTHETIC_REQUEST?: string;
2021
};
2122
}
2223
}

src/frontend/pages/_document.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export default class MyDocument extends Document<{ envString: string }> {
3131
NEXT_PUBLIC_PLATFORM: '${ENV_PLATFORM}',
3232
NEXT_PUBLIC_OTEL_SERVICE_NAME: '${WEB_OTEL_SERVICE_NAME}',
3333
NEXT_PUBLIC_OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: '${otlpTracesEndpoint}',
34+
IS_SYNTHETIC_REQUEST: '${isSyntheticRequest}',
3435
};`;
3536
return {
3637
...initialProps,

src/frontend/utils/telemetry/FrontendTracer.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
1212
import { SessionIdProcessor } from './SessionIdProcessor';
1313
import { detectResourcesSync } from '@opentelemetry/resources/build/src/detect-resources';
1414

15-
const { NEXT_PUBLIC_OTEL_SERVICE_NAME = '', NEXT_PUBLIC_OTEL_EXPORTER_OTLP_TRACES_ENDPOINT = '' } =
15+
const { NEXT_PUBLIC_OTEL_SERVICE_NAME = '', NEXT_PUBLIC_OTEL_EXPORTER_OTLP_TRACES_ENDPOINT = '', IS_SYNTHETIC_REQUEST = '' } =
1616
typeof window !== 'undefined' ? window.ENV : {};
1717

1818
const FrontendTracer = async (collectorString: string) => {
@@ -57,7 +57,7 @@ const FrontendTracer = async (collectorString: string) => {
5757
propagateTraceHeaderCorsUrls: /.*/,
5858
clearTimingResources: true,
5959
applyCustomAttributesOnSpan(span) {
60-
span.setAttribute('app.synthetic_request', 'false');
60+
span.setAttribute('app.synthetic_request', IS_SYNTHETIC_REQUEST);
6161
},
6262
},
6363
}),

0 commit comments

Comments
 (0)