From fd6bc2726da06164f83bb230bfd3927a52fa02e5 Mon Sep 17 00:00:00 2001 From: Jordi Bisbal Ansaldo Date: Tue, 30 Jan 2024 10:26:25 +0100 Subject: [PATCH] Added IS_SYNTHETIC_REQUEST window.env used to set the span web attribute in FrontendTracer.ts --- src/frontend/pages/_app.tsx | 1 + src/frontend/pages/_document.tsx | 1 + src/frontend/utils/telemetry/FrontendTracer.ts | 4 ++-- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/frontend/pages/_app.tsx b/src/frontend/pages/_app.tsx index e5e1523277..6da83d3664 100755 --- a/src/frontend/pages/_app.tsx +++ b/src/frontend/pages/_app.tsx @@ -17,6 +17,7 @@ declare global { NEXT_PUBLIC_PLATFORM?: string; NEXT_PUBLIC_OTEL_SERVICE_NAME?: string; NEXT_PUBLIC_OTEL_EXPORTER_OTLP_TRACES_ENDPOINT?: string; + IS_SYNTHETIC_REQUEST?: string; }; } } diff --git a/src/frontend/pages/_document.tsx b/src/frontend/pages/_document.tsx index 33dabe0a65..15e978d4d8 100644 --- a/src/frontend/pages/_document.tsx +++ b/src/frontend/pages/_document.tsx @@ -31,6 +31,7 @@ export default class MyDocument extends Document<{ envString: string }> { NEXT_PUBLIC_PLATFORM: '${ENV_PLATFORM}', NEXT_PUBLIC_OTEL_SERVICE_NAME: '${WEB_OTEL_SERVICE_NAME}', NEXT_PUBLIC_OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: '${otlpTracesEndpoint}', + IS_SYNTHETIC_REQUEST: '${isSyntheticRequest}', };`; return { ...initialProps, diff --git a/src/frontend/utils/telemetry/FrontendTracer.ts b/src/frontend/utils/telemetry/FrontendTracer.ts index 1720409b0c..c7ccc83c8e 100644 --- a/src/frontend/utils/telemetry/FrontendTracer.ts +++ b/src/frontend/utils/telemetry/FrontendTracer.ts @@ -12,7 +12,7 @@ import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http'; import { SessionIdProcessor } from './SessionIdProcessor'; import { detectResourcesSync } from '@opentelemetry/resources/build/src/detect-resources'; -const { NEXT_PUBLIC_OTEL_SERVICE_NAME = '', NEXT_PUBLIC_OTEL_EXPORTER_OTLP_TRACES_ENDPOINT = '' } = +const { NEXT_PUBLIC_OTEL_SERVICE_NAME = '', NEXT_PUBLIC_OTEL_EXPORTER_OTLP_TRACES_ENDPOINT = '', IS_SYNTHETIC_REQUEST = '' } = typeof window !== 'undefined' ? window.ENV : {}; const FrontendTracer = async (collectorString: string) => { @@ -57,7 +57,7 @@ const FrontendTracer = async (collectorString: string) => { propagateTraceHeaderCorsUrls: /.*/, clearTimingResources: true, applyCustomAttributesOnSpan(span) { - span.setAttribute('app.synthetic_request', 'false'); + span.setAttribute('app.synthetic_request', IS_SYNTHETIC_REQUEST); }, }, }),