Compono.Metrics.MeterFactoryTestingExtensions
Compono.Metrics¶
Compono.Metrics¶
MeterFactoryTestingExtensions Class¶
Direct inspection and fluent verification over any System.Diagnostics.Metrics.IMeterFactory - no assertion framework required. Every method here requires the System.Diagnostics.Metrics.IMeterFactory it's called on to actually be a CapturingMeterFactory (produced by UseMetrics(this CompositionBuilder), or directly via CapturingMeterFactory's public constructor) - calling any of these against a substitute, a Compono.TestDoubles-generated double, DefaultMeterFactory, or any other non-Compono System.Diagnostics.Metrics.IMeterFactory throws immediately, diagnostically, rather than returning an empty/default result. See docs/adr/0072-compono-metrics-testing-support-package.md's "Precedence and misuse" section.
Inheritance System.Object → MeterFactoryTestingExtensions
| Methods | |
|---|---|
| ClearMeasurements(this IMeterFactory) | Discards every measurement captured by factory so far. Works before and after disposal. |
| GetMeasurements<T>(this IMeterFactory, string) | Every measurement captured for instruments named instrumentName, across every meter, merged in capture order (ADR-0072 selection rule 7). A new list is returned on each call; later captures, ClearMeasurements(this IMeterFactory), and Dispose() never change a list already returned. |
| GetMeasurements<T>(this IMeterFactory, string, string) | Every measurement captured for instruments named instrumentName in the meter named meterName, merged in capture order. A new list is returned on each call. |
| RecordObservableInstruments(this IMeterFactory) | Polls this factory's observable instruments: calls this factory's listener's System.Diagnostics.Metrics.MeterListener.RecordObservableInstruments. Callbacks run synchronously on the calling thread and only for this factory's observable instruments; each observation appends measurements, so calling it twice records twice. Reads never poll. A no-op before the first Create(MeterOptions) or after disposal. |
| Verify<T>(this IMeterFactory, string) | The entry point for fluent verification, for example meters.Verify<long>("shop.orders.placed").WithTag("region", "eu").Once(). The selection is resolved here, when the builder is created, so a meter ambiguity, type conflict, or type mismatch throws before any filter is added. |
| Verify<T>(this IMeterFactory, string, string) | The entry point for fluent verification scoped to one meter name. The selection is resolved here, when the builder is created. |