Enable OTLP exporting as part of development build#2006
Enable OTLP exporting as part of development build#2006alzimmermsft wants to merge 3 commits intomicrosoft:mainfrom
Conversation
There was a problem hiding this comment.
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: falsewithAZURE_MCP_COLLECT_TELEMETRY_MICROSOFT: falseto prevent development telemetry from reaching Microsoft instrumentation. - Added
AZURE_MCP_ENABLE_OTLP_EXPORTER: trueto enable OTLP exporting by default for development.
| public static void InitializeConfigurationAndOptions(this IServiceCollection services) | ||
| public static void InitializeConfigurationOptionsAndOpenTelemetry(this IServiceCollection services) | ||
| { | ||
| #if DEBUG |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 | |||
There was a problem hiding this comment.
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.
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
servers/Azure.Mcp.Server/CHANGELOG.mdand/orservers/Fabric.Mcp.Server/CHANGELOG.mdfor product changes (features, bug fixes, UI/UX, updated dependencies)servers/Azure.Mcp.Server/README.mdand/orservers/Fabric.Mcp.Server/README.mddocumentationeng/scripts/Process-PackageReadMe.ps1. See Package README/servers/Azure.Mcp.Server/docs/azmcp-commands.mdand/or/docs/fabric-commands.md.\eng\scripts\Update-AzCommandsMetadata.ps1to update tool metadata in azmcp-commands.md (required for CI)ToolDescriptionEvaluatorand obtained a score of0.4or more and a top 3 ranking for all related test promptsconsolidated-tools.jsonbreaking-changelabel/servers/Azure.Mcp.Server/docs/e2eTestPrompts.mdcrypto mining, spam, data exfiltration, etc.)/azp run mcp - pullrequest - liveto run Live Test Pipeline