-
Notifications
You must be signed in to change notification settings - Fork 88
OTel enhancements for deployed server #21
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
Conversation
There was a problem hiding this 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 enhances OpenTelemetry (OTel) configuration for the deployed MCP server by introducing a unified approach to telemetry platform selection and implementing MCP semantic conventions for better observability.
Key Changes:
- Introduces
OPENTELEMETRY_PLATFORMenvironment variable to explicitly choose between AppInsights, Logfire, or no telemetry export - Migrates OpenTelemetry middleware to follow MCP semantic conventions (PR #2083) with standardized span naming and GenAI attributes
- Adds infrastructure support for Logfire token as a secure environment variable
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| servers/opentelemetry_middleware.py | Implements MCP semantic conventions with new span naming pattern "{method} {target}", adds GenAI attributes (gen_ai.tool.name, gen_ai.prompt.name), and includes safe JSON serialization helper |
| servers/deployed_mcp.py | Updates telemetry configuration to use OPENTELEMETRY_PLATFORM env var, changes get_expenses_data from @mcp.resource to @mcp.tool, removes enable_cross_partition_query parameter, and simplifies import |
| servers/auth_mcp.py | Updates to use OPENTELEMETRY_PLATFORM for consistent telemetry configuration and renames csv_content to expense_summary |
| servers/basic_mcp_http.py | Changes logging level from INFO to WARNING and updates transport from "http" to "streamable-http" |
| infra/write_env.sh | Adds LOGFIRE_TOKEN (conditional) and OPENTELEMETRY_PLATFORM to environment file generation |
| infra/write_env.ps1 | PowerShell equivalent of write_env.sh changes for Windows environments |
| infra/server.bicep | Adds openTelemetryPlatform parameter with validation, logfireToken secure parameter, and conditional environment variables/secrets |
| infra/main.parameters.json | Replaces useMonitoring with openTelemetryPlatform parameter and adds logfireToken |
| infra/main.bicep | Replaces useMonitoring boolean with openTelemetryPlatform enum, derives useAppInsights, and propagates new parameters throughout infrastructure |
| agents/langchainv1_github.py | Updates example query to be more specific (requests 5 repositories with bulleted list) |
| agents/agentframework_learn.py | Removes unnecessary Authorization header from MCPStreamableHTTPTool initialization |
| agents/agentframework_http.py | Restructures environment loading to only call load_dotenv when not in production |
| README.md | Adds new sections for using deployed MCP server with GitHub Copilot, running server locally, viewing traces in Application Insights, and viewing traces in Logfire |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
|
|
||
| @mcp.resource("resource://expenses") | ||
| @mcp.tool |
Copilot
AI
Dec 16, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The decorator was changed from @mcp.resource to @mcp.tool for this function in deployed_mcp.py, but remains as @mcp.resource in basic_mcp_http.py. This creates an inconsistency between the two server implementations. Consider whether get_expenses_data should be a resource or a tool, and ensure both files use the same decorator type for consistency.
| @mcp.tool | |
| @mcp.resource |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thats because we're explicitly showing resources in the first session, when we use basic. But my experience with the deployed servers is that resources dont get called often, so I changed them to tools to be more useful.
| expenses_data = [] | ||
|
|
||
| async for item in cosmos_container.query_items(query=query, enable_cross_partition_query=True): | ||
| async for item in cosmos_container.query_items(query=query): |
Copilot
AI
Dec 16, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The removal of 'enable_cross_partition_query=True' may cause the query to fail if the Cosmos DB container is partitioned. Without this parameter, Cosmos DB queries are limited to a single partition. If the container uses a partition key (which is common in production), this query should either specify the partition key or include enable_cross_partition_query=True to query across all partitions.
| async for item in cosmos_container.query_items(query=query): | |
| async for item in cosmos_container.query_items(query=query, enable_cross_partition_query=True): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm I think this comment is based off outdated knowledge. This is what Opus says:
"Looking at the Azure Cosmos DB Python SDK documentation, enable_cross_partition_query is no longer needed in the modern SDK. The parameter was deprecated and is now the default behavior - cross-partition queries are automatically enabled. So you removed it because it's unnecessary with the current version of the azure-cosmos SDK.
The SDK automatically handles cross-partition queries without requiring this flag, making the code cleaner."
I believe I verified this change.
OTel improvements to deployed MCP: