Skip to content

Enable OTLP exporting as part of development build#2006

Open
alzimmermsft wants to merge 3 commits intomicrosoft:mainfrom
alzimmermsft:EnableOtlpExportOnDebugBuilds
Open

Enable OTLP exporting as part of development build#2006
alzimmermsft wants to merge 3 commits intomicrosoft:mainfrom
alzimmermsft:EnableOtlpExportOnDebugBuilds

Conversation

@alzimmermsft
Copy link
Contributor

@alzimmermsft alzimmermsft commented Mar 10, 2026

What does this PR do?

Enables OTLP exporters by default for development builds to allow for richer debugging without needing to configure the environment. Replaces "AZURE_MCP_COLLECT_TELEMETRY": "false" with "AZURE_MCP_COLLECT_TELEMETRY_MICROSOFT": "false" which controls more specific behaviors, which we want, to allow custom Application Insights to be enabled without additional configuration in development builds.

GitHub issue number?

[Link to the GitHub issue this PR addresses]

Pre-merge Checklist

  • Required for All PRs
    • Read contribution guidelines
    • PR title clearly describes the change
    • Commit history is clean with descriptive messages (cleanup guide)
    • Added comprehensive tests for new/modified functionality
    • Updated servers/Azure.Mcp.Server/CHANGELOG.md and/or servers/Fabric.Mcp.Server/CHANGELOG.md for product changes (features, bug fixes, UI/UX, updated dependencies)
  • For MCP tool changes:
    • One tool per PR: This PR adds or modifies only one MCP tool for faster review cycles
    • Updated servers/Azure.Mcp.Server/README.md and/or servers/Fabric.Mcp.Server/README.md documentation
    • Validate README.md changes using script at eng/scripts/Process-PackageReadMe.ps1. See Package README
    • Updated command list in /servers/Azure.Mcp.Server/docs/azmcp-commands.md and/or /docs/fabric-commands.md
    • Run .\eng\scripts\Update-AzCommandsMetadata.ps1 to update tool metadata in azmcp-commands.md (required for CI)
    • For new or modified tool descriptions, ran ToolDescriptionEvaluator and obtained a score of 0.4 or more and a top 3 ranking for all related test prompts
    • For tools with new names, including new tools or renamed tools, update consolidated-tools.json
    • For renamed tools, follow the Tool Rename Checklist and tag the PR with the breaking-change label
    • For new tools associated with Azure services or publicly available tools/APIs/products, add URL to documentation in the PR description
  • Extra steps for Azure MCP Server tool changes:
    • Updated test prompts in /servers/Azure.Mcp.Server/docs/e2eTestPrompts.md
    • 👉 For Community (non-Microsoft team member) PRs:
      • Security review: Reviewed code for security vulnerabilities, malicious code, or suspicious activities before running tests (crypto mining, spam, data exfiltration, etc.)
      • Manual tests run: added comment /azp run mcp - pullrequest - live to run Live Test Pipeline

Copy link
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 updates appsettings.Development.json for the Azure MCP Server to enable OTLP telemetry exporters by default for development builds, aiming to provide richer debugging without requiring manual environment setup. It also replaces the old AZURE_MCP_COLLECT_TELEMETRY key with the more specific AZURE_MCP_COLLECT_TELEMETRY_MICROSOFT key to prevent development data from polluting Microsoft's production telemetry.

Changes:

  • Replaced AZURE_MCP_COLLECT_TELEMETRY: false with AZURE_MCP_COLLECT_TELEMETRY_MICROSOFT: false to prevent development telemetry from reaching Microsoft instrumentation.
  • Added AZURE_MCP_ENABLE_OTLP_EXPORTER: true to enable OTLP exporting by default for development.

@alzimmermsft alzimmermsft added this to the 2026-03 milestone Mar 10, 2026
@alzimmermsft alzimmermsft moved this from Untriaged to In Progress in Azure MCP Server Mar 10, 2026
public static void InitializeConfigurationAndOptions(this IServiceCollection services)
public static void InitializeConfigurationOptionsAndOpenTelemetry(this IServiceCollection services)
{
#if DEBUG
Copy link
Member

@conniey conniey Mar 11, 2026

Choose a reason for hiding this comment

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

The reason for having DOTNET_ENVIRONMENT is so we don't have to recompile to make test changes. We can rerun the application with different settings. We shouldn't have to if/def things based on the build type.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was finding the DOTNET_ENVIRONMENT was blank when running debug builds, so we fell back to Production. If you know of a better way to fallback to Development when running a debug build do let me know.

/// </summary>
/// <param name="services">Service Collection to add configuration logic to.</param>
public static void InitializeConfigurationAndOptions(this IServiceCollection services)
public static void InitializeConfigurationOptionsAndOpenTelemetry(this IServiceCollection services)
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason we have to configure open telemetry in this method as well? This method now has multiple responsibilities rather than just setting options.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I couldn't find a cleaner way to get the IConfiguration singleton bound here when we called OpenTelemetryExtensions.ConfigureOpenTelemetry. If you know of a way to cleanly pull that out of the IServiceCollection I'd be more than happy to revert this change as I'm not a huge fan of it either.

@@ -92,7 +93,7 @@ private static void EnableAzureMonitor(this IServiceCollection services)
#if RELEASE
Copy link
Member

@conniey conniey Mar 11, 2026

Choose a reason for hiding this comment

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

Frankly, I think we could have avoided this by using default appsettings.json = false and used the running environment to set it or not. Because now if we want to test this in a debug environment, it's impossible.

@anuchandy anuchandy modified the milestones: 2026-03, 2026-04 Mar 17, 2026
@anuchandy anuchandy added the Do Not Merge Do Not Merge / WIP PRs label Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Do Not Merge Do Not Merge / WIP PRs

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

5 participants