Closed yhsparrow closed 3 days ago
This is best reported in vendor (in this case Application Insights/Azure) repo.
I added MongoDB diagnostics via DiagnosticsActivityEventSubscriber to capture MongoDB operations using OpenTelemetry.
Not sure what is this, but if you share details (in a new issue), this may be something OpenTelemetry can help.
The MongoDB Driver for .NET does not instrument dependencies via DiagnosticSource
or ActivitySource
. You can check https://github.com/jbogard/MongoDB.Driver.Core.Extensions.DiagnosticSources as a workaround (until native instrumentation is added to the driver). This package publishes activities using an ActivitySource
and you can just subscribe to them with TracerProviderBuilder.AddSource
.
Package
OpenTelemetry
Is your feature request related to a problem?
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.
What is the expected behavior?
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.
Which alternative solutions or features have you considered?
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:Additional context
No response