Skip to content

Commit

Permalink
Added IS_SYNTHETIC_REQUEST window.env used to set the span web attrib…
Browse files Browse the repository at this point in the history
…ute in FrontendTracer.ts
  • Loading branch information
jordibisbal8 committed Jan 30, 2024
1 parent e556c4a commit fd6bc27
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/frontend/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
}
}
Expand Down
1 change: 1 addition & 0 deletions src/frontend/pages/_document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/utils/telemetry/FrontendTracer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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);
},
},
}),
Expand Down

0 comments on commit fd6bc27

Please sign in to comment.