-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Summary
Create a bridge to automatically capture telemetry from .NET's DiagnosticSource events. Many .NET libraries (HttpClient, SqlClient, etc.) emit diagnostic events that can be converted to OpenTelemetry spans.
Background
.NET has a built-in DiagnosticSource system that libraries use to emit events:
HttpClientemits request/response eventsSqlClientemits query events- Many other libraries participate
Currently this data is lost unless explicitly subscribed to.
Proposed API
var config = new TelemetryConfiguration
{
// Enable automatic DiagnosticSource bridging
EnableDiagnosticSourceBridge = true,
// Or selectively enable specific sources
DiagnosticSources = new[]
{
"HttpHandlerDiagnosticListener",
"SqlClientDiagnosticListener"
}
};
// Or configure at runtime
VsixTelemetry.SubscribeToDiagnosticSource("MyCustomSource");
VsixTelemetry.SubscribeToDiagnosticSource("HttpHandlerDiagnosticListener",
filter: evt => evt.Name.StartsWith("System.Net.Http"));Events to Bridge
HttpClient
System.Net.Http.HttpRequestOut.Start→ Span startSystem.Net.Http.HttpRequestOut.Stop→ Span end with status- Add: URL, method, status code, duration
SqlClient (if used)
System.Data.SqlClient.WriteCommandBefore→ Span startSystem.Data.SqlClient.WriteCommandAfter→ Span end- Add: Database, command type, (sanitized) query
Implementation Notes
- Use
DiagnosticListener.AllListenersto discover sources - Implement
IObserver<DiagnosticListener>for subscription - Map diagnostic events to OpenTelemetry span operations
- Handle event payload extraction via reflection or known types
- Consider performance impact of reflection
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request