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
475 stars 283 forks source link

Adding gRPC instrumentation but not HttpClient causes issues with parenting #1780

Open alanwest opened 4 years ago

alanwest commented 4 years ago

Both the gRPC .NET and HttpClient libraries generate their own Activity for outgoing calls.

gRPC .NET uses HttpClient behind the scenes, so when you configure OpenTelemetry with both gRPC and HttpClient instrumentation you'll see that the Activity generated by gRPC is the parent of the Activity generated by HttpClient.

However, if you only include gRPC instrumentation or if you only include HttpClient instrumentation the chain of parenting can become broken since the library still generates their respective Activity. Another way this can occur is if you add both gRPC and HttpClient instrumentation, but you configure SuppressDownstreamInstrumentation for the gRPC instrumentation thereby excluding the child HttpClient Activity from the trace.

This issue is somewhat related to open-telemetry/opentelemetry-dotnet-contrib#1779 in that the general issue is that libraries generate Activities regardless of whether OpenTelemetry has been configured to be interested in them. I'm not sure there are good answers here, but it would be nice if there were a way to inform a library of whether or not to generate Activities based on how OpenTelemetry is configured for an app.

cijothomas commented 4 years ago

https://github.com/open-telemetry/opentelemetry-dotnet/pull/1464 This PR should address this, right ? atleast partially?

alanwest commented 4 years ago

open-telemetry/opentelemetry-dotnet#1464 This PR should address this, right ? atleast partially?

Yes, correct parenting will be maintained when using SuppressDownstreamInstrumentation. I think it's ok to declare this "not a bug" and just document this behavior.

martinjt commented 9 months ago

Is this still something we have to do @alanwest ? it's been 3 years and I've not seen any issues with regards to this.

cijothomas commented 3 months ago

Is this still something we have to do @alanwest ? it's been 3 years and I've not seen any issues with regards to this.

Yes. There is no mention of this in the doc.