-
Notifications
You must be signed in to change notification settings - Fork 809
Remove Meter<T> #4049
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
|
There is Meter<T> as it is currently implemented in dotnet/extensions, and then the less simple explanation that tries to anticipate possible alternate implementations of Meter<T> and what problems arise there. As currently implemented Meter<T> does not populate the new scope parameter of the Meter constructor. This parameter is used to distinguish Meters in different DI containers. For example this pattern we planned to tell users to do would not work: // assume we have some type created in DI with constructor: MyWidget(Meter<MyWidget> meter)
var factory = services.GetRequiredService<IMeterFactory>();
var recorder = new InstrumentRecorder(factory, "MyWidget", "MyCounter");
var widget = services.GetRequiredService<MyWidget>();
// act
widget.DoSomething();
// assert
Assert(1, recorder.GetMeasurements().Count); // this fails because the MyWidget meter isn't associated
// with the factory There has also been some vocal feedback from folks who do not like particular designs, including opposition to Meter<T> on principle. Regardless of anyone's specific position that Meter<T> is a good or bad design choice, discussion on that topic ended when we said we were no longer pursuing it on the public issue. If we reverse our earlier decision, its reasonable that folks who were opposed to it before would expect opportunity for debate would resume. Another issue is that Meter<T> doesn't handle cases where users want to specify any other Meter constructor argument like version or tags. Switching between injecting the factory or the Meter<T> is of course doable, but complicates the guidance and isn't easily discoverable without resorting to docs. And then a bunch of hypotheticals:
Maybe the right clever design can solve all the concerns or we could start suggesting broader changes that replace IMeterFactory with something else but the biggest issue is that we don't have time to play that process out. IMeterFactory, Meter<T> and IMeter<T> were already considered and resolved during a 4 month period of design and feedback. Its certainly unfortunate if the impact of the decisions being made there weren't clear and it feels like something went awry in the review or communication that we need to improve on. However I don't see any path that brings in Meter<T> without effectively resetting the discussion back to where we were in February and starting again. |
@klauco did we agree on removing |
* #4049 Remove generic Meter<T> * first component test migration from Meter<T> * fix source-gen test class * fixes after initial feedback * CR * fix the link * fix version details XML * Update Microsoft.AspNetCore.HeaderParsing.csproj * migrate resource monitoring * fix duplicated file * migrate HealthChecks package * migrate Resilience packages * fixes after merge * Update src/Libraries/Microsoft.Extensions.Diagnostics.Testing/Metrics/MetricCollector.cs * minor updates * Apply suggestions from code review * minor improvements --------- Co-authored-by: Nikita Balabaev <[email protected]>
Done via #4342 |
dotnet/extensions defines a Meter<T> type that doesn't work with the newly introduced MeterFactory and doesn't align with guidance we plan to give users for writing metrics in a DI-aware scenario. We should remove this type.
The text was updated successfully, but these errors were encountered: