Skip to content

Libraries like HttpClient use legacy activity creation, requiring hacks in OpenTelemetry SDK #63868

Closed
@denisivan0v

Description

@denisivan0v

Problem Description

Distributed tracing can be supported by .NET applications by instrumenting them using System.Diagnostics.Activity API. In addition, there are two APIs to be used to produce and consume events generated by instrumented application:

  • System.Diagnostics.DiagnosticSource/System.Diagnostics.DiagnosticListener
  • System.Diagnostics.ActivitySource/System.Diagnostics.ActivityListener

The latter API were introduced recently and reflects OpenTelemetry specifications for tracing. By contrast the former is the legacy .NET-specific API were used to implement instrumentation for distributed tracing initially.

Currently, HttpClient still leverages System.Diagnostics.DiagnosticSource for distributed tracing instrumentation which requires OpenTelemetry SDK to use hacks and reflection. Going forward, this may also make it harder to stay up-to-date with progress done in OpenTelemetry specifications bringing even more complexity to OpenTelemetry SDK. For example, HTTP retries and redirects implementation require SpanLink objects (as per proposal here) that can only be supported by System.Diagnostics.ActivitySource.

Additional Information

Metadata

Metadata

Labels

area-System.Net.HttpenhancementProduct code improvement that does NOT require public API changes/additions

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions