Skip to content

Enable HTTP traces for self-hosted Azure MCP server#1227

Merged
srnagar merged 6 commits intomicrosoft:mainfrom
srnagar:remote-diagnostics
Nov 20, 2025
Merged

Enable HTTP traces for self-hosted Azure MCP server#1227
srnagar merged 6 commits intomicrosoft:mainfrom
srnagar:remote-diagnostics

Conversation

@srnagar
Copy link
Copy Markdown
Member

@srnagar srnagar commented Nov 20, 2025

What does this PR do?

This pull request adds support for self-hosted telemetry using OpenTelemetry and Azure Monitor when the server is running in HTTP mode. It introduces a new method to configure a dedicated telemetry pipeline that exports traces to Application Insights, with environment-based controls for enabling or disabling telemetry collection. The implementation includes logic to filter out unwanted telemetry data to avoid duplication and feedback loops.

Telemetry and Observability Enhancements:

  • Added a new method, ConfigureSelfHostingTelemetry, which sets up OpenTelemetry tracing with Azure Monitor exporter for self-hosted HTTP scenarios. This is only enabled if the transport is HTTP, telemetry collection is not disabled by environment variable, and the Application Insights connection string is set.
  • Introduced a filtering mechanism in ShouldInstrumentHttpRequest to prevent instrumenting Application Insights ingestion requests and to avoid duplicate spans from Azure SDKs.
  • The tracer provider is now initialized in the main execution path of the server command, ensuring telemetry is active during server operation.

Dependency Updates:

  • Added references to Azure.Monitor.OpenTelemetry.Exporter and OpenTelemetry for telemetry instrumentation and exporting. [1] [2] [3]

Comment thread core/Azure.Mcp.Core/src/Areas/Server/Commands/ServiceStartCommand.cs Outdated
Comment thread core/Azure.Mcp.Core/src/Areas/Server/Commands/ServiceStartCommand.cs Outdated
@github-project-automation github-project-automation Bot moved this from Untriaged to In Progress in Azure MCP Server Nov 20, 2025
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enables HTTP trace telemetry for self-hosted Azure MCP server instances by adding OpenTelemetry support with Azure Monitor integration. The implementation introduces a dedicated telemetry pipeline specifically for HTTP transport mode, along with filtering mechanisms to prevent telemetry loops and duplicate spans.

Key Changes:

  • Added a new telemetry configuration method for self-hosted HTTP scenarios that creates an independent TracerProvider with ASP.NET Core and HttpClient instrumentation
  • Refactored OpenTelemetry exporter configuration from batch processing to immediate configuration per connection string
  • Implemented filtering logic to exclude Application Insights ingestion requests and Azure SDK duplicate spans from instrumentation

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
servers/Azure.Mcp.Server/CHANGELOG.md Documents the new HTTP trace telemetry feature with reference to PR #1227
core/Azure.Mcp.Core/src/Extensions/OpenTelemetryExtensions.cs Refactors Azure Monitor exporter configuration from batch to immediate setup, clarifies conditional compilation for RELEASE builds
core/Azure.Mcp.Core/src/Areas/Server/Commands/ServiceStartCommand.cs Adds TracerProvider initialization for HTTP mode with environment-based controls and implements HTTP request filtering to prevent telemetry issues

@srnagar
Copy link
Copy Markdown
Member Author

srnagar commented Nov 20, 2025

/azp run mcp - pullrequest - live

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@srnagar srnagar enabled auto-merge (squash) November 20, 2025 22:29
@srnagar srnagar merged commit 1dfe5ca into microsoft:main Nov 20, 2025
32 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Azure MCP Server Nov 20, 2025
colbytimm pushed a commit to colbytimm/microsoft-mcp that referenced this pull request Dec 8, 2025
* Enable HTTP traces for self-hosted Azure MCP server

* update changelog

* formatting

* fix doc comment

* scope down the release preprocessor for only microsoft-owned telemetry

* pr comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants