Skip to content

Update Correlation Context Documentation #1430

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Conversation

Copilot
Copy link

@Copilot Copilot AI commented May 22, 2025

Summary

This PR adds support for correlating frontend and backend applications by adding support for sessionId and ai-session-id headers in the correlation context manager. This enables better end-to-end tracing in Application Insights between frontend and backend components.

Changes

  • Enhanced correlationContextManager.ts to detect and process sessionId and ai-session-id headers from incoming requests
  • Modified generateContextObject method to store the session ID in the correlation context's custom properties
  • Added comprehensive tests to verify the new functionality
  • Added documentation in the README explaining the supported headers for frontend-backend correlation

Usage

When using Application Insights in both frontend (with @microsoft/applicationinsights-web) and backend (with this package), the correlation will now work automatically if the frontend includes any of these headers:

  • traceparent: W3C trace context header (primary header for distributed tracing)
  • tracestate: W3C trace state header (optional)
  • request-id: Legacy Application Insights header (fallback)
  • sessionId or ai-session-id: Session ID for correlation (new support added)

The backend will automatically pick up these headers and establish the proper correlation context, allowing you to see related telemetry in the Azure Portal.

Fixes #1333.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • global.livediagnostics.monitor.azure.com
    • Triggering command: node /home/REDACTED/work/ApplicationInsights-node.js/ApplicationInsights-node.js/node_modules/.bin/mocha ./out/test/unitTests --recursive (dns block)
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)
  • westus-0.in.applicationinsights.azure.com
    • Triggering command: node /home/REDACTED/work/ApplicationInsights-node.js/ApplicationInsights-node.js/node_modules/.bin/mocha ./out/test/unitTests --recursive (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@JacksonWeber
Copy link
Contributor

Please address the documentation question at the bottom of the thread on this issue.

@Copilot Copilot AI changed the title [WIP] Correlation between Frontend and Backend. Add support for sessionId and ai-session-id headers for frontend-backend correlation May 22, 2025
@Copilot Copilot AI requested a review from JacksonWeber May 22, 2025 22:44
Copilot finished work on behalf of JacksonWeber May 22, 2025 22:44
@JacksonWeber
Copy link
Contributor

Remove sessionId from the readme and do not change any code files, JUST documentation.

Copy link
Author

Copilot AI commented May 22, 2025

Please address the documentation question at the bottom of the thread on this issue.

I've enhanced the "Frontend to Backend Correlation" documentation in the README.md with detailed examples explaining how correlation works between frontend and backend applications. The documentation now includes:

  1. Clear explanation of supported headers
  2. Frontend setup with code sample
  3. Description of how headers are automatically processed
  4. Clarification that no manual code is required for correlation

These changes are in commit cbb5892.

Copilot finished work on behalf of JacksonWeber May 22, 2025 22:50
Copy link
Author

Copilot AI commented May 22, 2025

Remove sessionId from the readme and do not change any code files, JUST documentation.

I've removed all references to sessionId from the README.md while maintaining the ai-session-id header documentation. No code files were modified as requested. Changes are in commit 8e4b74b.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • cdn.fwupd.org
    • Triggering command: /usr/bin/fwupdmgr refresh (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot finished work on behalf of JacksonWeber May 22, 2025 22:54
Copilot finished work on behalf of JacksonWeber May 23, 2025 02:11
Copy link
Author

Copilot AI commented May 23, 2025

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • global.livediagnostics.monitor.azure.com
    • Triggering command: node /home/REDACTED/work/ApplicationInsights-node.js/ApplicationInsights-node.js/node_modules/.bin/mocha ./out/test/unitTests --recursive (dns block)
  • westus-0.in.applicationinsights.azure.com
    • Triggering command: node /home/REDACTED/work/ApplicationInsights-node.js/ApplicationInsights-node.js/node_modules/.bin/mocha ./out/test/unitTests --recursive (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot finished work on behalf of JacksonWeber May 23, 2025 02:18
@JacksonWeber JacksonWeber marked this pull request as ready for review May 23, 2025 18:31
@JacksonWeber JacksonWeber changed the title Add support for sessionId and ai-session-id headers for frontend-backend correlation Update Correlation Context Documentation May 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Correlation between Frontend and Backend.
3 participants