Challenges Integrating MongoDB with Application Insights via OpenTelemetry #46358
Labels
Client
This issue points to a problem in the data-plane of the library.
customer-reported
Issues that are reported by GitHub users external to the Azure organization.
Monitor - Exporter
Monitor OpenTelemetry Exporter
needs-team-attention
Workflow: This issue needs attention from Azure service team or SDK team
question
The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Service Attention
Workflow: This issue is responsible by Azure service team.
Library name
Azure.Monitor.OpenTelemetry.Exporter
Please describe the feature.
Description:
I am facing significant challenges in configuring MongoDB dependency tracking with Application Insights using the OpenTelemetry approach that Microsoft is now recommending. While OpenTelemetry offers a standardized and vendor-agnostic telemetry collection framework, it currently lacks sufficient support for MongoDB or requires overly complex configurations to enable proper monitoring and observability.
I have followed Microsoft's guidelines to move towards OpenTelemetry for telemetry collection instead of the Application Insights SDK, given the clear messaging that this is the future direction for Application Insights integration. However, there are several issues when trying to track MongoDB dependencies and include them in Live Metrics or Application Insights Dependency Tracking.
Steps to Reproduce:
AzureMonitorTraceExporter
andAzureMonitorMetricExporter
to send traces and metrics to Application Insights.DiagnosticsActivityEventSubscriber
to capture MongoDB operations using OpenTelemetry.TelemetryClient.TrackDependency
.Current Workaround:
In order to get MongoDB dependency tracking working, I have reverted to using manual tracking in combination with the Application Insights SDK, specifically using the
TelemetryClient.TrackDependency()
method in each MongoDB operation. This approach is far from ideal:Key Issues:
Lack of MongoDB Automatic Dependency Tracking:
OpenTelemetry doesn't offer native support for tracking MongoDB dependencies in a seamless way when using Azure Monitor or Application Insights. This differs from the Application Insights SDK, which can automatically track SQL Server dependencies without any manual intervention.
Complexity for Non-SQL Databases:
Other non-SQL databases (like Redis, Cassandra, or MySQL) face similar issues where dependency tracking isn't straightforward. This limits the flexibility of using OpenTelemetry in more complex environments where different databases are used.
Manual Instrumentation is Required:
The current solution requires developers to manually track MongoDB dependency calls using
TelemetryClient.TrackDependency()
, which is both labor-intensive and error-prone. It also creates inconsistency in how telemetry is collected between different databases in the same application.Feature Request / Change Proposal:
I would like to request that OpenTelemetry for Azure Monitor includes native support for MongoDB and other NoSQL database dependency tracking, similar to how SQL Server is tracked. Specifically:
Automatic MongoDB Instrumentation:
OpenTelemetry should automatically capture and track MongoDB dependencies, making them appear in Live Metrics and the Application Insights Dependencies section without the need for manual tracking via
TelemetryClient
.Consistency Across Database Types:
OpenTelemetry should offer a consistent way to track all types of databases (both SQL and NoSQL) without requiring different approaches. This would simplify configuration and make telemetry collection more predictable for developers.
Enhanced Documentation:
The current documentation for configuring OpenTelemetry with MongoDB is sparse and lacks clear examples. Providing better documentation and examples on how to achieve dependency tracking for MongoDB (and other databases) would significantly improve the developer experience.
Impact:
This issue impacts developers who are trying to follow Microsoft's recommended path of moving to OpenTelemetry for telemetry collection while using Application Insights. Without proper support for MongoDB or NoSQL databases, it's difficult to create consistent, automated telemetry pipelines across mixed environments, forcing developers to choose between OpenTelemetry's flexibility and the Application Insights SDK's ease of use.
This gap in functionality makes it challenging for those who rely on both SQL and NoSQL databases in the same application, ultimately requiring manual workarounds or dual configurations (OpenTelemetry and Application Insights SDK), leading to added complexity and potential bugs.
Summary:
To streamline the transition to OpenTelemetry and make it a viable alternative to the Application Insights SDK, especially for MongoDB and other NoSQL databases, we request that:
This would help create a consistent and efficient telemetry setup for applications with mixed database environments and make the move to OpenTelemetry more practical and developer-friendly.
The text was updated successfully, but these errors were encountered: