Azure / azure-sdk-for-net

This repository is for active development of the Azure SDK for .NET. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/dotnet/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-net.
MIT License
5.49k stars 4.82k forks source link

[BUG] Duplication between Azure.Core.Http spans and HTTP client ones #37446

Open lmolkova opened 1 year ago

lmolkova commented 1 year ago

Library name and version

Azure.Core

Describe the bug

When OTel is configured to collect HTTP spans and Azure SDK spans, we report 2 spans for each HTTP call.

Azure SDK spans are 'better' because:

So, we need to find a way to suppress native HTTP client spans.

The problem is not unique to Azure SDK, but there is no otel-wide story for it (https://github.com/open-telemetry/opentelemetry-specification/issues/1767) and each language has its own way to suppress duplicates.

Here's the issue tracking it on OTel .NET side https://github.com/open-telemetry/opentelemetry-dotnet/issues/4641

Expected behavior

Only one span is created per HTTP call

Actual behavior

two spans are created per http call

Reproduction Steps

https://devblogs.microsoft.com/azure-sdk/introducing-experimental-opentelemetry-support-in-the-azure-sdk-for-net/ with latest otel

Environment

No response

lmolkova commented 1 year ago

A temporary alternative to https://github.com/open-telemetry/opentelemetry-dotnet/issues/4641 could be using reflection to access OpenTelemetry.SuppressInstrumentationScope helper.

This would increase the number of AOT warnings, but none of the tracing things work with AOT anyway.

lmolkova commented 1 year ago

related: #35572, #29955