Question: Change namespace of extension methods? #1541
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I'm putting this out here to pose a question regarding the namespaces we've chosen for some of our extension methods. We may very well not want to adopt any of the changes I've made here.
Background
We have many extension methods off of
TracerBuilderProvider
. Extension methods are great, but often can be a little tricky for a newcomer to a library since in some contexts they'll need to make sure they add the appropriateusing
statements.For example, in the context of an ASP.NET Core app one might write the following:
This example code requires the user to know to add both
using OpenTelemetry.Trace
andusing OpenTelemetry.Metrics
to expose the necessary extension methods.Question
Does it make sense to keep extension methods for OpenTelemetry types (i.e.,
TracerProviderBuilder
,MeterProviderBuilder
, etc) in a single namespace likeOpenTelemetry
orOpenTelemetry.Extensions
? Adding a using statement would still be required, but the benefit would be that a single using statement would make all extension methods available.The change here is in the context of the Zipkin and Jaeger exporters, but as shown, this question applies to our extension methods defined in instrumentation projects as well. Also, note that this would be a small breaking change.