Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Microsoft.Identity.Web;
using Microsoft.IdentityModel.Tokens;
using OpenTelemetry.Logs;
using OpenTelemetry.Metrics;
using OpenTelemetry.Trace;
Expand Down
16 changes: 11 additions & 5 deletions core/Azure.Mcp.Core/src/Extensions/OpenTelemetryExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@

using System.Reflection;
using System.Runtime.InteropServices;
using Azure.Mcp.Core.Areas.Server.Options;
using Azure.Mcp.Core.Configuration;
using Azure.Mcp.Core.Services.Telemetry;
using Azure.Monitor.OpenTelemetry.Exporter;
using Microsoft.Extensions.Azure;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using OpenTelemetry;
using OpenTelemetry.Logs;
using OpenTelemetry.Metrics;
using OpenTelemetry.Resources;
Expand All @@ -25,14 +24,21 @@ public static class OpenTelemetryExtensions
public static void ConfigureOpenTelemetry(this IServiceCollection services)
{
services.AddOptions<AzureMcpServerConfiguration>()
.Configure(options =>
.Configure<IOptions<ServiceStartOptions>>((options, serviceStartOptions) =>
{
options.Version = GetServerVersion(Assembly.GetCallingAssembly());

var collectTelemetry = Environment.GetEnvironmentVariable("AZURE_MCP_COLLECT_TELEMETRY");

options.IsTelemetryEnabled = string.IsNullOrEmpty(collectTelemetry)
|| (bool.TryParse(collectTelemetry, out var shouldCollect) && shouldCollect);
var transport = serviceStartOptions.Value.Transport;

bool isTelemetryEnabledEnvironment = string.IsNullOrEmpty(collectTelemetry) || (bool.TryParse(collectTelemetry, out var shouldCollect) && shouldCollect);

bool isStdioTransport = string.IsNullOrEmpty(transport) || string.Equals(transport, "stdio", StringComparison.OrdinalIgnoreCase);

// if transport is not set (default to stdio) or is set to stdio, enable telemetry
// telemetry is disabled for HTTP transport
options.IsTelemetryEnabled = isTelemetryEnabledEnvironment && isStdioTransport;
});

services.AddSingleton<ITelemetryService, TelemetryService>();
Expand Down
1 change: 1 addition & 0 deletions servers/Azure.Mcp.Server/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ The Azure MCP Server updates automatically by default whenever a new release com
- Updates `AzureMcpServerConfiguration.Version` to use value from `AssemblyInformationalVersionAttribute` rather than file version to support semver conventions such as -beta.1. [[#1040](https://github.com/microsoft/mcp/pull/1040)]
- Added a `CancellationToken` parameter `IBaseCommand.ExecuteAsync()` [[#1056](https://github.com/microsoft/mcp/pull/1056)]
- Added a `CancellationToken` parameter to async methods to many, but not yet all, `I[SomeService]` interfaces [[#1056](https://github.com/microsoft/mcp/pull/1056)]
- Disabled telemetry for HTTP transport [[#1072](https://github.com/microsoft/mcp/pull/1072)]

## 2.0.0-beta.1 (2025-10-29)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"profiles": {
"debug-remotemcp": {
"commandName": "Project",
"commandLineArgs": "server start --run-as-remote-http-service --outgoing-auth-strategy UseHostingEnvironmentIdentity",
"commandLineArgs": "server start --transport http --outgoing-auth-strategy UseHostingEnvironmentIdentity",
"dotnetRunMessages": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
Expand Down
Loading