open-telemetry / opentelemetry-dotnet-contrib

This repository contains set of components extending functionality of the OpenTelemetry .NET SDK. Instrumentation libraries, exporters, and other components can find their home here.
https://opentelemetry.io
Apache License 2.0
447 stars 273 forks source link

Attributes during Sampling for HttpClient and ASP.NET Core spans #2012

Open vishweshbankwar opened 1 year ago

vishweshbankwar commented 1 year ago

Feature Request

Spec requires client and server spans to provide certain attributes(for client and for server) during sampling so that the information can be used to make sampling decisions. In .NET this is currently not possible to do at the instrumentation library level, as the spans are created by the HttpClient and ASP.NET Core libraries itself. To support this requirement, the change need to be done on the libraries side.

Opening this issue for reference.

martinjt commented 1 year ago

I've created a request here for this.

https://github.com/dotnet/aspnetcore/issues/50488

cijothomas commented 1 year ago

Need to create issue for HttpClient as well. IIRC, one of the reason why this was not done was because ActivityTagsCollection is heap allocated and hence we avoided its usage until after sampling decision is made. It might be possible to leverage TagList for this purpose, with some support from Activity class itself in runtime.

We do this in SqlClient without alloc (because it was feasible). See https://github.com/open-telemetry/opentelemetry-dotnet/issues/1971#issuecomment-816877268 too

martinjt commented 1 year ago

the idea I had was to make it more of an extension, in the case that .NET didn't want to add the extra bits then it can become something that OpenTelemetry does.

Providing that extension point would be useful I think.