Correlate Frontend and Backend telemetry
mainThe SDK uses W3C trace context to automatically correlate telemetry across distributed systems. To enable correlation between a frontend application (using @microsoft/applicationinsights-web) and this Node.js backend SDK, you must ensure the frontend is configured with enableCorsCorrelation: true.
Supported headers:
traceparent: (Required) W3C trace context header in format00-traceId-spanId-flags.tracestate: (Optional) W3C trace state header for vendor-specific data.
When a request arrives at the backend, the SDK automatically extracts these headers, creates a correlation context, and associates all subsequent telemetry with that context. No manual backend code is required for this process.
// Example of frontend setup with Application Insights
const appInsights = new ApplicationInsights({
config: {
connectionString: "your-connection-string",
enableCorsCorrelation: true // Important for cross-domain correlation
}
});
appInsights.loadAppInsights();