diff --git a/.github/scripts/generate-api-reference.sh b/.github/scripts/generate-api-reference.sh
index d0b035b6..111a3a6f 100755
--- a/.github/scripts/generate-api-reference.sh
+++ b/.github/scripts/generate-api-reference.sh
@@ -24,7 +24,7 @@ cd "$repo_root"
# it doesn't recognize as a BCL type and links to a learn.microsoft.com URL
# that 404s for a Compono type - caught during the Phase 1 tool bake-off.
core_pkg=Compono
-integration_pkgs=(Compono.XunitV3 Compono.XunitV3.Aot Compono.NSubstitute Compono.Bogus Compono.TUnit Compono.TestDoubles Compono.DependencyInjection Compono.Http Compono.Logging Compono.MSTest Compono.NUnit)
+integration_pkgs=(Compono.XunitV3 Compono.XunitV3.Aot Compono.NSubstitute Compono.Bogus Compono.TUnit Compono.TestDoubles Compono.DependencyInjection Compono.Http Compono.Logging Compono.Metrics Compono.MSTest Compono.NUnit)
links_dir=$(mktemp -d)
trap 'rm -rf "$links_dir"' EXIT
diff --git a/.github/scripts/inspect-packed-nupkgs.sh b/.github/scripts/inspect-packed-nupkgs.sh
index cc3a7a1d..a4eeebef 100755
--- a/.github/scripts/inspect-packed-nupkgs.sh
+++ b/.github/scripts/inspect-packed-nupkgs.sh
@@ -245,7 +245,7 @@ main() {
}
local pkg nupkg extract_dir extra_paths nuspec
- for pkg in Compono Compono.XunitV3 Compono.XunitV3.Aot Compono.NSubstitute Compono.Bogus Compono.TUnit Compono.TestDoubles Compono.DependencyInjection Compono.Http Compono.Logging Compono.MSTest Compono.NUnit Compono.Options; do
+ for pkg in Compono Compono.XunitV3 Compono.XunitV3.Aot Compono.NSubstitute Compono.Bogus Compono.TUnit Compono.TestDoubles Compono.DependencyInjection Compono.Http Compono.Logging Compono.Metrics Compono.MSTest Compono.NUnit Compono.Options; do
nupkg=$(find "$pack_output" -maxdepth 1 -iname "${pkg}.[0-9]*.nupkg" | head -1)
if [ -z "$nupkg" ]; then
echo "FAIL: no .nupkg found for $pkg in $pack_output" >&2
@@ -342,6 +342,13 @@ main() {
assert_exact_pin_dependency "$nuspec" "$pkg" "Compono"
assert_dependency_range_per_tfm "$nuspec" "$pkg" "Microsoft.Extensions.Logging.Abstractions" "$packages_props"
;;
+ Compono.Metrics)
+ assert_manifest_field "$nuspec" "$pkg" "title" "Compono — System.Diagnostics.Metrics Testing Support"
+ assert_exact_pin_dependency "$nuspec" "$pkg" "Compono"
+ # No third-party or package dependency of its own: CapturingMeterFactory rides the
+ # in-box System.Diagnostics.Metrics shared-framework types on every target TFM - nothing
+ # else to range-assert here (ADR-0072 "Package identity and dependency graph").
+ ;;
Compono.MSTest)
assert_manifest_field "$nuspec" "$pkg" "title" "Compono — MSTest Integration"
assert_exact_pin_dependency "$nuspec" "$pkg" "Compono"
diff --git a/.github/workflows/aot-validation.yaml b/.github/workflows/aot-validation.yaml
index 080e7331..956df5cd 100644
--- a/.github/workflows/aot-validation.yaml
+++ b/.github/workflows/aot-validation.yaml
@@ -1,14 +1,14 @@
name: AOT Validation
-# ADR-0041 Amendment 7: permanent, CI-blocking Native AOT smoke gate for the nine existing
+# ADR-0041 Amendment 7: permanent, CI-blocking Native AOT smoke gate for the ten existing
# test/*.AotSmokeTest projects, replacing the previous manual-only "run it by hand before release"
-# verification.
+# verification. (Compono.Metrics joined the matrix via ADR-0072/PLAN-0074's own B4 phase.)
#
# Deliberately NO `paths:` filter on this workflow's own `pull_request` trigger. A workflow entirely
# skipped by trigger-level path filtering leaves its required status check `Pending` rather than
# reporting success, under GitHub's required-check semantics - that would block a PR indefinitely
# instead of passing it on an AOT-irrelevant change. Selectivity happens *inside* the workflow
-# instead: the `changes` job below computes which of the nine legs are actually applicable from the
+# instead: the `changes` job below computes which of the ten legs are actually applicable from the
# PR's changed files (a small repository-owned `git diff` script, not a third-party changed-files
# action), each leg's own publish-and-run job runs behind an `if:` reading that output (an
# inapplicable leg reports an ordinary skipped conclusion, never a missing status), and `aot-gate` -
@@ -16,22 +16,22 @@ name: AOT Validation
# (`if: always()`) and always resolves to success or failure, so the required check never sits
# Pending.
#
-# The exact guarantee the nine aot-smoke legs prove: the packaged Compono package's exercised public
+# The exact guarantee the ten aot-smoke legs prove: the packaged Compono package's exercised public
# API surface is callable from a Native-AOT-published, trimmed consumer application without runtime
# AOT/trimming failures. This is deliberately narrower than "the package's public API surface": it
# covers core `Compono` itself, not only integration packages, and it makes no claim of exhaustive
# coverage of every public member - each leg is a throwaway console app calling a specific, real
-# entry point of the packaged API directly. Those nine legs make NO claim that xUnit v3, TUnit,
+# entry point of the packaged API directly. Those ten legs make NO claim that xUnit v3, TUnit,
# MSTest, or NUnit's own test runners are Native-AOT compatible - no leg ever publishes a test
# framework's runner/host as Native AOT.
#
-# The tenth leg, aot-xunitv3-aot-pipeline (ADR-0066/PLAN-0066), is the one exception to that last
+# The eleventh leg, aot-xunitv3-aot-pipeline (ADR-0066/PLAN-0066), is the one exception to that last
# sentence: it publishes a real Compono.XunitV3.Aot-consuming xUnit v3 test project - real
# [Theory]+[Compose], real Compono.Generators-emitted RegisteredEngineConfig.RegisterTheoryDataRowFactory
# registration, real xunit.v3.aot.mtp-v2 - and proves xUnit v3's own AOT discovery/execution pipeline
# actually discovers and runs a Compono-composed test under Native AOT. This claim is scoped to
# xUnit v3 (Phase 1's plain [Compose] only) specifically - it says nothing about TUnit/MSTest/NUnit's
-# own runners, which remain covered only by the nine aot-smoke legs' narrower guarantee above.
+# own runners, which remain covered only by the ten aot-smoke legs' narrower guarantee above.
#
# This repository does not use GitHub merge queues today - no `merge_group` trigger is added
# speculatively; add one later only if that changes.
@@ -65,13 +65,13 @@ jobs:
echo "Changed files:"
echo "$changed"
- all_legs='["Compono","Compono.Http","Compono.Logging","Compono.MSTest","Compono.NUnit","Compono.Options","Compono.TestDoubles","Compono.TUnit","Compono.XunitV3"]'
+ all_legs='["Compono","Compono.Http","Compono.Logging","Compono.Metrics","Compono.MSTest","Compono.NUnit","Compono.Options","Compono.TestDoubles","Compono.TUnit","Compono.XunitV3"]'
# A change to shared/core/generator infrastructure (or to this workflow itself) can affect
- # every packaged leg at once - run all nine rather than reflexively narrowing to only the
+ # every packaged leg at once - run all ten rather than reflexively narrowing to only the
# paths that happened to change (ADR-0041 Amendment 7's own "do not run it reflexively, but
# do not under-run it either" balance).
- # ADR-0066/PLAN-0066: the tenth leg (Compono.XunitV3.Aot's own real-generator, real-xUnit-AOT-
+ # ADR-0066/PLAN-0066: the eleventh leg (Compono.XunitV3.Aot's own real-generator, real-xUnit-AOT-
# pipeline proof) shares this same core/generator/shared-config trigger, plus its own
# dedicated paths, computed separately below since it runs as its own job
# (aot-xunitv3-aot-pipeline), not part of the aot-smoke matrix - it needs a materially
@@ -89,7 +89,7 @@ jobs:
fi
if [ "$core_or_shared_change" = "true" ]; then
- echo "Core/generator/shared-config change detected - running all nine AotSmokeTest legs."
+ echo "Core/generator/shared-config change detected - running all ten AotSmokeTest legs."
echo "legs=$all_legs" >> "$GITHUB_OUTPUT"
exit 0
fi
@@ -101,6 +101,7 @@ jobs:
echo "$changed" | grep -q '^src/Compono\.Http/' && add_leg "Compono.Http"
echo "$changed" | grep -q '^src/Compono\.Logging/' && add_leg "Compono.Logging"
+ echo "$changed" | grep -q '^src/Compono\.Metrics/' && add_leg "Compono.Metrics"
echo "$changed" | grep -q '^src/Compono\.MSTest/' && add_leg "Compono.MSTest"
echo "$changed" | grep -q '^src/Compono\.NUnit/' && add_leg "Compono.NUnit"
echo "$changed" | grep -q '^src/Compono\.Options/' && add_leg "Compono.Options"
@@ -110,7 +111,7 @@ jobs:
echo "$changed" | grep -q '^src/Shared/Compono\.XunitV3/' && add_leg "Compono.XunitV3"
# A change scoped to one leg's own AotSmokeTest project only needs that leg re-run, not all
- # nine - extract which leg(s) directly from the changed paths.
+ # ten - extract which leg(s) directly from the changed paths.
for proj in $(echo "$changed" | grep -oE '^test/[^/]+\.AotSmokeTest/' | sed -E 's#^test/(.+)\.AotSmokeTest/#\1#' | sort -u); do
add_leg "$proj"
done
@@ -161,15 +162,19 @@ jobs:
if: matrix.leg == 'Compono.Logging'
run: bash test/Compono.Logging.AotSmokeTest/verify-packaging.sh
+ - name: Additional packaging verification (Compono.Metrics)
+ if: matrix.leg == 'Compono.Metrics'
+ run: bash test/Compono.Metrics.AotSmokeTest/verify-packaging.sh
+
- name: Additional analyzer-contract verification (Compono.Http)
if: matrix.leg == 'Compono.Http'
run: bash test/Compono.Http.AotSmokeTest/AnalyzerContract/verify-analyzer-contract.sh
- # ADR-0066/PLAN-0066's tenth leg - critically different from the aot-smoke matrix above: this
+ # ADR-0066/PLAN-0066's eleventh leg - critically different from the aot-smoke matrix above: this
# publishes a REAL Compono.XunitV3.Aot-consuming xUnit v3 test project (real [Theory]+[Compose],
# real Compono.Generators-emitted RegisteredEngineConfig.RegisterTheoryDataRowFactory registration,
# real xunit.v3.aot.mtp-v2), not a hand-dispatch console app - it proves xUnit's own AOT
- # discovery/execution pipeline actually runs a Compono-composed test, which none of the nine
+ # discovery/execution pipeline actually runs a Compono-composed test, which none of the ten
# aot-smoke legs attempt (ADR-0041 Amendment 7's own stated scope boundary).
aot-xunitv3-aot-pipeline:
needs: changes
@@ -247,8 +252,8 @@ jobs:
exit 1
fi
- # Same fail-closed shape for the tenth leg (ADR-0066/PLAN-0066), gated on its own
- # xunitv3_aot_applicable output rather than the nine-leg legs array.
+ # Same fail-closed shape for the eleventh leg (ADR-0066/PLAN-0066), gated on its own
+ # xunitv3_aot_applicable output rather than the ten-leg legs array.
if [ "$xunitv3_aot_result" = "failure" ] || [ "$xunitv3_aot_result" = "cancelled" ]; then
echo "::error::The Compono.XunitV3.Aot real-pipeline leg failed or was cancelled - see the aot-xunitv3-aot-pipeline job above." >&2
exit 1
diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml
index 3a7298c6..2feaa977 100644
--- a/.github/workflows/docs.yml
+++ b/.github/workflows/docs.yml
@@ -26,6 +26,7 @@ on:
- 'src/Compono.DependencyInjection/**'
- 'src/Compono.Http/**'
- 'src/Compono.Logging/**'
+ - 'src/Compono.Metrics/**'
- 'src/Compono.MSTest/**'
- 'src/Compono.NUnit/**'
- 'Directory.Build.props'
@@ -52,6 +53,7 @@ on:
- 'src/Compono.DependencyInjection/**'
- 'src/Compono.Http/**'
- 'src/Compono.Logging/**'
+ - 'src/Compono.Metrics/**'
- 'src/Compono.MSTest/**'
- 'src/Compono.NUnit/**'
- 'Directory.Build.props'
@@ -97,7 +99,7 @@ jobs:
- name: Build publishable packages (net10.0)
run: |
set -euo pipefail
- for pkg in Compono Compono.XunitV3 Compono.XunitV3.Aot Compono.NSubstitute Compono.Bogus Compono.TUnit Compono.TestDoubles Compono.DependencyInjection Compono.Http Compono.Logging Compono.MSTest Compono.NUnit; do
+ for pkg in Compono Compono.XunitV3 Compono.XunitV3.Aot Compono.NSubstitute Compono.Bogus Compono.TUnit Compono.TestDoubles Compono.DependencyInjection Compono.Http Compono.Logging Compono.Metrics Compono.MSTest Compono.NUnit; do
dotnet build "src/${pkg}/${pkg}.csproj" -c Release -f net10.0
done
diff --git a/.github/workflows/package-validation.yaml b/.github/workflows/package-validation.yaml
index 3c8fff34..f088bc6e 100644
--- a/.github/workflows/package-validation.yaml
+++ b/.github/workflows/package-validation.yaml
@@ -32,12 +32,12 @@ jobs:
PACK_OUTPUT: ${{ github.workspace }}/artifacts/package-validation
# Single authoritative publishable-package list (PLAN-0061 Phase 1) - the baseline-lookup and
# pack steps below both derive from this one job-level env var instead of each repeating the
- # same 11-package literal, so adding/removing a package can't drift across the two
+ # same 14-package literal, so adding/removing a package can't drift across the two
# independently. A job-level `env:` entry is injected into every step's own
# process environment by GitHub Actions itself, so this survives across the separate `run:`
# steps below (each its own shell process) with no extra plumbing - deliberately not a Bash
# array, which would only live for the one step that declared it.
- PACKAGES: "Compono Compono.XunitV3 Compono.XunitV3.Aot Compono.NSubstitute Compono.Bogus Compono.TUnit Compono.TestDoubles Compono.DependencyInjection Compono.Http Compono.Logging Compono.MSTest Compono.NUnit Compono.Options"
+ PACKAGES: "Compono Compono.XunitV3 Compono.XunitV3.Aot Compono.NSubstitute Compono.Bogus Compono.TUnit Compono.TestDoubles Compono.DependencyInjection Compono.Http Compono.Logging Compono.Metrics Compono.MSTest Compono.NUnit Compono.Options"
steps:
- uses: actions/checkout@v7
diff --git a/.gitignore b/.gitignore
index d1f24c9f..0207b397 100644
--- a/.gitignore
+++ b/.gitignore
@@ -481,6 +481,10 @@ FodyWeavers.xsd
# 10's Native AOT publish-and-run proof) - regenerated by that script, never committed.
.local-nuget-feed-nunit-aot-smoke/
+# Local NuGet feed populated by Compono.Metrics.AotSmokeTest's pack-compono.sh (ADR-0072 / PLAN-0074
+# B4's Native AOT publish-and-run proof) - regenerated by that script, never committed.
+.local-nuget-feed-metrics-aot-smoke/
+
# Raw per-run outputs from skills/compono-workspace/ eval iterations - transient, regenerated by
# each run. grading.json/timing.json/benchmark.json/feedback.json ARE committed (this repo's own
# established evaluation-evidence convention, see skills/compono-workspace/benchmarks/), only the
diff --git a/Compono.slnx b/Compono.slnx
index 5aba1923..574e73fc 100644
--- a/Compono.slnx
+++ b/Compono.slnx
@@ -11,6 +11,7 @@
+
@@ -27,6 +28,7 @@
+
diff --git a/Directory.Packages.props b/Directory.Packages.props
index be46b98e..7033fdb8 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -193,6 +193,13 @@
+
+
diff --git a/README.md b/README.md
index 090afba9..30ffc60a 100644
--- a/README.md
+++ b/README.md
@@ -48,6 +48,7 @@ Compono determines **how** those requirements are satisfied.
| `Compono.MSTest` | MSTest integration | [](https://www.nuget.org/packages/Compono.MSTest) | [](https://www.nuget.org/packages/Compono.MSTest) |
| `Compono.NUnit` | NUnit integration (no `[TestFixture]` required) | [](https://www.nuget.org/packages/Compono.NUnit) | [](https://www.nuget.org/packages/Compono.NUnit) |
| `Compono.Options` | `Microsoft.Extensions.Options` testing support (`TestOptionsSource`, `UseOptions()`) | [](https://www.nuget.org/packages/Compono.Options) | [](https://www.nuget.org/packages/Compono.Options) |
+| `Compono.Metrics` | `System.Diagnostics.Metrics` testing support (`UseMetrics()`, `CapturingMeterFactory`, `Verify()`) | [](https://www.nuget.org/packages/Compono.Metrics) | [](https://www.nuget.org/packages/Compono.Metrics) |
## Example
diff --git a/docs/adr/0072-compono-metrics-testing-support-package.md b/docs/adr/0072-compono-metrics-testing-support-package.md
new file mode 100644
index 00000000..5a37aad0
--- /dev/null
+++ b/docs/adr/0072-compono-metrics-testing-support-package.md
@@ -0,0 +1,724 @@
+# [ADR-0072] `Compono.Metrics`: `System.Diagnostics.Metrics` Testing Support
+
+**Status:** Accepted
+
+**Date:** 2026-11-11
+
+**Decision Makers:** product owner (maintainer interview, 2026-11-11), assisted by Claude Opus 5.5
+
+## Context
+
+Issue [#165](https://github.com/LayeredCraft/compono/issues/165) (child of
+[#161](https://github.com/LayeredCraft/compono/issues/161), item 2): a SUT
+takes `IMeterFactory` and records counter, histogram, and gauge
+measurements. Tests need to compose that SUT and assert the measurements'
+values, instrument names, and tags. Today Compono has no metrics support.
+Consumers hand-write an `IMeterFactory` and wire one
+`MetricCollector` (`Microsoft.Extensions.Diagnostics.Testing`) per
+instrument.
+
+[RESEARCH-0039](../research/0039-issue-165-metrics-testing-admission.md)
+ran capability admission. Gates A and B are met, and the product owner
+chose a new package over a documentation-only recipe. It also records the
+empirical BCL facts this ADR relies on (spike on SDK 11.0.100, `net8.0`
+and `net11.0`). In short:
+
+- Everything needed is in-box on every target TFM. No `PackageReference`.
+- A per-factory `MeterListener` that enables only instruments whose
+ `Meter.Scope` is that factory isolates same-named meters across factories,
+ and its `RecordObservableInstruments()` polls only that factory's
+ observable instruments.
+- `Gauge` exists on `net9.0+` only, but a generic measurement callback
+ receives it without naming the type.
+- `services.AddMetrics()` registers its factory with `TryAdd`.
+- `DefaultMeterFactory` caches meters, doesn't mutate the caller's
+ options, rejects a foreign scope, and throws `ObjectDisposedException`
+ after disposal.
+
+## Decision Drivers
+
+- Real consumer scenario (#161 migration, `dynamodb-distributed-lock`)
+ with the smallest maintainable public surface.
+- No new dependency. No reflection, no generator work, Native AOT and
+ trimming compatible (`IsAotCompatible=true`).
+- Deterministic results: parallel tests never see each other's
+ measurements, and reads have no side effects.
+- Compono's non-owning composition model (ADR-0022 Amendment 4,
+ RESEARCH-0015). No ownership ADR is required.
+- No static or ambient capture state.
+- Consistency with `Compono.Logging` (ADR-0055) where it fits: composed
+ double is the handle, `[Shared]` reaches it, extension methods throw a
+ diagnostic on a non-Compono instance, verification forwards to core
+ `CallVerifier`. Different where metrics differ: values are typed and
+ value-centric, and observable instruments need an explicit poll.
+- Low allocation on the measurement callback path.
+
+## Considered Options
+
+**Axis 1, home:** (1) new `Compono.Metrics` package; (2) documentation-only
+recipe (hand-written factory + `MetricCollector`); (3) fold into an
+existing package (`Compono.Logging`).
+
+**Axis 2, handle:** (1) the composed `IMeterFactory` is the handle
+(`[Shared] IMeterFactory`, extension methods); (2) a test-owned collector
+passed to `UseMetrics(collector)` (ADR-0071 `LogCollector` style); (3) both.
+
+**Axis 3, listener ownership:** (1) one lazily created listener per
+factory, disposed with the factory; (2) one shared static listener that
+routes by `Meter.Scope`, plus a transient listener for observable polls;
+(3) block on a Compono disposal-ownership ADR.
+
+**Axis 4, value typing:** (1) typed (`CapturedMeasurement`); (2)
+untyped (`object Value`); (3) normalized to `double`.
+
+**Axis 5, observable instruments:** (1) explicit
+`RecordObservableInstruments()`; (2) poll automatically on every read;
+(3) explicit plus an opt-in auto-poll option.
+
+**Axis 6, verification:** (1) snapshot reads plus a filter-then-count
+`Verify` builder forwarding to `CallVerifier`; (2) option 1 plus
+aggregate helpers (`Sum`, `LastValue`); (3) snapshot reads only.
+
+**Axis 7, host/DI path:** (1) documentation recipe only; (2) an
+`AddComponoMetrics()` `IServiceCollection` extension; (3) defer.
+
+## Decision Outcome
+
+Chosen per axis, all confirmed in the maintainer interview (2026-11-11):
+Axis 1 option 1, Axis 2 option 1, Axis 3 option 1, Axis 4 option 1,
+Axis 5 option 1, Axis 6 option 1, Axis 7 option 1. Supporting decisions
+from the same interview: an unknown instrument name yields no
+measurements (it doesn't throw); tag matching is subset + `object.Equals`;
+no timestamp; no wait API; `Meter` constructor parameters are not
+composed; stage-6 precedence follows registration order.
+
+Settled in the product-owner review (2026-11-11): `CapturedMeasurement`
+is a plain `readonly struct` (not a record struct, so `==` never suggests
+value equality over `Tags`); meter and instrument names match ordinal,
+case-sensitive; the type names below are accepted as proposed; the
+package ships in the #161 release (v1.4.0); disposal, type conflicts,
+snapshot lifetime, capture order, and the Native AOT validation matrix are
+specified explicitly below.
+
+Accepted in the product-owner final review (2026-11-11), which confirmed:
+unsupported measurement types are rejected with `ArgumentException`; the
+same-named, conflicting-type instrument limitation is accepted for v1 with
+no version or tag selectors; disposal stays explicit and test-owned, with
+no ownership or disposal API; `InvalidOperationException` is used for
+ambiguity, type conflicts, and misuse, with no custom exception hierarchy;
+and the Native AOT validation matrix stands as documented.
+
+### Package identity and dependency graph
+
+```
+Compono.Metrics
+ -> Compono (CompositionBuilder.AddTestDoubleProvider, ICompositionValueProvider, CallVerifier)
+ (System.Diagnostics.Metrics: in-box shared framework on net8.0/net9.0/net10.0/net11.0)
+```
+
+- TFMs: `net8.0;net9.0;net10.0;net11.0`, matching the other packages.
+- No `PackageReference`. Explicitly not added:
+ `System.Diagnostics.DiagnosticSource` (package),
+ `Microsoft.Extensions.Diagnostics`,
+ `Microsoft.Extensions.Diagnostics.Testing`,
+ `Microsoft.Extensions.DependencyInjection.Abstractions`. Test projects
+ may reference `Microsoft.Extensions.Hosting`/`Microsoft.Extensions.Diagnostics`
+ as test-only dependencies to prove the host recipe.
+- No dependency on `Compono.Logging`, `Compono.TestDoubles`, or
+ `Compono.NSubstitute`. No generator or MSBuild props of its own.
+ `IMeterFactory` is non-generic, so the provider handles it directly.
+
+### Public API
+
+```csharp
+namespace Compono.Metrics;
+
+public static class CompositionBuilderExtensions
+{
+ // Stage-6 provider: composes IMeterFactory as a new CapturingMeterFactory per request.
+ public static CompositionBuilder UseMetrics(this CompositionBuilder builder);
+}
+
+// Test IMeterFactory. Publicly constructible (CapturingLogger precedent); UseMetrics() uses the same constructor.
+public sealed class CapturingMeterFactory : IMeterFactory
+{
+ public CapturingMeterFactory();
+ public Meter Create(MeterOptions options);
+ public void Dispose();
+}
+
+// Plain readonly struct (not a record struct): no synthesized value equality.
+public readonly struct CapturedMeasurement where T : struct
+{
+ public T Value { get; }
+ public IReadOnlyList> Tags { get; } // per-measurement copy; empty, never null
+ public Instrument Instrument { get; } // the real instrument (and through it, its Meter); see "Snapshot lifetime"
+}
+
+public static class MeterFactoryTestingExtensions
+{
+ public static IReadOnlyList> GetMeasurements(
+ this IMeterFactory factory, string instrumentName) where T : struct;
+ public static IReadOnlyList> GetMeasurements(
+ this IMeterFactory factory, string meterName, string instrumentName) where T : struct;
+
+ public static MeasurementVerificationBuilder Verify(
+ this IMeterFactory factory, string instrumentName) where T : struct;
+ public static MeasurementVerificationBuilder Verify(
+ this IMeterFactory factory, string meterName, string instrumentName) where T : struct;
+
+ public static void RecordObservableInstruments(this IMeterFactory factory);
+ public static void ClearMeasurements(this IMeterFactory factory);
+}
+
+public sealed class MeasurementVerificationBuilder where T : struct
+{
+ public MeasurementVerificationBuilder WithValue(T value);
+ public MeasurementVerificationBuilder WithTag(string key, object? value);
+ public MeasurementVerificationBuilder WithoutTag(string key);
+ public MeasurementVerificationBuilder Matching(Func, bool> predicate);
+
+ // One-line forwarders to core CallVerifier over the filtered measurement count.
+ public void Once();
+ public void Never();
+ public void Exactly(int times);
+ public void AtLeast(int times);
+ public void AtMost(int times);
+}
+```
+
+Consumer shapes:
+
+```csharp
+// Composed (any test framework). [Shared] makes the SUT and the test see the same factory.
+[Theory, Compose]
+public void PlacingAnOrderCountsIt([Shared] IMeterFactory meters, OrderService sut)
+{
+ using var _ = meters; // the test owns disposal; see "Disposal patterns"
+
+ sut.PlaceOrder(new Order("eu", 3));
+
+ meters.Verify("shop.orders.placed").WithTag("region", "eu").WithValue(1).Once();
+ meters.Verify("shop.orders.duration").Once(); // histogram: one recording
+
+ var placed = meters.GetMeasurements("Shop.Orders", "shop.orders.placed");
+ Assert.Equal(1, placed.Sum(m => m.Value)); // value math via LINQ
+}
+
+public sealed class MetricsProfile : ICompositionProfile
+{
+ public void Configure(CompositionBuilder builder) => builder.UseMetrics();
+}
+
+// Observable instruments: poll explicitly, then read.
+meters.RecordObservableInstruments();
+meters.Verify("shop.queue.depth").WithValue(7).Once();
+
+// Direct construction, no composition.
+using var meters = new CapturingMeterFactory();
+var sut = new OrderService(meters);
+
+// Generic Host / DI (documentation recipe, consumer's own DI API; not Compono surface).
+using var meters = new CapturingMeterFactory();
+builder.Services.AddSingleton(meters); // AddMetrics() uses TryAdd, so this wins
+```
+
+### Factory semantics (`CapturingMeterFactory`)
+
+Parity with `DefaultMeterFactory` (RESEARCH-0039 §5 facts 9-10):
+
+- `Create(null)` throws `ArgumentNullException`. `Create` with a non-null
+ `options.Scope` that isn't this factory throws
+ `InvalidOperationException`. `Create` after `Dispose()` throws
+ `ObjectDisposedException`.
+- The caller's `MeterOptions` is never mutated. The meter is constructed
+ from a copy whose `Scope` is this factory.
+- Meters are cached: the same name, version, and tag set (order-insensitive,
+ `object.Equals` on values) returns the same `Meter`. Anything else
+ creates a new one.
+- Thread-safe.
+
+### Capture semantics
+
+- **Listener:** each factory owns one `MeterListener`, created on its first
+ `Create` and started before the meter is returned. Its
+ `InstrumentPublished` enables an instrument only when
+ `ReferenceEquals(instrument.Meter.Scope, this)`. Callbacks are registered
+ for the seven numeric types the BCL supports (`byte`, `short`, `int`,
+ `long`, `float`, `double`, `decimal`). The per-instrument state passed to
+ `EnableMeasurementEvents` is a typed buffer, so measurements are never
+ boxed. A factory that never creates a meter never creates a listener.
+- **What's captured:** every measurement of every enabled instrument kind:
+ `Counter`, `UpDownCounter`, `Histogram`, `Gauge` (`net9.0+`,
+ no TFM split in the capture code), and observable instruments when
+ polled. Raw measurements only. Compono doesn't aggregate, doesn't
+ interpret kind (no delta-vs-last-value semantics), and doesn't read
+ histogram bucket advice.
+- **Tags:** the measurement's tags are copied into an array in callback
+ order (`Array.Empty` when there are none). Meter-level and
+ instrument-level tags are not merged in. They're reachable through
+ `CapturedMeasurement.Instrument`.
+- **No timestamp.** Order is capture order (see "Capture order").
+- **Isolation:** two factories never see each other's measurements, even
+ for identical meter and instrument names. There's no static or shared
+ capture state.
+
+### Selection and matching
+
+`GetMeasurements` and `Verify` resolve their selection with the
+same algorithm, in this order. The first rule that applies decides the
+outcome. `Verify` resolves it when the builder is created, so a
+conflict throws before any filter is added.
+
+1. **Arguments.** Null or empty `instrumentName`/`meterName` throws
+ `ArgumentException`. A `T` that isn't one of the seven BCL measurement
+ types (`byte`, `short`, `int`, `long`, `float`, `double`, `decimal`)
+ throws `ArgumentException`, whether or not any instrument exists. The
+ message names the requested type and lists the seven supported types.
+ No instrument can ever record such a `T`, so this catches the mistake
+ deterministically.
+2. **Candidates.** Every instrument this factory has published whose
+ `Name` equals `instrumentName` and, with the two-argument overload,
+ whose `Meter.Name` equals `meterName`. Both comparisons are ordinal and
+ case-sensitive. The candidate set includes instruments of **every**
+ value type, not just `T`. Instruments are never pre-filtered by `T`, so
+ an instrument with an unexpected type can't be silently ignored.
+3. **Unknown name.** No candidates yields an empty result.
+ `Verify(...).Never()` passes. A failing `Once()`/`Exactly(n)`/
+ `AtLeast(n)` message lists the instruments that do exist (meter name,
+ instrument name, value type), so a typo is visible.
+4. **Meter ambiguity** (one-argument overload only). Candidates from meters
+ with different `Meter.Name` values throw `InvalidOperationException`.
+ The message lists each candidate (meter name and version, instrument
+ name, value type) and points at the two-argument overload.
+5. **Type conflict.** Candidates that record more than one value type
+ throw `InvalidOperationException`, **even when one of the types is
+ `T`**. The message lists each candidate with its meter name and version
+ and its value type, and says that one selection can't merge
+ measurements of different types. This can happen inside one meter
+ (`CreateCounter("x")` and `CreateCounter("x")` are distinct
+ instruments) or across same-named meters with different versions or
+ tags. A consumer resolves it by renaming an instrument in the SUT, or
+ by narrowing with the two-argument overload when the conflicting
+ instruments live in differently named meters. The package doesn't
+ offer version- or tag-level meter selection (non-goal; use
+ `Matching(m => m.Instrument.Meter.Version == "2")` after the types
+ agree).
+6. **Type mismatch.** Candidates that all record one value type other than
+ `T` throw `InvalidOperationException` naming that type, for example
+ `instrument "shop.orders.placed" records int, not long`.
+7. **Merge.** Otherwise every candidate records `T`. Their measurements are
+ merged in capture order. This covers same-named meters with a
+ different version or tags, and repeated instances of one instrument
+ name (RESEARCH-0039 fact 10).
+
+These exceptions are `InvalidOperationException`/`ArgumentException`
+with descriptive messages, matching `Compono.Logging`'s misuse diagnostics.
+No new public exception type is added.
+- **`WithValue(value)`:** `EqualityComparer.Default`. Floating-point
+ equality is exact; use `Matching(...)` for tolerance.
+- **`WithTag(key, value)`:** the measurement contains a tag with that key
+ (ordinal) whose value satisfies `object.Equals(tagValue, value)`. Other
+ tags are ignored. No numeric coercion: `200` (`int`) doesn't match `200L`.
+ The failure message shows each tag's actual runtime type. Chain calls for
+ several tags.
+- **`WithoutTag(key)`:** the measurement has no tag with that key.
+- **Exact tag-set** and other matches: `Matching(...)`.
+- Failure-message fragments follow `LogVerificationBuilder`'s style, for
+ example `instrument "shop.orders.placed" (long) with tag region = "eu"
+ (string) and value 1: expected exactly 1 measurement(s), observed 0`.
+
+### Observable instruments
+
+- `RecordObservableInstruments()` calls this factory's listener's
+ `RecordObservableInstruments()`. Callbacks run synchronously on the
+ calling thread and only for this factory's observable instruments. Each
+ observation appends measurements. Calling it twice records twice.
+- Reads (`GetMeasurements`, `Verify`) never poll and have no side effects.
+- If a callback throws, the BCL behavior stands: the other callbacks still
+ run, then `AggregateException` propagates to the test. Compono doesn't
+ catch it.
+- Before the first `Create`, or after disposal, it's a no-op.
+
+### Asynchronous measurements
+
+Measurements recorded on other threads (background work, hosted services)
+are captured thread-safely as they arrive. Reads are point-in-time
+snapshots. Compono provides no wait or timeout API. The test awaits its
+own completion signal before asserting. `WaitForMeasurementsAsync` is
+deferred, not rejected. It's additive if evidence asks for it.
+
+### Lifecycle and ownership
+
+- Composition stays non-owning. `UseMetrics()` composes a new factory per
+ request. `[Shared] IMeterFactory` gives the SUT and the test the same one,
+ exactly like `[Shared] ILogger`.
+- `IMeterFactory` already extends `IDisposable`. `Dispose()` disposes every
+ meter the factory created (raising `MeasurementsCompleted`), then the
+ listener. It's idempotent and thread-safe. A measurement racing with
+ disposal may be captured or dropped, but never throws or corrupts state.
+- After disposal, captured measurements stay readable, `ClearMeasurements`
+ works, `RecordObservableInstruments` is a no-op, and measurements on the
+ disposed meters' instruments aren't captured.
+- Disposal is the test's responsibility. Consequence of skipping it: an
+ undisposed factory that created meters stays referenced by the BCL's
+ static meter list for the process lifetime (RESEARCH-0039 fact 8). Its
+ meters, listener, and captured measurements are kept with it, and the
+ listener stays registered. This is the same cost as an undisposed
+ `DefaultMeterFactory`. A factory that never created a meter costs
+ nothing.
+
+#### Disposal patterns
+
+No new ownership API is added. Compono composition never disposes the
+factory (ADR-0022 Amendment 4). Whether a test framework disposes
+`IDisposable` method arguments is framework-specific, and Compono doesn't
+rely on it either way. `Dispose()` is idempotent, so a framework that
+also disposes the argument is harmless. The documented patterns:
+
+1. **`[Compose]`-family tests (every framework adapter): dispose the
+ `[Shared]` parameter in the test body.**
+
+ ```csharp
+ [Theory, Compose]
+ public void PlacingAnOrderCountsIt([Shared] IMeterFactory meters, OrderService sut)
+ {
+ using var _ = meters;
+ sut.PlaceOrder(new Order("eu", 3));
+ meters.Verify("shop.orders.placed").Once();
+ }
+ ```
+
+ `[Shared]` guarantees the parameter is the same instance the SUT holds,
+ so disposing it disposes everything the SUT created through it. The
+ `using` declaration runs when the method exits, including when an
+ assertion throws. Assertions can go anywhere in the body because
+ captured data stays readable after disposal. In an `async` test,
+ `using var` works the same way and runs after the last `await`.
+ `IMeterFactory` isn't `IAsyncDisposable`, so `await using` doesn't
+ apply. The parameter must be `[Shared]`: without it, the test's factory
+ is a different instance from the SUT's, and the SUT's factory isn't
+ reachable to dispose (or to assert against).
+2. **`Composer.Create` tests: construct the factory, then register it.**
+
+ ```csharp
+ using var meters = new CapturingMeterFactory();
+ var composer = Composer.Create(b => b.Register(() => meters));
+ var sut = composer.Create();
+ ```
+
+ An exact registration takes precedence over `UseMetrics()`, so
+ `UseMetrics()` isn't needed here. The test creates the instance, so it
+ owns it.
+3. **Generic Host / DI:** the same, with
+ `services.AddSingleton(meters)`. An instance
+ registration isn't disposed by the container, so the test's `using`
+ owns it. Dispose the factory after the host has stopped. Disposal stops
+ capture, so measurements recorded during host shutdown are only
+ captured while the factory is alive.
+
+Dispose after the SUT's work is done. Measurements recorded after disposal
+aren't captured, so disposing while background work is still running can
+drop measurements.
+
+#### Snapshot lifetime
+
+- `GetMeasurements` returns a new list each call. Later captures,
+ `ClearMeasurements()`, and `Dispose()` never change a list already
+ returned.
+- Each `Tags` list is a per-measurement copy taken in the callback. It
+ doesn't alias the BCL's tag span or any other measurement's tags.
+- `CapturedMeasurement.Instrument` is the actual `Instrument` object the
+ SUT created. Through `Instrument.Meter` it references the actual
+ `Meter`, and through `Meter.Scope` the factory. A retained snapshot
+ therefore keeps the instrument, its meter, and the factory (and that
+ factory's captured measurements) reachable for as long as the test holds
+ it. That's ordinary object reachability and ends when the snapshot is
+ dropped. It isn't a registration and causes no capture.
+- Snapshots stay valid after the factory is disposed. `Value`, `Tags`, and
+ `Instrument`'s descriptive members (`Name`, `Unit`, `Description`,
+ `IsObservable`, `Meter.Name`, `Meter.Version`, `Meter.Tags`) remain
+ readable. A disposed meter's instruments report `Enabled == false`, and
+ recording through them is a no-op. Reading a snapshot never throws
+ because of disposal.
+
+### Precedence and misuse
+
+- `UseMetrics()` registers a stage-6 provider that handles exactly
+ `typeof(IMeterFactory)` and returns `NotHandled` for everything else.
+ Precedence against `UseNSubstitute()`/`UseGeneratedTestDoubles()`
+ follows the existing first-registered-wins rule (ADR-0024). Register
+ `UseMetrics()` first. No generator exclusion is added.
+- Every `MeterFactoryTestingExtensions` method throws
+ `InvalidOperationException` when the `IMeterFactory` isn't a
+ `CapturingMeterFactory`. The message names `UseMetrics()`, the
+ registration-order requirement, and the host recipe. It's detected by a
+ type check, not reflection.
+- `Meter` constructor parameters are not composed by this package.
+ Consumers register them from the shared factory in a profile
+ (documented recipe).
+
+### Concurrency and allocation
+
+- One private lock per factory guards appends, clears, and reads. The tag
+ copy happens before the lock is taken. Reads return snapshot copies.
+
+#### Capture order
+
+- **Definition:** capture order is the order in which measurements are
+ successfully inserted into the factory's synchronized capture buffer.
+- Each measurement gets a factory-wide sequence number, assigned **inside
+ the same lock acquisition that appends it**. Merged selections
+ (selection rule 7) and every snapshot are ordered by that sequence
+ number.
+- Measurements recorded sequentially on one thread are captured in that
+ thread's program order, because each append completes before the next
+ recording starts. One `RecordObservableInstruments()` call appends in
+ the order the BCL invokes the callbacks and their observations.
+- **No chronological ordering is claimed across concurrent producers.**
+ Two threads recording at about the same time may be captured in either
+ order, and capture order can differ from the order the `Add`/`Record`
+ calls began. Tests that need a cross-thread order must establish it
+ themselves.
+- `ClearMeasurements()` doesn't reset the sequence. Order is only
+ meaningful within one factory.
+- Per measurement: one tag array (none when the measurement has no tags)
+ and an amortized list append. No boxing of values, no LINQ, no closure
+ allocation in callbacks.
+
+### Native AOT and trimming
+
+No reflection, no `MakeGenericType`, no dynamic code, no generated
+activation. The seven typed callbacks are ordinary generic instantiations
+over value types that the compiler sees statically. `IsAotCompatible=true`.
+
+Validation matrix. Only what CI actually runs is claimed:
+
+| Coverage | net8.0 | net9.0 | net10.0 | net11.0 |
+|---|---|---|---|---|
+| Library build with trim/AOT analyzers (`IsAotCompatible`), warnings as errors | CI | CI | CI | CI |
+| `Compono.Metrics.Tests` (JIT) | CI | CI | CI | CI |
+| Native AOT publish + run of `Compono.Metrics.AotSmokeTest` (linux-x64) | not covered | not covered | CI | not covered |
+
+The AOT row matches the existing `aot-validation.yaml` smoke matrix: every
+`*.AotSmokeTest` targets `net10.0` and publishes for `linux-x64`. This ADR
+doesn't extend that. On net8.0, net9.0, and net11.0, AOT compatibility is
+supported by the analyzers alone, not by a runtime run. An optional manual
+publish on other TFMs (as ADR-0071 Amendment 2 did) may be recorded in the
+plan as evidence, but it isn't a CI guarantee. The smoke test must
+publish with zero IL2xxx/IL3xxx warnings and exit successfully.
+
+### Explicit non-goals
+
+- A metrics framework, aggregation engine, exporter, or OpenTelemetry
+ integration.
+- Tracing (`ActivitySource`) testing.
+- Composing `Meter` parameters, or a configurable meter name.
+- An `IServiceCollection`/host extension (documentation recipe instead).
+- Timestamps, `TimeProvider`, and wait/timeout APIs.
+- Aggregate helpers (`Sum`, `LastValue`) and numeric tag coercion.
+- Automatic disposal by composition.
+- Replacing `Microsoft.Extensions.Diagnostics.Testing` for consumers who
+ prefer it. They can keep using it.
+
+### Positive Consequences
+
+- `IMeterFactory` SUTs compose with one `UseMetrics()` call. One handle
+ covers every instrument, isolated per factory.
+- No dependencies at all. Combined with ADR-0071, the #161 suite no longer
+ needs `Microsoft.Extensions.Diagnostics.Testing`.
+- Deterministic observable collection and side-effect-free reads.
+- The same verification idiom as `Compono.Logging`/`Compono.TestDoubles`.
+
+### Negative Consequences
+
+- An undisposed factory with meters leaks for the process lifetime, and
+ disposal is one manual line per test (`using var _ = meters;`).
+ Mitigation: the three documented disposal patterns, `using` in every
+ example, the sample, and the skill reference. The leak is identical to
+ an undisposed `DefaultMeterFactory`.
+- Same-named instruments with different value types in same-named meters
+ (for example, `Shop` v1 and v2) can't be read at all. Selection rule 5
+ throws, and there's no version- or tag-level meter selector. Mitigation:
+ the conflict message names every instrument. The scenario is unusual,
+ and a selector is additive later if evidence asks for one.
+- Typed reads require the test to know `T`. Mitigation: mismatches throw a
+ message naming the real type.
+- No wait API, so tests asserting on background work must synchronize
+ themselves. Mitigation: documented, additive later.
+- Wrong registration order against `UseNSubstitute()` produces a
+ substitute. Mitigation: the misuse exception names the cause.
+
+## Pros and Cons of the Options
+
+### Axis 1 (home)
+
+- **New package (chosen).** Good: `Compono.Http` precedent for a
+ zero-dependency BCL seam, and a clear package guide and skill route.
+ Bad: one more package to validate, document, and release.
+- **Documentation recipe.** Good: no surface. Bad: keeps the heavy
+ dependency set and per-instrument collectors, and every consumer
+ re-derives isolation.
+- **Fold into `Compono.Logging`.** Good: no new package. Bad: wrong
+ ecosystem name, and forces `Logging.Abstractions` on metrics users.
+
+### Axis 2 (handle)
+
+- **Composed factory (chosen).** Good: works from `[Compose]` attributes
+ and profiles with no test-body object, and matches ADR-0055. Bad: needs
+ `[Shared]`, like logging.
+- **Test-owned collector.** Good: matches ADR-0071. Bad: awkward where no
+ test-body object exists, and adds a second type for no evidenced need.
+- **Both.** Bad: more surface with no evidence.
+
+### Axis 3 (listener)
+
+- **Per-factory, lazy (chosen).** Good: no static state, observable polls
+ are naturally scoped, unused factories cost nothing. Bad: one listener
+ per active factory. Each costs a callback on every instrument publish in
+ the process.
+- **Shared static router.** Good: one listener total. Bad: static state,
+ and a shared `RecordObservableInstruments()` would run every test's
+ callbacks, so it needs a second transient-listener mechanism. It doesn't
+ fix the meter leak either (fact 8).
+- **Ownership ADR.** Bad: large, out of scope for #165 per RESEARCH-0015.
+
+### Axis 4 (typing)
+
+- **Typed (chosen).** Good: no boxing, compile-time value type, matches
+ `MetricCollector`. Bad: the test names `T`.
+- **Untyped.** Bad: boxes every measurement, and moves `int`-vs-`long`
+ `Equals` pitfalls into tests.
+- **Double.** Bad: loses `decimal` precision and `long` exactness above 2^53.
+
+### Axis 5 (observables)
+
+- **Explicit (chosen).** Good: reads have no side effects, BCL name, and
+ deterministic. Bad: one extra call.
+- **Auto on read.** Bad: two reads record two observations, and SUT
+ callbacks run inside assertions.
+- **Opt-in auto.** Bad: option surface without evidence.
+
+### Axis 6 (verification)
+
+- **Snapshot + filter `Verify` (chosen).** Good: diagnostic failure
+ messages, same shape as `LogVerificationBuilder`, value math stays in
+ LINQ. Bad: count-centric `Verify` doesn't express sums directly.
+- **Aggregate helpers.** Bad: generic math over seven types, and
+ kind-dependent meaning (a sum of gauge values is meaningless).
+- **Snapshot only.** Bad: loses Compono's diagnostic messages and idiom
+ consistency.
+
+### Axis 7 (host)
+
+- **Recipe (chosen).** Good: one line of the consumer's own DI API, and no
+ dependency added. Bad: no IntelliSense-discoverable Compono call.
+- **`AddComponoMetrics()`.** Bad: adds `DependencyInjection.Abstractions`
+ to a zero-dependency package for a one-liner.
+- **Defer.** Bad: host tests are a likely next question.
+
+## Links
+
+- Issue [#165](https://github.com/LayeredCraft/compono/issues/165); parent
+ [#161](https://github.com/LayeredCraft/compono/issues/161)
+- [RESEARCH-0039](../research/0039-issue-165-metrics-testing-admission.md),
+ [RESEARCH-0036](../research/0036-issue-161-test-composition-gaps-intake.md),
+ [RESEARCH-0015](../research/0015-disposal-ownership-research.md),
+ [RESEARCH-0033](../research/0033-compono-logging-tests-concurrency-hang-investigation.md)
+- [ADR-0055](0055-compono-logging-testing-support-package.md),
+ [ADR-0071](0071-compono-logging-host-wide-log-capture.md),
+ [ADR-0051](0051-compono-http-handler-based-testing-package.md),
+ [ADR-0024](0024-public-provider-extensibility-model.md),
+ [ADR-0022](0022-compono-xunit-package-design.md) Amendment 4
+- [PLAN-0074](../plans/0074-compono-metrics-testing-support-impl-plan.md)
+
+## Amendment (2026-11-11): instrument capture classifies by base type, so `Gauge` is captured on every TFM whose runtime provides it
+
+Implementation review caught that the "Capture semantics" section's
+enumerated instrument-kind list (`Counter`, `UpDownCounter`,
+`Histogram`, `Gauge`, and the observable kinds) was implemented with a
+`Gauge`-recognizing branch gated behind `#if NET9_0_OR_GREATER`. That
+compiles the branch out for a `net8.0`-targeted assembly, so a `net8.0`
+consumer whose runtime provides `DiagnosticSource` 9.x (where `Gauge`
+exists) would have had its gauge instruments silently ignored — no buffer,
+no capture, no diagnostic.
+
+The capture code now classifies an instrument by its BCL base type instead
+of by naming each concrete kind: an instrument is captured when it is an
+`Instrument` or an `ObservableInstrument`. Every supported synchronous
+kind (`Counter`, `UpDownCounter`, `Histogram`, `Gauge`) derives
+from `Instrument`, and every observable kind (`ObservableCounter`,
+`ObservableUpDownCounter`, `ObservableGauge`) derives from
+`ObservableInstrument`, so the set of captured kinds is unchanged; the
+difference is that a kind the runtime introduces later is captured without a
+compile-time branch. This is TFM-independent, needs no `PackageReference`,
+and still boxes nothing. The original "what's captured" list is otherwise
+unchanged. A `net8.0` test (compiled against `DiagnosticSource` 9.x,
+test-only) records and verifies `Gauge` as a regression guard.
+
+## Amendment 2 (2026-11-11): meter-tag identity is a one-to-one (bag) match, so duplicate keys are significant
+
+The "Factory semantics" section says the same name, version, and tag set
+(order-insensitive, `object.Equals` on values) returns the same `Meter`. The
+first implementation compared tag sets with "every left entry matches some
+right entry", which treats `[k=1, k=1]` and `[k=1, j=2]` as equal (both
+left entries find the `k=1` on the right).
+
+Each entry on one side must now consume exactly one distinct entry on the
+other side (a `bool[] matched` bag match), preserving order-insensitivity
+while making duplicate keys significant: `[k=1, k=1]` equals `[k=1, k=1]`,
+but not `[k=1, j=2]`, and `[k=1, k=1]` does not equal `[k=1]`. The common
+case (no meter tags) still allocates nothing.
+
+This is intentionally **stricter** than `DefaultMeterFactory`: its
+duplicate-tag comparison is not a true multiset comparison, so
+Compono.Metrics does not claim tag-set parity with it here. A duplicate
+meter-tag key is significant — two sets with the same keys but different
+duplicate multiplicities are never treated as the same meter — which is the
+predictable, documented behavior this framework wants.
+
+## Amendment 3 (2026-11-11): a test `IMeterFactory` wins host DI by being the *last* registration, not the first
+
+The "Disposal patterns" section's Generic Host example registered the test
+factory with a comment claiming `AddMetrics()` uses `TryAdd`, "so this
+wins". That inference is wrong for `Host.CreateApplicationBuilder()`, which
+already registers a default `IMeterFactory` as part of its built-in service
+setup. `IServiceProvider` resolves a **single** service to its **last**
+registration, so the test factory wins because it is registered *after* the
+builder is created — not because it is registered first. `TryAdd`/
+`TryAddSingleton` would in fact keep the existing (default) registration and
+discard the test factory.
+
+The documented recipe is therefore: `Host.CreateApplicationBuilder()`, then
+`builder.Services.AddSingleton(meters)`; never
+`TryAddSingleton` to replace a factory. Diagnostic and prose wording across
+the package guide, host recipe, troubleshooting page, and the
+`RequireCapturing` misuse message were corrected to this rule. No public
+API changed.
+
+## Amendment 4 (2026-11-11): tag-value diagnostics describe the *expected* filter value, including its runtime type
+
+The "Selection and matching" section's `WithTag` bullet said the failure
+message "shows each tag's actual runtime type". The implementation annotated
+the *expected* value's compile-time type (for example `region = "eu"
+(string)`), which is not the measurement's actual runtime tag type and read
+as if it were. That annotation was removed.
+
+A later review restored a type annotation but made the wording unambiguous:
+the message describes the **expected** value the test passed to `WithTag`,
+never the captured measurement's tag. A string stays quoted without an
+annotation (`region = "eu"` — the quotes already convey the type), `null`
+renders as `null`, and every other value shows its runtime type, for example
+`status = 200 (int)`. Because the type comes from the argument the test
+supplied, the message can never claim a type the measurement does not have.
+
+Failure messages also: join the filter descriptions with `with` (first) and
+`and` (subsequent); format numeric values with the invariant culture; forward
+the count to core `CallVerifier`'s `Expected exactly N call(s) to ...,
+but received M.` wording; and, when an unknown instrument name matched
+nothing, append a separate sentence naming the missing instrument and
+listing the instruments the factory did publish (after the count sentence,
+where it reads naturally). Example:
+`Expected exactly 1 call(s) to instrument "shop.orders.placed" (long) with
+tag region = "eu" and value 1, but received 0.` No public API changed, and
+core `CallVerifier` is untouched.
diff --git a/docs/adr/README.md b/docs/adr/README.md
index 209a19e8..d4563dbd 100644
--- a/docs/adr/README.md
+++ b/docs/adr/README.md
@@ -130,3 +130,4 @@ the mechanics: numbering, status, and the index.
| [0069](0069-xunitv3-require-fixture-accessor.md) | xUnit v3 Fixture Accessor for Composition Profiles (`RequireFixture()`) | Accepted |
| [0070](0070-xunitv3-composedata-composed-theory-rows.md) | xUnit v3 Composed Theory Rows (`[ComposeData]`) | Accepted |
| [0071](0071-compono-logging-host-wide-log-capture.md) | `Compono.Logging`: Host-Wide Log Capture (`LogCollector` + `AddComponoCapture`) | Accepted |
+| [0072](0072-compono-metrics-testing-support-package.md) | `Compono.Metrics`: `System.Diagnostics.Metrics` Testing Support | Accepted |
diff --git a/docs/architecture/current/provider-pipeline.md b/docs/architecture/current/provider-pipeline.md
index 4bd53281..035bdee0 100644
--- a/docs/architecture/current/provider-pipeline.md
+++ b/docs/architecture/current/provider-pipeline.md
@@ -17,7 +17,7 @@ providers reordering themselves:
| 3 | Exact registrations | **Hybrid**: a context-owned deterministic lookup against the exact-registration table, then — only on a miss, if `UseServiceProvider(...)` was configured — a fallback `IServiceProvider.GetService(typeof(T))` call. |
| 4 | Configuration rules | Ordered `ICompositionProvider` collection populated by type/member value rules compiled from `builder.For()...`, whether reached directly or via a profile. |
| 5 | Semantic value providers | Ordered `ICompositionProvider` collection. Public registration surface: `builder.AddSemanticProvider(ICompositionValueProvider)`. `Compono.Bogus`'s `BogusMemberNameProvider` is this stage's first real registrant. |
-| 6 | Test-double providers | Ordered `ICompositionProvider` collection. Public registration surface: `builder.AddTestDoubleProvider(ICompositionValueProvider)`. `Compono.NSubstitute`'s `NSubstituteProvider`, `Compono.TestDoubles`'s `GeneratedTestDoubleProvider`, and `Compono.Logging`'s `LoggingProvider` are real registrants — registration order between them decides which one resolves an interface request first when more than one is installed, same as any other stage. For `ILogger`/`ILogger` specifically, [ADR-0055](../../adr/0055-compono-logging-testing-support-package.md) Amendment 4 makes `GeneratedTestDoubleProvider` unable to handle those types at all once `ComponoGeneratedLogging` is enabled (they're Logging-owned, excluded from `Compono.TestDoubles` generation) — so order against `UseGeneratedTestDoubles()` isn't observable for them. Register `UseLogging()` before `UseNSubstitute()` when `ILogger`/`ILogger` should resolve to a `CapturingLogger`/`CapturingLogger` rather than a substitute — `NSubstituteProvider` is unaffected by Amendment 4 and still resolves them if registered first. |
+| 6 | Test-double providers | Ordered `ICompositionProvider` collection. Public registration surface: `builder.AddTestDoubleProvider(ICompositionValueProvider)`. `Compono.NSubstitute`'s `NSubstituteProvider`, `Compono.TestDoubles`'s `GeneratedTestDoubleProvider`, `Compono.Logging`'s `LoggingProvider`, and `Compono.Metrics`'s `MetricsProvider` are real registrants — registration order between them decides which one resolves an interface request first when more than one is installed, same as any other stage. For `ILogger`/`ILogger` specifically, [ADR-0055](../../adr/0055-compono-logging-testing-support-package.md) Amendment 4 makes `GeneratedTestDoubleProvider` unable to handle those types at all once `ComponoGeneratedLogging` is enabled (they're Logging-owned, excluded from `Compono.TestDoubles` generation) — so order against `UseGeneratedTestDoubles()` isn't observable for them. Register `UseLogging()` before `UseNSubstitute()` when `ILogger`/`ILogger` should resolve to a `CapturingLogger`/`CapturingLogger` rather than a substitute — `NSubstituteProvider` is unaffected by Amendment 4 and still resolves them if registered first. For `IMeterFactory`, register `UseMetrics()` before `UseNSubstitute()` so the request resolves to a `CapturingMeterFactory`; `NSubstituteProvider` resolves `IMeterFactory` (a non-generic interface) to a substitute if registered first — see [ADR-0072](../../adr/0072-compono-metrics-testing-support-package.md). |
| 7 | Built-in value providers | **Hybrid**: an ordered provider collection (primitives, enums, nullable value types) tried first, followed by a context-owned deterministic dispatch through `CollectionPlanCache` for the five built-in collection shapes. |
| 8 | Generated composition plans | Context-owned deterministic dispatch via `PlanCache` — **not** an `ICompositionProvider`; see [Generated Plans and Discovery](generated-plans-and-discovery.md). |
| 9 | Diagnostic failure | Context-owned terminal stage |
@@ -25,7 +25,7 @@ providers reordering themselves:
Only stage 7 has anything registered *unconditionally*
(`BuiltInProviders.Default`); every other stage is opt-in, populated only
when a consumer actually calls `.For()` (stage 4), `UseNSubstitute()`/
-`UseGeneratedTestDoubles()` (stage 6), `UseBogus()` (stage 5), or registers
+`UseGeneratedTestDoubles()`/`UseMetrics()` (stage 6), `UseBogus()` (stage 5), or registers
a hand-written provider directly. Provider order *within* an extensible stage is registration
order — stage 7 alone holds three real providers
(`PrimitiveValueProvider`, `EnumValueProvider`, `NullableValueProvider`),
diff --git a/docs/getting-started/installation.md b/docs/getting-started/installation.md
index cc27d868..844c6663 100644
--- a/docs/getting-started/installation.md
+++ b/docs/getting-started/installation.md
@@ -50,6 +50,7 @@ dotnet add package Compono.NSubstitute # automatic substitute compositio
dotnet add package Compono.Bogus # semantic fake data (names, emails, ...)
dotnet add package Compono.DependencyInjection # row.AsServiceProvider() bridge
dotnet add package Compono.Http # TestHttpHandler for HttpClient tests
+dotnet add package Compono.Metrics # System.Diagnostics.Metrics testing support
```
Every package targets `net8.0`/`net9.0`/`net10.0`/`net11.0` and has a
diff --git a/docs/how-to/verify-metrics-across-a-host.md b/docs/how-to/verify-metrics-across-a-host.md
new file mode 100644
index 00000000..ee0c51f5
--- /dev/null
+++ b/docs/how-to/verify-metrics-across-a-host.md
@@ -0,0 +1,108 @@
+# How Do I Verify Metrics Recorded by a Service in a Generic Host?
+
+Create the `CapturingMeterFactory`, register it as the host's
+`IMeterFactory` singleton, run the host, then verify that factory. The
+factory is the test-owned capture destination: it sees every measurement
+recorded through the `IMeterFactory` its services resolve. See
+[`Compono.Metrics`'s Package Guide](../packages/compono-metrics.md) for the
+full capture, selection, and disposal semantics.
+
+## Basic case
+
+```csharp
+using Compono.Metrics;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Hosting;
+using System.Diagnostics.Metrics;
+
+[Fact]
+public async Task Checkout_RecordsAnOrder()
+{
+ using var meters = new CapturingMeterFactory();
+
+ var builder = Host.CreateApplicationBuilder();
+ builder.Services.AddSingleton(meters); // last IMeterFactory registration wins
+ builder.Services.AddSingleton();
+ using var host = builder.Build();
+
+ await host.StartAsync(TestContext.Current.CancellationToken);
+
+ var service = host.Services.GetRequiredService();
+ service.PlaceOrder(new Order("eu", 3));
+
+ await host.StopAsync(TestContext.Current.CancellationToken);
+
+ meters.Verify("shop.orders.placed").WithTag("region", "eu").Once();
+}
+```
+
+`Host.CreateApplicationBuilder()` already registers a default
+`IMeterFactory` as part of its built-in service setup, so `IMeterFactory` has
+two registrations once you add yours. The container resolves a **single**
+`IMeterFactory` to its **last** registration, so registering your instance
+after the builder is created means the host resolves `meters`. Do **not** use
+`TryAddSingleton` to install it: `TryAdd` keeps whatever is registered first,
+so it would leave the default factory in place and silently discard yours.
+The test creates the factory, so the test owns it —
+the container does not dispose an instance registration. Dispose the
+factory (here, via `using var` at the end of the test) **after** the host
+has stopped: a measurement recorded after disposal isn't captured.
+
+## Keep the factory for the whole test
+
+Captured measurements stay readable after the factory is disposed, and
+`ClearMeasurements()` keeps working, so you can assert after disposal:
+
+```csharp
+await host.StopAsync(TestContext.Current.CancellationToken);
+meters.Dispose();
+
+meters.Verify("shop.orders.placed").Once(); // still valid
+```
+
+Reads (`GetMeasurements`, `Verify`) never record anything and have no
+side effects, so asserting never perturbs capture.
+
+## Observable instruments
+
+Observable instruments are only recorded when polled. Call
+`RecordObservableInstruments()` after the code under test has run and before
+asserting:
+
+```csharp
+service.PlaceOrder(new Order("eu", 3));
+
+meters.RecordObservableInstruments();
+meters.Verify("shop.queue.depth").WithValue(7).Once();
+```
+
+Each call records one observation per observable instrument; calling it
+twice records twice. Before the first `Create`, or after disposal, it is a
+no-op.
+
+## Background and asynchronous work
+
+Measurements recorded on other threads — a hosted service, a background
+task — are captured thread-safely as they arrive. Compono provides no wait
+or timeout API, so the test must await its own completion signal before
+asserting. There is no chronological ordering guarantee across concurrent
+producers; if a test needs a cross-thread order, establish it itself.
+
+## What the host may not capture
+
+`UseMetrics()` and `CapturingMeterFactory` don't change how the host
+resolves services. A service that captures its own `Meter` through
+`new Meter(...)` (rather than through the injected `IMeterFactory`) is not
+scoped to this factory, so its measurements are never captured — its
+`Meter.Scope` isn't the factory. Give the service the `IMeterFactory` and
+let it create its meters from that, which is the shape this package targets.
+
+## See also
+
+- [`Compono.Metrics` Package Guide](../packages/compono-metrics.md) —
+ selection rules, matching, disposal patterns, and snapshot lifetime.
+- [Share a Value Across a Test](share-a-value-across-a-test.md) — when a
+ composed service needs the same factory the test asserts against, without
+ a host.
+- [Troubleshooting: metrics](../troubleshooting/common-errors.md#verify-metrics-on-a-non-compono-imeterfactory-throws)
+ — the misuse and selection diagnostics.
diff --git a/docs/index.md b/docs/index.md
index 7f010a22..a475903d 100644
--- a/docs/index.md
+++ b/docs/index.md
@@ -48,6 +48,7 @@ Compono determines **how** those requirements are satisfied.
| `Compono.MSTest` | MSTest integration |
| `Compono.NUnit` | NUnit integration (no `[TestFixture]` required) |
| `Compono.Options` | `Microsoft.Extensions.Options` testing support (`TestOptionsSource`, `UseOptions()`) |
+| `Compono.Metrics` | `System.Diagnostics.Metrics` testing support (`UseMetrics()`, `CapturingMeterFactory`, `Verify()`) |
## Example
diff --git a/docs/packages/compono-metrics.md b/docs/packages/compono-metrics.md
new file mode 100644
index 00000000..a6890088
--- /dev/null
+++ b/docs/packages/compono-metrics.md
@@ -0,0 +1,404 @@
+# Compono.Metrics
+
+First-class `System.Diagnostics.Metrics` testing support. `IMeterFactory`
+composes naturally through `UseMetrics()`, backed by a hand-written
+`CapturingMeterFactory` (`System.Diagnostics.Metrics` is in-box on every
+target framework — there is no third-party dependency and no
+`Microsoft.Extensions.Diagnostics.Testing`). A composed factory captures
+every measurement of every instrument a SUT creates — counter,
+up/down-counter, histogram, gauge, and observable instruments when polled
+— and exposes Compono-native typed reads and `Verify()` verification
+reusing core `Compono`'s `CallVerifier` unmodified. See
+[ADR-0072](../adr/0072-compono-metrics-testing-support-package.md) for the
+full decision record and
+[RESEARCH-0039](../research/0039-issue-165-metrics-testing-admission.md)
+for the design investigation and the empirical BCL facts this package
+relies on.
+
+## When to install
+
+Your code under test takes an `IMeterFactory` constructor dependency and
+records measurements, and the test wants to assert *what* was recorded —
+instrument names, values, and tags — not substitute an unrelated
+application interface or hand-write a factory plus one
+`MetricCollector` per instrument:
+
+```bash
+dotnet add package Compono
+dotnet add package Compono.Metrics
+```
+
+This package depends only on `Compono`. `System.Diagnostics.Metrics`
+(`IMeterFactory`, `Meter`, `MeterListener`, `Counter`, and so on) is
+part of the shared framework on every supported target framework, so no
+`PackageReference` is added — not `System.Diagnostics.DiagnosticSource`,
+not `Microsoft.Extensions.Diagnostics`, not
+`Microsoft.Extensions.Diagnostics.Testing`, not
+`Microsoft.Extensions.DependencyInjection.Abstractions`.
+
+**No MSBuild opt-in.** Unlike `Compono.TestDoubles`, there is nothing to
+enable — `Compono.Metrics` ships no generator, analyzer, or props asset.
+`UseMetrics()` works as soon as the package is referenced.
+
+## What it gives you
+
+```csharp
+using Compono;
+using Compono.Metrics;
+using System.Diagnostics.Metrics;
+
+var composer = Composer.Create(builder => builder.UseMetrics());
+var service = composer.Create(); // OrderService(IMeterFactory meters, ...)
+```
+
+```csharp
+public sealed class MetricsProfile : ICompositionProfile
+{
+ public void Configure(CompositionBuilder builder) =>
+ builder.UseMetrics().Share();
+}
+
+[Theory]
+[Compose]
+public void PlacingAnOrderCountsIt([Shared] IMeterFactory meters, OrderService sut)
+{
+ using var _ = meters; // the test owns disposal; see "Disposal patterns"
+
+ sut.PlaceOrder(new Order("eu", 3));
+
+ meters.Verify("shop.orders.placed").WithTag("region", "eu").WithValue(1).Once();
+ meters.Verify("shop.orders.duration").Once(); // histogram: one recording
+}
+```
+
+```csharp
+var placed = meters.GetMeasurements("Shop.Orders", "shop.orders.placed");
+Assert.Equal(1, placed.Sum(m => m.Value)); // value math via LINQ
+```
+
+- **`UseMetrics()`** — registers a stage-6 test-double provider so any
+ `IMeterFactory` request composes as a new `CapturingMeterFactory`.
+- **`meters.GetMeasurements(instrumentName)`** /
+ **`GetMeasurements(meterName, instrumentName)`** — a snapshot list of
+ the matching measurements. Direct inspection, no assertion framework
+ required. `T` is one of `byte`, `short`, `int`, `long`, `float`,
+ `double`, or `decimal`.
+- **`meters.Verify(...)`** — the fluent entry point: `.WithValue(value)`,
+ `.WithTag(key, value)`, `.WithoutTag(key)`, `.Matching(predicate)`,
+ ending in `.Once()` / `.Never()` / `.Exactly(n)` / `.AtLeast(n)` /
+ `.AtMost(n)` — the exact same single-verb vocabulary
+ `Compono.TestDoubles`/`Compono.Http`/`Compono.Logging` already use
+ (`repository.Verify().Save().Once()`, `logger.Verify().AtLevel(...).Once()`),
+ each a thin, one-line forward through the same shared count-verification
+ semantics core `Compono`'s `CallVerifier` implements. The filter chain
+ narrows *which* measurements count, then the terminal counts them exactly
+ the same way regardless of which package it's reached through.
+- **`meters.RecordObservableInstruments()`** — polls this factory's
+ observable instruments. Reads never poll; see "Observable instruments."
+- **`meters.ClearMeasurements()`** — empties the capture buffer. Order is
+ otherwise capture order; see "Capture order."
+- **`CapturingMeterFactory`** — hand-written and publicly, directly
+ constructible with no composition involved at all:
+ ```csharp
+ using var meters = new CapturingMeterFactory();
+ var sut = new OrderService(meters);
+ ```
+ A `UseMetrics()`-composed factory and a directly-constructed one behave
+ identically — one implementation, not two.
+
+## Factory semantics
+
+`CapturingMeterFactory` has parity with the BCL's own `DefaultMeterFactory`:
+
+- `Create(null)` throws `ArgumentNullException`. `Create` with a non-null
+ `options.Scope` that isn't this factory throws `InvalidOperationException`.
+ `Create` after `Dispose()` throws `ObjectDisposedException`.
+- The caller's `MeterOptions` is never mutated. The meter is constructed
+ from a copy whose `Scope` is this factory, so `meter.Scope` is
+ reference-equal to the factory.
+- Meters are cached: the same name, version, and tag set (order-insensitive,
+ `object.Equals` on values) returns the **same** `Meter`. Anything else
+ creates a new one.
+- Thread-safe.
+
+## Capture semantics
+
+- **Listener.** Each factory owns one `MeterListener`, created on its first
+ `Create` and started before the meter is returned. It enables an
+ instrument only when `ReferenceEquals(instrument.Meter.Scope, this)`, so
+ two factories never see each other's measurements even for identical
+ meter and instrument names. There is no static or shared capture state.
+ A factory that never creates a meter never creates a listener.
+- **What's captured.** Every measurement of every enabled instrument kind:
+ `Counter`, `UpDownCounter`, `Histogram`, `Gauge` (`net9.0+`),
+ and observable instruments when polled. Raw measurements only — Compono
+ doesn't aggregate, doesn't interpret kind (no delta-vs-last-value
+ semantics), and doesn't read histogram bucket advice.
+- **No timestamp.** Order is capture order (see "Capture order").
+- **Isolation.** Two factories never see each other's measurements.
+
+## Selection and matching
+
+`GetMeasurements` and `Verify` resolve their selection with the same
+algorithm, in this order. The first rule that applies decides the outcome.
+`Verify` resolves it when the builder is created, so a conflict throws
+before any filter is added.
+
+1. **Arguments.** A null or empty `instrumentName`/`meterName` throws
+ `ArgumentException`. A `T` that isn't one of the seven BCL measurement
+ types throws `ArgumentException` whether or not any instrument exists;
+ the message names the requested type and lists the seven supported types.
+2. **Candidates.** Every instrument this factory has published whose `Name`
+ equals `instrumentName` and, with the two-argument overload, whose
+ `Meter.Name` equals `meterName`. Both comparisons are ordinal and
+ case-sensitive. The candidate set includes instruments of **every** value
+ type, not just `T`.
+3. **Unknown name.** No candidates yields an empty result.
+ `Verify(...).Never()` passes. A failing `Once()`/`Exactly(n)`/`AtLeast(n)`
+ message lists the instruments that do exist (meter name, instrument name,
+ value type), so a typo is visible.
+4. **Meter ambiguity** (one-argument overload only). Candidates from meters
+ with different `Meter.Name` values throw `InvalidOperationException`. The
+ message lists each candidate and points at the two-argument overload.
+5. **Type conflict.** Candidates that record more than one value type throw
+ `InvalidOperationException`, **even when one of the types is `T`**. This
+ can happen inside one meter (`CreateCounter("x")` and
+ `CreateCounter("x")` are distinct instruments) or across same-named
+ meters with different versions or tags.
+6. **Type mismatch.** Candidates that all record one value type other than
+ `T` throw `InvalidOperationException` naming that type, for example
+ `instrument "shop.orders.placed" records int, not long`.
+7. **Merge.** Otherwise every candidate records `T`. Their measurements are
+ merged in capture order.
+
+Matching filters:
+
+- **`WithValue(value)`** uses `EqualityComparer.Default`. Floating-point
+ equality is exact; use `Matching(...)` for tolerance.
+- **`WithTag(key, value)`** matches a measurement that contains a tag with
+ that key (ordinal) whose value satisfies `object.Equals(tagValue, value)`.
+ Other tags are ignored. There is no numeric coercion: `200` (`int`) does
+ **not** match `200L`. Chain calls for several tags.
+- **`WithoutTag(key)`** matches a measurement with no tag with that key.
+- **`Matching(predicate)`** covers exact tag-set and any other condition.
+
+Failure messages follow `LogVerificationBuilder`'s style: the filters are
+joined with `with`/`and`, and the count forwards to core `CallVerifier`'s
+`Expected exactly N call(s) to ..., but received M.` wording. Numeric values
+are formatted with the invariant culture. The message describes the filter
+you asked for. A string tag value is shown quoted (`region = "eu"`); any
+other value shows the runtime type of the value you passed to `WithTag` (for
+example `200` renders as `200 (int)`), so it always matches the expectation
+and never annotates the measurement's actual tag. For example:
+
+```text
+Expected exactly 1 call(s) to instrument "shop.orders.placed" (long) with tag region = "eu" and value 1, but received 0.
+```
+
+```text
+Expected exactly 1 call(s) to instrument "shop.orders.placed" (long) with tag status = 200 (int), but received 0.
+```
+
+When nothing matched an unknown instrument name, the message names the
+instrument that doesn't exist and lists the ones that do:
+
+```text
+Expected exactly 1 call(s) to instrument "shop.orders.placed" (long), but received 0. No instrument named "shop.orders.placed" has been published by this factory. Existing instruments: meter "Shop.Orders": instrument "orders.placed" (long).
+```
+
+These exceptions are `InvalidOperationException`/`ArgumentException` with
+descriptive messages; no new public exception type is added.
+
+## Observable instruments
+
+- `RecordObservableInstruments()` calls this factory's listener's
+ `RecordObservableInstruments()`. Callbacks run synchronously on the
+ calling thread and only for this factory's observable instruments. Each
+ observation appends measurements. Calling it twice records twice.
+- Reads (`GetMeasurements`, `Verify`) never poll and have no side effects.
+- If a callback throws, the BCL behavior stands: the other callbacks still
+ run, then `AggregateException` propagates to the test. Compono doesn't
+ catch it.
+- Before the first `Create`, or after disposal, it is a no-op.
+
+```csharp
+meters.RecordObservableInstruments();
+meters.Verify("shop.queue.depth").WithValue(7).Once();
+```
+
+## Asynchronous measurements
+
+Measurements recorded on other threads (background work, hosted services)
+are captured thread-safely as they arrive. Reads are point-in-time
+snapshots. Compono provides no wait or timeout API — the test awaits its
+own completion signal before asserting.
+
+## Disposal patterns
+
+No ownership or disposal API is added. Composition is non-owning
+(`UseMetrics()` composes a new factory per request and never disposes it).
+`IMeterFactory` already extends `IDisposable`, and `Dispose()` disposes
+every meter the factory created, then the listener. It is idempotent and
+thread-safe, so a test framework that also disposes the argument is
+harmless. The documented patterns:
+
+1. **`[Compose]`-family tests: dispose the `[Shared]` parameter in the test
+ body.**
+
+ ```csharp
+ [Theory, Compose]
+ public void PlacingAnOrderCountsIt([Shared] IMeterFactory meters, OrderService sut)
+ {
+ using var _ = meters;
+ sut.PlaceOrder(new Order("eu", 3));
+ meters.Verify("shop.orders.placed").Once();
+ }
+ ```
+
+ `[Shared]` guarantees the parameter is the same instance the SUT holds,
+ so disposing it disposes everything the SUT created through it. The
+ `using` declaration runs when the method exits, including when an
+ assertion throws. Assertions can go anywhere in the body because
+ captured data stays readable after disposal. In an `async` test,
+ `using var` works the same way and runs after the last `await`.
+ `IMeterFactory` isn't `IAsyncDisposable`, so `await using` doesn't apply.
+
+2. **`Composer.Create` tests: construct the factory, then register it.**
+
+ ```csharp
+ using var meters = new CapturingMeterFactory();
+ var composer = Composer.Create(b => b.Register(() => meters));
+ var sut = composer.Create();
+ ```
+
+ An exact registration takes precedence over `UseMetrics()`, so
+ `UseMetrics()` isn't needed here. The test creates the instance, so it
+ owns it.
+
+3. **Generic Host / DI:** the same, registered as a singleton instance.
+
+ ```csharp
+ using var meters = new CapturingMeterFactory();
+ var builder = Host.CreateApplicationBuilder();
+ builder.Services.AddSingleton(meters); // last IMeterFactory registration wins
+ builder.Services.AddSingleton();
+ using var host = builder.Build();
+
+ // ... start the host, call the code under test ...
+
+ meters.Verify("shop.orders.placed").Once();
+ ```
+
+ `Host.CreateApplicationBuilder()` already registers a default
+ `IMeterFactory` as part of its built-in service setup, so `IMeterFactory`
+ has two registrations once you add yours. The container resolves a
+ **single** `IMeterFactory` to its **last** registration, so the host
+ resolves `meters`. Don't use `TryAddSingleton` to install it: `TryAdd`
+ keeps whatever is registered first, so it would leave the default factory
+ in place and discard yours. An instance registration isn't disposed by the
+ container, so the test's `using` owns it. Dispose the factory after the
+ host has stopped, so measurements recorded during host shutdown are still
+ captured.
+
+Dispose after the SUT's work is done. Measurements recorded after disposal
+aren't captured, so disposing while background work is still running can
+drop measurements. Consequence of skipping disposal: an undisposed factory
+that created meters stays referenced by the BCL's static meter list for the
+process lifetime — the same cost as an undisposed `DefaultMeterFactory`. A
+factory that never created a meter costs nothing.
+
+## Snapshot lifetime
+
+- `GetMeasurements` returns a new list each call. Later captures,
+ `ClearMeasurements()`, and `Dispose()` never change a list already
+ returned.
+- Each `Tags` list is a per-measurement copy taken in the callback; it never
+ aliases the BCL's tag span or another measurement's tags. A measurement
+ with no tags yields `Tags` that is empty, never null.
+- `CapturedMeasurement.Instrument` is the actual `Instrument` object the
+ SUT created. Through `Instrument.Meter` it references the actual `Meter`,
+ and through `Meter.Scope` the factory. That's ordinary object
+ reachability, not a registration; it causes no capture.
+- Snapshots stay valid after the factory is disposed. `Value`, `Tags`, and
+ `Instrument`'s descriptive members remain readable; a disposed meter's
+ instruments report `Enabled == false`, and recording through them is a
+ no-op. Reading a snapshot never throws because of disposal.
+
+## Capture order
+
+- Capture order is the order in which measurements are successfully inserted
+ into the factory's synchronized capture buffer.
+- Each measurement gets a factory-wide sequence number, assigned inside the
+ same lock acquisition that appends it. Merged selections and every
+ snapshot are ordered by that sequence number.
+- Measurements recorded sequentially on one thread are captured in that
+ thread's program order. One `RecordObservableInstruments()` call appends
+ in the order the BCL invokes the callbacks and their observations.
+- **No chronological ordering is claimed across concurrent producers.** Two
+ threads recording at about the same time may be captured in either order.
+- `ClearMeasurements()` doesn't reset the sequence. Order is only meaningful
+ within one factory.
+- One private lock per factory guards appends, clears, and reads; the tag
+ copy happens before the lock is taken.
+
+## Registration order and misuse
+
+- `UseMetrics()` registers a stage-6 provider that handles exactly
+ `typeof(IMeterFactory)` and returns `NotHandled` for everything else.
+ Precedence against `UseNSubstitute()`/`UseGeneratedTestDoubles()` follows
+ the existing first-registered-wins rule
+ ([ADR-0024](../adr/0024-public-provider-extensibility-model.md)).
+ Register `UseMetrics()` first:
+ ```csharp
+ builder.UseMetrics().UseNSubstitute(); // IMeterFactory -> CapturingMeterFactory
+ builder.UseNSubstitute().UseMetrics(); // IMeterFactory -> a substitute instead
+ ```
+- Every `MeterFactoryTestingExtensions` method throws
+ `InvalidOperationException` when the `IMeterFactory` isn't a
+ `CapturingMeterFactory`. The message names `UseMetrics()`, the
+ registration-order requirement, and the host recipe. It's detected by a
+ type check, not reflection.
+- `Meter` constructor parameters are not composed by this package. Consumers
+ that want a specific `Meter` register it from the shared factory in a
+ profile.
+
+## Native AOT and trimming
+
+No reflection, no `MakeGenericType`, no dynamic code, no generated
+activation. `IsAotCompatible=true`, so the library builds with the trim/AOT
+analyzers on every target framework. The `Compono.Metrics.AotSmokeTest`
+project publishes with `PublishAot=true` for `linux-x64` on `net10.0` in CI,
+matching the existing smoke matrix.
+
+## v1 non-goals
+
+Deliberately not in this package — see ADR-0072's Decision Outcome for the
+rationale behind each:
+
+- A metrics framework, aggregation engine, exporter, or OpenTelemetry
+ integration.
+- Tracing (`ActivitySource`) testing.
+- Composing `Meter` parameters, or a configurable meter name.
+- An `IServiceCollection`/host extension (documentation recipe instead).
+- Timestamps, `TimeProvider`, and wait/timeout APIs.
+- Aggregate helpers (`Sum`, `LastValue`) and numeric tag coercion.
+- Automatic disposal by composition.
+- Version- or tag-level meter selection. Same-named instruments with
+ conflicting value types in same-named meters can't be read at all; use
+ `Matching(m => m.Instrument.Meter.Version == "2")` after the types agree.
+- Replacing `Microsoft.Extensions.Diagnostics.Testing` for consumers who
+ prefer it.
+
+## Next
+
+- [Basic Usage sample](../samples/basic-usage.md) (`MetricsTests`) — a
+ concise `UseMetrics()`/`Verify()` scenario in this repo's single clearest
+ reference project.
+- [Verify Metrics Across a Host](../how-to/verify-metrics-across-a-host.md)
+ — the Generic Host recipe.
+- [`Compono.XunitV3`](compono-xunitv3.md)/[`Compono.TUnit`](compono-tunit.md)
+ — `[Compose]`/`[Shared]` used throughout the examples above.
+- [`Compono.Logging`](compono-logging.md) — the same "composed double is the
+ handle, `Verify()` forwards to `CallVerifier`" idiom for logging.
+- [ADR-0072](../adr/0072-compono-metrics-testing-support-package.md) — the
+ full decision record.
diff --git a/docs/packages/index.md b/docs/packages/index.md
index e4818207..6ac32154 100644
--- a/docs/packages/index.md
+++ b/docs/packages/index.md
@@ -1,6 +1,6 @@
# Package Guides
-Compono ships as thirteen independently-installable NuGet packages. Pick
+Compono ships as fourteen independently-installable NuGet packages. Pick
which ones you need before reading any single guide in depth — most
projects only need the first two.
@@ -19,6 +19,7 @@ projects only need the first two.
| [`Compono.Http`](compono-http.md) | `TestHttpHandler` — a reflection-free `HttpMessageHandler` test double: `OnGet`/`OnPost`/etc. + `When(...)` matching, strict unmatched-request behavior, registration-handle verification. | Your test needs to exercise the real `HttpClient` pipeline against a configured HTTP response, instead of substituting an application-level interface. |
| [`Compono.Logging`](compono-logging.md) | `UseLogging()` — `ILogger`/`ILogger` compose as a hand-written `CapturingLogger`/`CapturingLogger`, with structured-property extraction, real scope tracking, and `Verify()` verification. Generation is on by default once installed. | Your composed type takes an `ILogger`/`ILogger` dependency and the test wants to assert what was logged. |
| [`Compono.Options`](compono-options.md) | `TestOptionsSource`/`UseOptions()` — one test-configured source of truth coherently backing `IOptions`/`IOptionsSnapshot`/`IOptionsMonitor` for a settings type. | Your composed type depends on `IOptions`/`IOptionsSnapshot`/`IOptionsMonitor` and the test wants one coherent source, not hand-wired separate registrations or a buggy hand-rolled Monitor fake. |
+| [`Compono.Metrics`](compono-metrics.md) | `UseMetrics()` — `IMeterFactory` composes as a hand-written `CapturingMeterFactory`; typed `GetMeasurements()` and `Verify()`, explicit observable polling. | Your composed type takes an `IMeterFactory` and the test wants to assert recorded values and tags. |
Every package targets `net8.0`/`net9.0`/`net10.0`/`net11.0` and has a
stable release, except `Compono.XunitV3.Aot` (`net9.0`/`net10.0`/`net11.0`
@@ -59,7 +60,7 @@ whether or not you're also using xUnit v3 integration).
## Version compatibility
-All twelve packages ship in lockstep during the `0.x` line — each integration
+All fourteen packages ship in lockstep during the `0.x` line — each integration
package's dependency on `Compono` is exact-pinned at pack time, so mixing
versions across packages (e.g. `Compono.XunitV3 0.3.0` with `Compono
0.5.0`) is not supported and will fail to restore. Always update all
diff --git a/docs/plans/0074-compono-metrics-testing-support-impl-plan.md b/docs/plans/0074-compono-metrics-testing-support-impl-plan.md
new file mode 100644
index 00000000..1e118b3c
--- /dev/null
+++ b/docs/plans/0074-compono-metrics-testing-support-impl-plan.md
@@ -0,0 +1,380 @@
+# [PLAN-0074] `Compono.Metrics`: `System.Diagnostics.Metrics` Testing Support (Issue #165)
+
+**Status:** In Progress
+
+**Implements:** [ADR-0072](../adr/0072-compono-metrics-testing-support-package.md)
+(issue [#165](https://github.com/LayeredCraft/compono/issues/165), child of
+[#161](https://github.com/LayeredCraft/compono/issues/161)). ADR-0072 is
+**Accepted** (product-owner final review, 2026-11-11), and so is this plan.
+The design is approved. Implementation phases B1–B6 are complete and
+independently reviewed with follow-up corrections applied (see
+`## Notes`); the change is uncommitted on `docs/165-metrics-planning`,
+awaiting the single combined PR.
+
+## Goal
+
+A test can write `builder.UseMetrics()`, take `[Shared] IMeterFactory meters`
+next to a SUT that records metrics, dispose it with `using var _ = meters;`,
+and assert `meters.Verify("shop.orders.placed").WithTag("region", "eu").Once()`.
+Measurements are isolated per factory, observable instruments poll only on
+`RecordObservableInstruments()`, and the package has no dependency beyond
+core `Compono`. It builds and tests on `net8.0`–`net11.0`, packs,
+package-validates, and passes the CI Native AOT smoke test (net10.0,
+linux-x64). It ships with a package guide, a host recipe, one BasicUsage
+sample, the API reference, and `compono` skill coverage.
+
+## Scope
+
+**In:** everything in ADR-0072's Decision Outcome.
+
+**Out (do not build):** everything in ADR-0072's "Explicit non-goals", plus:
+
+- Any change to core `Compono`, `Compono.Generators`, or any other `src/`
+ package. If implementation finds that core needs a change, stop and
+ raise it. It's a design question, not an implementation detail.
+- Any `PackageReference` in `src/Compono.Metrics`.
+- Any ownership/disposal API (ADR-0072 "Disposal patterns" is
+ documentation only).
+- A new public exception type (conflicts use `InvalidOperationException`).
+- Extending the CI AOT smoke matrix beyond its existing net10.0/linux-x64
+ shape.
+- Package version bumps and NuGet publishing (release-owner action).
+
+**Release:** ships in the #161 release, **v1.4.0**, alongside #164.
+
+**Delivery (D8, revised):** the maintainer decided the feature ships in **one
+combined PR**. The planning artifacts (RESEARCH-0039, ADR-0072 `Accepted`,
+this plan) travel on the same branch as the implementation (B1–B6); there is
+no separate planning-only PR and no planning-PR merge gate. The combined PR
+also carries the `docs/plans/README.md` and `docs/adr/README.md` rows.
+
+**Dogfood:** optional per repo policy (2026-11-04). Not planned. In-repo
+pack-and-consume and the AOT smoke test cover the integration risk.
+
+## Decisions already made (do not reopen during implementation)
+
+From the maintainer interview and review (2026-11-11), recorded in ADR-0072:
+
+| # | Decision |
+|---|---|
+| D1 | New package `Compono.Metrics`, no external dependency. |
+| D2 | The composed `CapturingMeterFactory` is the handle (`[Shared] IMeterFactory`, extension methods). |
+| D3 | One lazy `MeterListener` per factory, scope-filtered, disposed with the factory. No static state. |
+| D4 | Typed reads: `CapturedMeasurement` (plain `readonly struct`), `GetMeasurements`, `Verify`. |
+| D5 | Selection follows ADR-0072's seven ordered rules: unsupported `T` → `ArgumentException`; unknown name → empty; ambiguous meter names → throw; **mixed value types → type-conflict throw, even if one is `T`**; single other type → mismatch throw; otherwise merge. |
+| D6 | Observable instruments poll only on explicit `RecordObservableInstruments()`. |
+| D7 | `Verify` filters (`WithValue`, `WithTag`, `WithoutTag`, `Matching`) + `CallVerifier` counts. No aggregate helpers. |
+| D8 | Docs PR first, then one implementation PR. |
+| D9 | Host/DI path is a documentation recipe only. |
+| D10 | `Meter` parameters aren't composed (documented recipe). |
+| D11 | No wait API. No timestamp. Tag match is subset + `object.Equals`, no coercion. |
+| D12 | Precedence is registration order (ADR-0024), documented. No generator exclusion. |
+| D13 | Names are ordinal, case-sensitive. Type names: `CapturingMeterFactory`, `CapturedMeasurement`, `MeterFactoryTestingExtensions`, `MeasurementVerificationBuilder`. |
+| D14 | Disposal is test-owned, through the three documented patterns. No ownership API. |
+| D15 | Capture order is insertion order into the synchronized buffer. The sequence number is assigned under the append's lock. No cross-producer chronology. |
+| D16 | Snapshots hold the real `Instrument`/`Meter` references and stay valid after disposal. |
+| D17 | Release v1.4.0. One focused BasicUsage sample. |
+| D18 | An unsupported `T` throws `ArgumentException`. The message names the requested type and lists the seven supported types. |
+| D19 | The v1 limitation is accepted: same-named instruments with conflicting value types in same-named meters can't be read. No version or tag selectors. |
+| D20 | `InvalidOperationException` for ambiguity, type conflicts, type mismatch, and misuse. No custom exception hierarchy. |
+| D21 | Native AOT matrix as documented: analyzers on net8.0–net11.0, CI publish-and-run on net10.0 linux-x64 only. |
+
+## Phases
+
+### B0 — Acceptance (Done: design accepted)
+
+- [x] Product-owner review of RESEARCH-0039, ADR-0072, and this plan.
+ Refinements applied (2026-11-11).
+- [x] Final review of the refinements. ADR-0072 `Status: Accepted`, and its
+ `docs/adr/README.md` row updated (2026-11-11).
+- [x] Delivery revised (2026-11-11): the planning artifacts
+ (RESEARCH-0039, ADR-0072, PLAN-0074, both index rows, and the stale
+ PLAN-0072 row in `docs/plans/README.md` corrected to `Done`) land in
+ the **single combined PR** with the implementation, not a separate
+ planning-only PR. The obsolete planning-PR merge gate is removed.
+
+### B1 — Package skeleton and factory (Done)
+
+- [x] `src/Compono.Metrics/Compono.Metrics.csproj`: TFMs
+ `net8.0;net9.0;net10.0;net11.0`, `IsAotCompatible=true`,
+ `ProjectReference` to `Compono` with the exact-version pin target
+ (copy `Compono.Logging.csproj`'s), `InternalsVisibleTo` the test
+ project. No `PackageReference`.
+- [x] Add it to `Compono.slnx`.
+- [x] `CapturingMeterFactory`: `DefaultMeterFactory` parity (null,
+ foreign-scope, and disposed checks; options copy; meter cache by name
+ + version + order-insensitive tags), lazy listener, idempotent
+ thread-safe `Dispose` (meters, then listener).
+- [x] `MetricsProvider` (internal, stage 6, `typeof(IMeterFactory)` only)
+ and `UseMetrics()`.
+
+### B2 — Capture, selection, verification (Done)
+
+- [x] Typed per-instrument buffers as listener state. Seven numeric
+ callbacks. Tag copy before taking the lock. One lock per factory.
+ The factory-wide sequence number is assigned in the same lock
+ acquisition as the append (D15).
+- [x] `CapturedMeasurement` as a plain `readonly struct`.
+- [x] Selection exactly per ADR-0072's seven rules, in order (D5). The
+ candidate set is never pre-filtered by `T`.
+- [x] `MeterFactoryTestingExtensions`: `GetMeasurements` (new list per
+ call), `Verify` (resolves the selection when the builder is
+ created), `RecordObservableInstruments`, `ClearMeasurements`, misuse
+ `InvalidOperationException` (names `UseMetrics()`, order, host
+ recipe).
+- [x] `MeasurementVerificationBuilder` with `LogVerificationBuilder`-style
+ failure messages, including the existing-instruments list on a
+ failed count.
+
+### B3 — Tests (Done)
+
+See Test Plan. Bounded concurrency only (RESEARCH-0033). `test/Compono.Metrics.Tests`
+passes on all four TFMs: net8.0 (77), net9.0 (78), net10.0 (78), net11.0 (78).
+
+### B4 — Native AOT and packaging (Done)
+
+- [x] `test/Compono.Metrics.AotSmokeTest`, targeting `net10.0` only, like
+ every existing smoke test (copy the `Compono.Logging` layout:
+ `pack-compono.sh`, `nuget.config`, `verify-packaging.sh`). Exercise
+ composition, every instrument kind available on net10.0, observable
+ polling, tags, a type-conflict diagnostic, and `Verify`.
+- [x] Wire `Compono.Metrics` into `.github/workflows/aot-validation.yaml`
+ (the `all_legs` list **and** the `src/Compono\.Metrics/` change
+ filter), `package-validation.yaml`, `docs.yml`,
+ `.github/scripts/inspect-packed-nupkgs.sh` (+ its `.tests.sh`),
+ `generate-api-reference.sh`, and `scripts/dogfood-validate.sh`'s
+ package list, following each file's `Compono.Logging` entry.
+- [x] Package validation for a new package (no ApiCompat baseline yet).
+ Follow how the most recent new package was first validated.
+- [x] The packed `.nuspec` has exactly one dependency (`Compono`, exact
+ version) per TFM group.
+- [x] Optional, not a gate: a manual Native AOT publish of a consumer on
+ net8.0/net9.0/net11.0. If done, record it in Notes as evidence and
+ don't present it as CI coverage.
+
+### B5 — Documentation, sample, and skill (Done)
+
+- [x] `docs/packages/compono-metrics.md` package guide: setup, `[Shared]`,
+ **disposal patterns (all three, with the "dispose after the SUT's
+ work is done" caveat and the undisposed-leak consequence)**,
+ instrument kinds, the selection rules (including type conflicts),
+ tag matching, observables, capture order (no cross-producer
+ chronology), snapshot lifetime, precedence, the `Meter` parameter
+ recipe, the Native AOT validation matrix as stated in ADR-0072,
+ non-goals, and migration from `MetricCollector`.
+- [x] `docs/how-to/` recipe: assert metrics from a Generic Host
+ (`AddSingleton(meters)`, test-owned disposal after
+ the host stops).
+- [x] `docs/troubleshooting/common-errors.md`: misuse, meter ambiguity,
+ type conflict, type mismatch, and unsupported-`T` messages.
+- [x] `docs/packages/index.md`, `docs/index.md`, `README.md` package lists,
+ `mkdocs.yml` nav, `docs/architecture/current/provider-pipeline.md`
+ (stage-6 provider list).
+- [x] One focused sample in `samples/Compono.Samples.BasicUsage`: a
+ `MetricsSampleProfile` (`UseMetrics()`), a small SUT that takes
+ `IMeterFactory`, and one `[Compose]` test using
+ `[Shared] IMeterFactory`, `using var _ = meters;`, and `Verify`.
+ Add the package reference the way the sample references
+ `Compono.Logging`. Update `docs/samples/basic-usage.md`.
+- [x] Regenerate `docs/reference/api` before pushing (memory: API
+ reference drift).
+- [x] `skills/compono/SKILL.md` detection table + `skills/compono/references/metrics.md`
+ (must show the disposal pattern) + evals in `skills/compono/evals/evals.json`.
+
+### B6 — Validation gate and closeout (Done)
+
+- [x] `dotnet build` 0 warnings / 0 errors and `dotnet test` green on all
+ four TFMs.
+- [x] Pack-and-consume check from a throwaway console project on a local
+ feed.
+- [x] CI AOT smoke leg for `Compono.Metrics` green (net10.0, linux-x64,
+ zero IL2xxx/IL3xxx).
+- [x] Plan tasks checked and validation recorded. The combined PR (D8,
+ revised) carries this plan and both index rows; the plan stays
+ `In Progress` until that PR merges, then its index row moves to
+ `Done`, #165 closes, and #161 is updated.
+
+## Critical Files
+
+New:
+
+- `src/Compono.Metrics/` — `Compono.Metrics.csproj`,
+ `CompositionBuilderExtensions.cs`, `MetricsProvider.cs`,
+ `CapturingMeterFactory.cs`, `CapturedMeasurement{T}.cs`,
+ `MeterFactoryTestingExtensions.cs`, `MeasurementVerificationBuilder{T}.cs`,
+ internal capture buffer and selection types.
+- `test/Compono.Metrics.Tests/`, `test/Compono.Metrics.AotSmokeTest/`.
+- `docs/packages/compono-metrics.md`, a `docs/how-to/` host recipe,
+ `skills/compono/references/metrics.md`, `docs/reference/api/Compono.Metrics/`.
+- `samples/Compono.Samples.BasicUsage/` — `MetricsSampleProfile.cs`,
+ `MetricsTests.cs`, a small SUT type (or an addition to `Domain.cs`).
+
+Modified:
+
+- `Compono.slnx`, `.github/workflows/{aot-validation.yaml,package-validation.yaml,docs.yml}`,
+ `.github/scripts/{inspect-packed-nupkgs.sh,inspect-packed-nupkgs.tests.sh,generate-api-reference.sh}`,
+ `scripts/dogfood-validate.sh`, `mkdocs.yml`, `README.md`,
+ `docs/index.md`, `docs/packages/index.md`, `docs/samples/basic-usage.md`,
+ `docs/architecture/current/provider-pipeline.md`,
+ `docs/troubleshooting/common-errors.md`, `skills/compono/SKILL.md`,
+ `skills/compono/evals/evals.json`,
+ `samples/Compono.Samples.BasicUsage/Compono.Samples.BasicUsage.csproj`,
+ `Directory.Packages.props` (only if the sample's package-reference
+ pattern needs a version entry), `.gitignore` (if the AOT smoke test needs
+ the same entries as Logging's).
+- Both index rows (`docs/adr/README.md` and `docs/plans/README.md`) travel in the single combined PR (D8, revised); there is no separate planning-only PR.
+
+Not modified: `src/Compono`, `src/Compono.Generators`, and every other
+`src/` package.
+
+## Test Plan
+
+`test/Compono.Metrics.Tests` (xUnit v3 / MTP, all four TFMs). Each row is
+an acceptance criterion for B3.
+
+| Area | Cases |
+|---|---|
+| Factory parity | null options; foreign scope throws; caller options not mutated; same name/version/tags cached (tag order irrelevant); different version → new meter; `Create` after dispose throws `ObjectDisposedException`. |
+| Composition | `UseMetrics()` composes `IMeterFactory` as `CapturingMeterFactory`; `[Shared]` gives SUT and test one instance; without `[Shared]` they differ; provider ignores other types; an exact `Register` wins over `UseMetrics()`; order vs `UseNSubstitute()` (wrong order → misuse exception naming the cause). |
+| Instrument kinds | `Counter`, `UpDownCounter`, `Histogram` on all TFMs; `Gauge` under `#if NET9_0_OR_GREATER`; each of the seven value types. |
+| Observables | nothing recorded before poll; one poll records once; two polls → two measurements; reads don't poll; only this factory's callbacks run (two factories); throwing callback → `AggregateException` and the other callbacks are still recorded; no-op before the first `Create` and after dispose. |
+| Selection (rules 1–7, one test per rule) | unsupported `T` (e.g. `Guid`) → `ArgumentException` even with no instruments, and the message lists the seven supported types; null/empty names → `ArgumentException`; unknown name → empty, `Never()` passes, and a failed `Once()` lists existing instruments; different meter names with the one-argument overload → ambiguity throw, two-argument overload resolves it; **mixed types in one meter (`Counter("x")` + `Counter("x")`) → type-conflict throw for ``, ``, and ``, the message lists both instruments, and nothing is silently ignored**; mixed types across same-named meters with different versions → type-conflict throw; single other type → mismatch throw naming it; same-named meters with different versions and the same `T` → merged in capture order; `Verify` throws the conflict when the builder is created. |
+| Matching | `WithValue` exact (incl. float); `WithTag` subset; `int` vs `long` doesn't match and the message shows the types; `WithoutTag`; chained filters; `Matching`; every `CallVerifier` terminal. |
+| Tags | no-tag measurement → empty list (not null); tag order preserved; meter/instrument-level tags not merged; a returned `Tags` list isn't affected by later measurements. |
+| Snapshot lifetime | a list returned before `ClearMeasurements()`/`Dispose()`/later captures is unchanged afterwards; after dispose `Value`, `Tags`, `Instrument.Name`, `Instrument.Meter.Name/Version` are readable and `Instrument.Enabled == false`; `Instrument` is reference-equal to the SUT's instrument. |
+| Capture order | single-thread recordings across several instruments come back in program order (including a merged selection); one observable poll appends in callback order; under concurrency, sequence numbers are strictly increasing and gap-free per snapshot, with **no assertion of cross-thread chronology**. |
+| Disposal patterns | pattern 1: a real `[Compose]`-style test body with `using var _ = meters;` disposes the shared factory on success **and** when an assertion throws (meters' instruments report `Enabled == false` afterwards); pattern 2: `Composer.Create` + `Register(() => meters)` captures and disposes; dispose idempotent and concurrent-safe; data readable after dispose; `ClearMeasurements` before/after dispose; recording after dispose not captured. |
+| Isolation | two factories, identical meter and instrument names, running in parallel: no cross-contamination. |
+| Concurrency | bounded multi-thread recording on several instruments alongside reads and clears; no lost or torn measurements (count invariant); bounded writers per RESEARCH-0033. |
+| Host recipe (pattern 3) | real Generic Host (test-only `Microsoft.Extensions.Hosting`): `AddSingleton(meters)` before and after `AddMetrics()` → a SUT resolved from the host records into `meters`; the container doesn't dispose the instance; the test disposes it after the host stops. |
+| Misuse | every extension method on a non-Compono `IMeterFactory` (hand-written stub) throws `InvalidOperationException`. |
+
+Plus the BasicUsage sample test (runs in the normal test run), the
+`Compono.Metrics.AotSmokeTest` CI leg, and the pack-and-consume check (B6).
+
+Validation matrix (the same as ADR-0072's; only CI-backed cells are
+claimed):
+
+| Coverage | net8.0 | net9.0 | net10.0 | net11.0 |
+|---|---|---|---|---|
+| Library build + trim/AOT analyzers (`IsAotCompatible`), warnings as errors | CI | CI | CI | CI |
+| `Compono.Metrics.Tests` (JIT) | CI | CI | CI | CI |
+| `Gauge` (sync) tests | n/a (BCL) | CI | CI | CI |
+| Native AOT publish + run (`Compono.Metrics.AotSmokeTest`, linux-x64) | not covered | not covered | CI | not covered |
+
+Test-framework neutrality comes from core composition. No framework
+adapter changes. Disposal pattern 1 is framework-independent C#.
+
+## Notes
+
+- 2026-11-11: Planning drafted from the maintainer interview. BCL facts
+ are in RESEARCH-0039 §5 (spike on SDK 11.0.100).
+- 2026-11-11: Product-owner review. Disposal patterns, the type-conflict
+ rule, snapshot lifetime, the capture-order definition, and the explicit
+ AOT matrix were added. Open items resolved (D4, D13, D17; the PLAN-0072
+ index fix is part of the same combined PR). One addition made while specifying selection:
+ an unsupported `T` throws `ArgumentException` (rule 1), so the conflict
+ and mismatch rules only deal with real measurement types.
+- 2026-11-11: Final review. ADR-0072 and this plan accepted. D18–D21
+ confirmed (unsupported-`T` diagnostic, the accepted conflicting-type
+ limitation, `InvalidOperationException` only, the AOT matrix).
+ Implementation is not started.
+- 2026-11-11: Implementation (B1–B6) complete on `docs/165-metrics-planning`.
+ Evidence:
+ - `src/Compono.Metrics` builds with **0 warnings / 0 errors** on
+ net8.0–net11.0 with the trim/AOT analyzers.
+ - `dotnet build Compono.slnx -c Debug` → Build succeeded, 0 Warning(s),
+ 0 Error(s). `dotnet test Compono.slnx -c Debug` → total 7403, failed 0,
+ succeeded 6902, skipped 501 (pre-existing platform/placeholder skips).
+ `Compono.Metrics.Tests` per TFM: net8.0 77, net9.0 78, net10.0 78,
+ net11.0 78 (net8.0 has no `Gauge`, which is `net9.0+` BCL).
+ - `samples/Compono.Samples.BasicUsage` (incl. the new `MetricsTests`)
+ → 8 tests, all passing.
+ - Packaged all 14 publishable packages at 1.0.0 into a temp folder and ran
+ `.github/scripts/inspect-packed-nupkgs.tests.sh` (all regression tests
+ passed) and `.github/scripts/inspect-packed-nupkgs.sh ` (all
+ package-contents assertions passed). `Compono.Metrics`-specific checks
+ confirmed: the expected file shape, ``
+ `Compono — System.Diagnostics.Metrics Testing Support`, no `build/` or
+ `analyzers/`, and `Compono` pinned at the exact version per TFM group.
+ - Native AOT: `dotnet publish test/Compono.Metrics.AotSmokeTest -c Release
+ -f net10.0 -r osx-arm64 --self-contained -p:PublishAot=true` produced
+ zero IL2xxx/IL3xxx warnings, and the published binary ran to `PASS`
+ (exit 0). CI publishes the same project for linux-x64 only (ADR-0072's
+ matrix; not extended).
+ - `scripts/dogfood-validate.sh` deliberately needed no change: its
+ default set is the original four packages and `Compono.Logging` is
+ likewise absent; external dogfood is optional per repo policy.
+ - The implementation is left **uncommitted** on `docs/165-metrics-planning`
+ for independent review; no PR, push, merge, package publish, release-draft
+ edit, or issue close was performed. The feature ships in the single combined
+ PR (D8, revised); the plan stays `In Progress` until that PR merges.
+- 2026-11-11: Independent review (Claude) approved the architecture and public
+ API and raised five follow-up corrections; all are applied and validated.
+ Delivery changed to **one combined PR** (D8, revised) — the planning
+ artifacts, implementation, docs, and both index rows travel on
+ `docs/165-metrics-planning`; there is no separate planning-only PR and no
+ planning-PR merge gate. Corrections:
+ - **Gauge capture is TFM-independent.** `CaptureState.IsCapturedKind` now
+ classifies with `instrument is Instrument or ObservableInstrument`
+ (both base types exist on every target), replacing the concrete-kind list
+ with its `#if NET9_0_OR_GREATER` `Gauge` branch. A net8.0 consumer whose
+ runtime provides DiagnosticSource 9.x now records and verifies `Gauge`.
+ New `GaugeCaptureTests` (3 tests) prove it on all four TFMs; the net8.0
+ test assembly references `System.Diagnostics.DiagnosticSource` 9.0.0
+ **test-only** (never a production `PackageReference`, per ADR-0072).
+ - **Meter-tag identity is a one-to-one bag match.** `TagSetsEqual` now
+ requires each left entry to consume a distinct right entry, so duplicate
+ keys are significant (`[k=1, k=1]` ≠ `[k=1, j=2]`). This is intentionally
+ stricter than `DefaultMeterFactory`, whose duplicate-tag comparison is not a
+ true multiset comparison; the empty-tag case still allocates nothing. Three
+ `CapturingMeterFactoryTests` regression tests cover it
+ (`Create_ReturnsSameInstance_ForDuplicateKeysWithIdenticalValues`,
+ `Create_ReturnsDifferentInstance_ForDuplicateKeysWithDifferentSecondEntry`,
+ `Create_ReturnsDifferentInstance_ForDuplicateKeysWithDifferentCount`).
+ - **Host DI rule corrected.** A host's `HostApplicationBuilder` already
+ registers a default `IMeterFactory`; a test factory wins single-service
+ resolution by being the **last** `AddSingleton` registration
+ (never `TryAddSingleton`, which keeps the existing one). The extension's
+ misuse message and the package guide, host recipe, and troubleshooting docs
+ were corrected. Three `HostRecipeTests` prove the default is present, the
+ later registration wins, and `TryAddSingleton` doesn't replace.
+ - **Verification diagnostics.** Filters join with `with`/`and`; numeric
+ values format with the invariant culture; a `WithTag` filter describes the
+ **expected** value the test passed - a string stays quoted with no
+ annotation, and every other non-null value shows its runtime type (e.g.
+ `status = 200 (int)`), so the message never implies it reports the captured
+ measurement's actual tag type; the unknown-instrument
+ suggestion is appended after the core `CallVerifier` count sentence (and
+ names the meter when the two-argument overload was used). `CallVerifier`
+ itself is unchanged, and no public API changed.
+ - **Regression coverage** added, each test identified by file and method:
+ interleaved/merged capture ordering -
+ `SnapshotAndDisposalTests.CaptureOrder_ForMergedSelection_OrdersByCaptureSequence_NotByMeterRegistration`
+ (fails if the capture-sequence sort is dropped); observable callback that
+ throws -
+ `ObservableInstrumentTests.RecordObservableInstruments_ThrowingCallback_PropagatesAggregateException_AndRecordsOthers`;
+ concurrent `Create`/`Dispose` -
+ `CapturingMeterFactoryTests.CreateAndDisposeConcurrently_DisposesSafely_AndRejectsLaterCreate`;
+ recording racing disposal -
+ `IsolationAndConcurrencyTests.RecordingWhileDisposing_DoesNotThrow_AndStopsCapturingAfterDispose`;
+ meaningful clear/record invariants -
+ `IsolationAndConcurrencyTests.ConcurrentClearAndRecord_KeepsCaptureConsistent`;
+ culture-invariant message formatting -
+ `CultureInvarianceTests.FailureMessage_FormatsNumericValueAndTagWithInvariantCulture`;
+ unknown meter/instrument diagnostics -
+ `SelectionTests.UnknownInstrumentName_NeverPasses_AndFailingOnce_ListsExistingInstruments`
+ and `SelectionTests.UnknownInstrumentNameInNamedMeter_ReportsTheMeterAndExistingInstruments`;
+ expected-tag-value type annotation -
+ `VerificationBuilderTests.FailureMessage_AnnotatesExpectedNonStringTagValueWithItsRuntimeType`.
+ Snapshot stability after disposal was already covered by the pre-existing
+ `SnapshotAndDisposalTests.Snapshot_StaysReadable_AfterDispose` (not
+ re-added).
+ - ADR-0072 records these as four dated Amendments; its original Decision text
+ is unchanged.
+ - Updated evidence: `Compono.Metrics.Tests` now passes **94** tests on
+ net9.0/net10.0/net11.0 and **93** on net8.0 (the difference is the single
+ in-box `Gauge` test in `InstrumentCaptureTests`, `#if NET9_0_OR_GREATER`);
+ `HostRecipeTests` 5/5; full-solution build/test, pack-all
+ `inspect-packed-nupkgs.sh`, and the Native AOT publish-and-run are green
+ after the corrections.
diff --git a/docs/plans/README.md b/docs/plans/README.md
index 2d518d9d..0944d242 100644
--- a/docs/plans/README.md
+++ b/docs/plans/README.md
@@ -86,5 +86,6 @@ one. This file is just the mechanics: numbering, status, and the index.
| [0069](0069-generator-wide-per-item-emission-failure-isolation-impl-plan.md) | Generator-Wide Per-Item Emission Failure Isolation (Issue #143) | Done |
| [0070](0070-xunitv3-require-fixture-accessor-impl-plan.md) | xUnit v3 Fixture Accessor (`RequireFixture()`, Issue #162) | Done |
| [0071](0071-xunitv3-composedata-composed-theory-rows-impl-plan.md) | xUnit v3 Composed Theory Rows (`[ComposeData]`, Issue #163) | Done |
-| [0072](0072-compono-logging-host-wide-log-capture-and-dotnet-11-ga-impl-plan.md) | `Compono.Logging` Host-Wide Log Capture (Issue #164) + .NET 11 GA Migration | In Progress |
+| [0072](0072-compono-logging-host-wide-log-capture-and-dotnet-11-ga-impl-plan.md) | `Compono.Logging` Host-Wide Log Capture (Issue #164) + .NET 11 GA Migration | Done |
| [0073](0073-compono-nunit-classic-vstest-discovery-impl-plan.md) | Compono.NUnit: classic-VSTest discovery-time module initialization (Issue #171) | Done |
+| [0074](0074-compono-metrics-testing-support-impl-plan.md) | `Compono.Metrics`: `System.Diagnostics.Metrics` Testing Support (Issue #165) | In Progress |
diff --git a/docs/reference/api/Compono.Metrics/Compono.Metrics.CapturedMeasurement_T_.Instrument.md b/docs/reference/api/Compono.Metrics/Compono.Metrics.CapturedMeasurement_T_.Instrument.md
new file mode 100644
index 00000000..8ce333f8
--- /dev/null
+++ b/docs/reference/api/Compono.Metrics/Compono.Metrics.CapturedMeasurement_T_.Instrument.md
@@ -0,0 +1,18 @@
+#### [Compono\.Metrics](index.md 'index')
+### [Compono\.Metrics](Compono.Metrics.md 'Compono\.Metrics').[CapturedMeasurement<T>](Compono.Metrics.CapturedMeasurement_T_.md 'Compono\.Metrics\.CapturedMeasurement\')
+
+## CapturedMeasurement\\.Instrument Property
+
+The actual [Instrument](Compono.Metrics.CapturedMeasurement_T_.Instrument.md 'Compono\.Metrics\.CapturedMeasurement\\.Instrument') instance that recorded this measurement \(the one the SUT
+created\)\. Through [System\.Diagnostics\.Metrics\.Instrument\.Meter](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.metrics.instrument.meter 'System\.Diagnostics\.Metrics\.Instrument\.Meter') it references the
+actual [System\.Diagnostics\.Metrics\.Meter](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.metrics.meter 'System\.Diagnostics\.Metrics\.Meter'), and through [System\.Diagnostics\.Metrics\.Meter\.Scope](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.metrics.meter.scope 'System\.Diagnostics\.Metrics\.Meter\.Scope') the factory\. Descriptive members
+\(for example [System\.Diagnostics\.Metrics\.Instrument\.Name](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.metrics.instrument.name 'System\.Diagnostics\.Metrics\.Instrument\.Name'),
+[System\.Diagnostics\.Metrics\.Instrument\.Enabled](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.metrics.instrument.enabled 'System\.Diagnostics\.Metrics\.Instrument\.Enabled'), and the meter's name/version/tags\)
+stay readable after the factory is disposed\.
+
+```csharp
+public System.Diagnostics.Metrics.Instrument Instrument { get; }
+```
+
+#### Property Value
+[System\.Diagnostics\.Metrics\.Instrument](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.metrics.instrument 'System\.Diagnostics\.Metrics\.Instrument')
\ No newline at end of file
diff --git a/docs/reference/api/Compono.Metrics/Compono.Metrics.CapturedMeasurement_T_.Tags.md b/docs/reference/api/Compono.Metrics/Compono.Metrics.CapturedMeasurement_T_.Tags.md
new file mode 100644
index 00000000..56c2e00f
--- /dev/null
+++ b/docs/reference/api/Compono.Metrics/Compono.Metrics.CapturedMeasurement_T_.Tags.md
@@ -0,0 +1,16 @@
+#### [Compono\.Metrics](index.md 'index')
+### [Compono\.Metrics](Compono.Metrics.md 'Compono\.Metrics').[CapturedMeasurement<T>](Compono.Metrics.CapturedMeasurement_T_.md 'Compono\.Metrics\.CapturedMeasurement\')
+
+## CapturedMeasurement\\.Tags Property
+
+This measurement's tags, copied out of the BCL's callback span in callback order\. A per\-measurement
+copy that never aliases the BCL's span or any other measurement's tags; empty \(never
+[null](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/null 'https://docs\.microsoft\.com/en\-us/dotnet/csharp/language\-reference/keywords/null')\) when the measurement had no tags\. Meter\-level and instrument\-level tags are
+not merged in \- they're reachable through [Instrument](Compono.Metrics.CapturedMeasurement_T_.Instrument.md 'Compono\.Metrics\.CapturedMeasurement\\.Instrument')\.
+
+```csharp
+public System.Collections.Generic.IReadOnlyList> Tags { get; }
+```
+
+#### Property Value
+[System\.Collections\.Generic\.IReadOnlyList<](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ireadonlylist-1 'System\.Collections\.Generic\.IReadOnlyList\`1')[System\.Collections\.Generic\.KeyValuePair<](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.keyvaluepair-2 'System\.Collections\.Generic\.KeyValuePair\`2')[System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String')[,](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.keyvaluepair-2 'System\.Collections\.Generic\.KeyValuePair\`2')[System\.Object](https://learn.microsoft.com/en-us/dotnet/api/system.object 'System\.Object')[>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.keyvaluepair-2 'System\.Collections\.Generic\.KeyValuePair\`2')[>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ireadonlylist-1 'System\.Collections\.Generic\.IReadOnlyList\`1')
\ No newline at end of file
diff --git a/docs/reference/api/Compono.Metrics/Compono.Metrics.CapturedMeasurement_T_.Value.md b/docs/reference/api/Compono.Metrics/Compono.Metrics.CapturedMeasurement_T_.Value.md
new file mode 100644
index 00000000..eedf850c
--- /dev/null
+++ b/docs/reference/api/Compono.Metrics/Compono.Metrics.CapturedMeasurement_T_.Value.md
@@ -0,0 +1,14 @@
+#### [Compono\.Metrics](index.md 'index')
+### [Compono\.Metrics](Compono.Metrics.md 'Compono\.Metrics').[CapturedMeasurement<T>](Compono.Metrics.CapturedMeasurement_T_.md 'Compono\.Metrics\.CapturedMeasurement\')
+
+## CapturedMeasurement\\.Value Property
+
+The recorded value, exactly as the instrument received it \(no normalization, no
+ aggregation\)\.
+
+```csharp
+public T Value { get; }
+```
+
+#### Property Value
+[T](Compono.Metrics.CapturedMeasurement_T_.md#Compono.Metrics.CapturedMeasurement_T_.T 'Compono\.Metrics\.CapturedMeasurement\\.T')
\ No newline at end of file
diff --git a/docs/reference/api/Compono.Metrics/Compono.Metrics.CapturedMeasurement_T_.md b/docs/reference/api/Compono.Metrics/Compono.Metrics.CapturedMeasurement_T_.md
new file mode 100644
index 00000000..a58f333a
--- /dev/null
+++ b/docs/reference/api/Compono.Metrics/Compono.Metrics.CapturedMeasurement_T_.md
@@ -0,0 +1,31 @@
+#### [Compono\.Metrics](index.md 'index')
+### [Compono\.Metrics](Compono.Metrics.md 'Compono\.Metrics')
+
+## CapturedMeasurement\ Struct
+
+A single captured measurement: the recorded value, its tags, and the [Instrument](Compono.Metrics.CapturedMeasurement_T_.Instrument.md 'Compono\.Metrics\.CapturedMeasurement\\.Instrument') that
+recorded it\. A plain [readonly](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/readonly 'https://docs\.microsoft\.com/en\-us/dotnet/csharp/language\-reference/keywords/readonly')[struct](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/struct 'https://docs\.microsoft\.com/en\-us/dotnet/csharp/language\-reference/keywords/struct') \- deliberately not a
+[record](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/record 'https://docs\.microsoft\.com/en\-us/dotnet/csharp/language\-reference/keywords/record')[struct](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/struct 'https://docs\.microsoft\.com/en\-us/dotnet/csharp/language\-reference/keywords/struct'), so there is no synthesized value equality that
+would suggest `==` compares [Tags](Compono.Metrics.CapturedMeasurement_T_.Tags.md 'Compono\.Metrics\.CapturedMeasurement\\.Tags') by value; use [Value](Compono.Metrics.CapturedMeasurement_T_.Value.md 'Compono\.Metrics\.CapturedMeasurement\\.Value') directly or
+the [Verify<T>\(this IMeterFactory, string\)](Compono.Metrics.MeterFactoryTestingExtensions.Verify.md#Compono.Metrics.MeterFactoryTestingExtensions.Verify_T_(thisSystem.Diagnostics.Metrics.IMeterFactory,string) 'Compono\.Metrics\.MeterFactoryTestingExtensions\.Verify\\(this System\.Diagnostics\.Metrics\.IMeterFactory, string\)') filter chain\.
+See docs/adr/0072\-compono\-metrics\-testing\-support\-package\.md\.
+
+```csharp
+public readonly struct CapturedMeasurement
+ where T : struct
+```
+#### Type parameters
+
+
+
+`T`
+
+The measurement's value type \- one of the seven BCL measurement value types
+ \([System\.Byte](https://learn.microsoft.com/en-us/dotnet/api/system.byte 'System\.Byte'), [System\.Int16](https://learn.microsoft.com/en-us/dotnet/api/system.int16 'System\.Int16'), [System\.Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32 'System\.Int32'), [System\.Int64](https://learn.microsoft.com/en-us/dotnet/api/system.int64 'System\.Int64'), [System\.Single](https://learn.microsoft.com/en-us/dotnet/api/system.single 'System\.Single'),
+ [System\.Double](https://learn.microsoft.com/en-us/dotnet/api/system.double 'System\.Double'), [System\.Decimal](https://learn.microsoft.com/en-us/dotnet/api/system.decimal 'System\.Decimal')\)\.
+
+| Properties | |
+| :--- | :--- |
+| [Instrument](Compono.Metrics.CapturedMeasurement_T_.Instrument.md 'Compono\.Metrics\.CapturedMeasurement\\.Instrument') | The actual [Instrument](Compono.Metrics.CapturedMeasurement_T_.Instrument.md 'Compono\.Metrics\.CapturedMeasurement\\.Instrument') instance that recorded this measurement \(the one the SUT created\)\. Through [System\.Diagnostics\.Metrics\.Instrument\.Meter](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.metrics.instrument.meter 'System\.Diagnostics\.Metrics\.Instrument\.Meter') it references the actual [System\.Diagnostics\.Metrics\.Meter](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.metrics.meter 'System\.Diagnostics\.Metrics\.Meter'), and through [System\.Diagnostics\.Metrics\.Meter\.Scope](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.metrics.meter.scope 'System\.Diagnostics\.Metrics\.Meter\.Scope') the factory\. Descriptive members \(for example [System\.Diagnostics\.Metrics\.Instrument\.Name](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.metrics.instrument.name 'System\.Diagnostics\.Metrics\.Instrument\.Name'), [System\.Diagnostics\.Metrics\.Instrument\.Enabled](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.metrics.instrument.enabled 'System\.Diagnostics\.Metrics\.Instrument\.Enabled'), and the meter's name/version/tags\) stay readable after the factory is disposed\. |
+| [Tags](Compono.Metrics.CapturedMeasurement_T_.Tags.md 'Compono\.Metrics\.CapturedMeasurement\\.Tags') | This measurement's tags, copied out of the BCL's callback span in callback order\. A per\-measurement copy that never aliases the BCL's span or any other measurement's tags; empty \(never [null](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/null 'https://docs\.microsoft\.com/en\-us/dotnet/csharp/language\-reference/keywords/null')\) when the measurement had no tags\. Meter\-level and instrument\-level tags are not merged in \- they're reachable through [Instrument](Compono.Metrics.CapturedMeasurement_T_.Instrument.md 'Compono\.Metrics\.CapturedMeasurement\\.Instrument')\. |
+| [Value](Compono.Metrics.CapturedMeasurement_T_.Value.md 'Compono\.Metrics\.CapturedMeasurement\\.Value') | The recorded value, exactly as the instrument received it \(no normalization, no aggregation\)\. |
diff --git a/docs/reference/api/Compono.Metrics/Compono.Metrics.CapturingMeterFactory.CapturingMeterFactory().md b/docs/reference/api/Compono.Metrics/Compono.Metrics.CapturingMeterFactory.CapturingMeterFactory().md
new file mode 100644
index 00000000..1a91d9a7
--- /dev/null
+++ b/docs/reference/api/Compono.Metrics/Compono.Metrics.CapturingMeterFactory.CapturingMeterFactory().md
@@ -0,0 +1,11 @@
+#### [Compono\.Metrics](index.md 'index')
+### [Compono\.Metrics](Compono.Metrics.md 'Compono\.Metrics').[CapturingMeterFactory](Compono.Metrics.CapturingMeterFactory.md 'Compono\.Metrics\.CapturingMeterFactory')
+
+## CapturingMeterFactory\(\) Constructor
+
+Creates a standalone [CapturingMeterFactory](Compono.Metrics.CapturingMeterFactory.md 'Compono\.Metrics\.CapturingMeterFactory'), usable with no Compono composition involved
+at all\.
+
+```csharp
+public CapturingMeterFactory();
+```
\ No newline at end of file
diff --git a/docs/reference/api/Compono.Metrics/Compono.Metrics.CapturingMeterFactory.Create(System.Diagnostics.Metrics.MeterOptions).md b/docs/reference/api/Compono.Metrics/Compono.Metrics.CapturingMeterFactory.Create(System.Diagnostics.Metrics.MeterOptions).md
new file mode 100644
index 00000000..4e602eca
--- /dev/null
+++ b/docs/reference/api/Compono.Metrics/Compono.Metrics.CapturingMeterFactory.Create(System.Diagnostics.Metrics.MeterOptions).md
@@ -0,0 +1,37 @@
+#### [Compono\.Metrics](index.md 'index')
+### [Compono\.Metrics](Compono.Metrics.md 'Compono\.Metrics').[CapturingMeterFactory](Compono.Metrics.CapturingMeterFactory.md 'Compono\.Metrics\.CapturingMeterFactory')
+
+## CapturingMeterFactory\.Create\(MeterOptions\) Method
+
+Creates a [System\.Diagnostics\.Metrics\.Meter](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.metrics.meter 'System\.Diagnostics\.Metrics\.Meter') bound to this factory\. The same name, version, and tag set
+\(order\-insensitive, [System\.Object\.Equals\(System\.Object,System\.Object\)](https://learn.microsoft.com/en-us/dotnet/api/system.object.equals#system-object-equals(system-object-system-object) 'System\.Object\.Equals\(System\.Object,System\.Object\)') on values\) returns the same
+[System\.Diagnostics\.Metrics\.Meter](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.metrics.meter 'System\.Diagnostics\.Metrics\.Meter'); anything else creates a new one\. Duplicate tag keys are significant:
+`[k=1, k=1]` is a different set from `[k=1, j=2]`\.
+
+```csharp
+public System.Diagnostics.Metrics.Meter Create(System.Diagnostics.Metrics.MeterOptions options);
+```
+#### Parameters
+
+
+
+`options` [System\.Diagnostics\.Metrics\.MeterOptions](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.metrics.meteroptions 'System\.Diagnostics\.Metrics\.MeterOptions')
+
+The meter options\.
+
+Implements [Create\(MeterOptions\)](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.metrics.imeterfactory.create#system-diagnostics-metrics-imeterfactory-create(system-diagnostics-metrics-meteroptions) 'System\.Diagnostics\.Metrics\.IMeterFactory\.Create\(System\.Diagnostics\.Metrics\.MeterOptions\)')
+
+#### Returns
+[System\.Diagnostics\.Metrics\.Meter](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.metrics.meter 'System\.Diagnostics\.Metrics\.Meter')
+
+#### Exceptions
+
+[System\.ArgumentNullException](https://learn.microsoft.com/en-us/dotnet/api/system.argumentnullexception 'System\.ArgumentNullException')
+[options](Compono.Metrics.CapturingMeterFactory.Create(System.Diagnostics.Metrics.MeterOptions).md#Compono.Metrics.CapturingMeterFactory.Create(System.Diagnostics.Metrics.MeterOptions).options 'Compono\.Metrics\.CapturingMeterFactory\.Create\(System\.Diagnostics\.Metrics\.MeterOptions\)\.options') is [null](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/null 'https://docs\.microsoft\.com/en\-us/dotnet/csharp/language\-reference/keywords/null')\.
+
+[System\.InvalidOperationException](https://learn.microsoft.com/en-us/dotnet/api/system.invalidoperationexception 'System\.InvalidOperationException')
+[options](Compono.Metrics.CapturingMeterFactory.Create(System.Diagnostics.Metrics.MeterOptions).md#Compono.Metrics.CapturingMeterFactory.Create(System.Diagnostics.Metrics.MeterOptions).options 'Compono\.Metrics\.CapturingMeterFactory\.Create\(System\.Diagnostics\.Metrics\.MeterOptions\)\.options')'s [System\.Diagnostics\.Metrics\.MeterOptions\.Scope](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.metrics.meteroptions.scope 'System\.Diagnostics\.Metrics\.MeterOptions\.Scope')
+ is non\-[null](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/null 'https://docs\.microsoft\.com/en\-us/dotnet/csharp/language\-reference/keywords/null') and isn't this factory\.
+
+[System\.ObjectDisposedException](https://learn.microsoft.com/en-us/dotnet/api/system.objectdisposedexception 'System\.ObjectDisposedException')
+This factory has been disposed\.
\ No newline at end of file
diff --git a/docs/reference/api/Compono.Metrics/Compono.Metrics.CapturingMeterFactory.Dispose().md b/docs/reference/api/Compono.Metrics/Compono.Metrics.CapturingMeterFactory.Dispose().md
new file mode 100644
index 00000000..d3fbea80
--- /dev/null
+++ b/docs/reference/api/Compono.Metrics/Compono.Metrics.CapturingMeterFactory.Dispose().md
@@ -0,0 +1,17 @@
+#### [Compono\.Metrics](index.md 'index')
+### [Compono\.Metrics](Compono.Metrics.md 'Compono\.Metrics').[CapturingMeterFactory](Compono.Metrics.CapturingMeterFactory.md 'Compono\.Metrics\.CapturingMeterFactory')
+
+## CapturingMeterFactory\.Dispose\(\) Method
+
+Disposes every meter this factory created \(raising
+`MeasurementsCompleted`\), then its [System\.Diagnostics\.Metrics\.MeterListener](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.metrics.meterlistener 'System\.Diagnostics\.Metrics\.MeterListener')\. Idempotent and
+thread\-safe\. Captured measurements stay readable afterwards; measurements recorded on the disposed
+meters' instruments are no longer captured\. Disposing a [System\.Diagnostics\.Metrics\.Meter](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.metrics.meter 'System\.Diagnostics\.Metrics\.Meter') a consumer obtained from
+[Create\(MeterOptions\)](Compono.Metrics.CapturingMeterFactory.Create(System.Diagnostics.Metrics.MeterOptions).md 'Compono\.Metrics\.CapturingMeterFactory\.Create\(System\.Diagnostics\.Metrics\.MeterOptions\)') is a no\-op \- the factory owns the meter's lifetime, matching
+`DefaultMeterFactory`\.
+
+```csharp
+public void Dispose();
+```
+
+Implements [Dispose\(\)](https://learn.microsoft.com/en-us/dotnet/api/system.idisposable.dispose 'System\.IDisposable\.Dispose')
\ No newline at end of file
diff --git a/docs/reference/api/Compono.Metrics/Compono.Metrics.CapturingMeterFactory.md b/docs/reference/api/Compono.Metrics/Compono.Metrics.CapturingMeterFactory.md
new file mode 100644
index 00000000..c648f88e
--- /dev/null
+++ b/docs/reference/api/Compono.Metrics/Compono.Metrics.CapturingMeterFactory.md
@@ -0,0 +1,46 @@
+#### [Compono\.Metrics](index.md 'index')
+### [Compono\.Metrics](Compono.Metrics.md 'Compono\.Metrics')
+
+## CapturingMeterFactory Class
+
+A hand\-written, reflection\-free [System\.Diagnostics\.Metrics\.IMeterFactory](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.metrics.imeterfactory 'System\.Diagnostics\.Metrics\.IMeterFactory') that captures the measurements of every
+instrument its meters publish into an inspectable, thread\-safe, Compono\-native model
+\([CapturedMeasurement<T>](Compono.Metrics.CapturedMeasurement_T_.md 'Compono\.Metrics\.CapturedMeasurement\')\)\. Directly, publicly constructible \- composing through
+[UseMetrics\(this CompositionBuilder\)](Compono.Metrics.CompositionBuilderExtensions.UseMetrics(thisCompono.CompositionBuilder).md 'Compono\.Metrics\.CompositionBuilderExtensions\.UseMetrics\(this Compono\.CompositionBuilder\)') is not required\. See
+docs/adr/0072\-compono\-metrics\-testing\-support\-package\.md\.
+
+```csharp
+public sealed class CapturingMeterFactory : System.Diagnostics.Metrics.IMeterFactory, System.IDisposable
+```
+
+Inheritance [System\.Object](https://learn.microsoft.com/en-us/dotnet/api/system.object 'System\.Object') → CapturingMeterFactory
+
+Implements [System\.Diagnostics\.Metrics\.IMeterFactory](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.metrics.imeterfactory 'System\.Diagnostics\.Metrics\.IMeterFactory'), [System\.IDisposable](https://learn.microsoft.com/en-us/dotnet/api/system.idisposable 'System\.IDisposable')
+
+### Remarks
+
+Factory semantics match `DefaultMeterFactory`: [Create\(MeterOptions\)](Compono.Metrics.CapturingMeterFactory.Create(System.Diagnostics.Metrics.MeterOptions).md 'Compono\.Metrics\.CapturingMeterFactory\.Create\(System\.Diagnostics\.Metrics\.MeterOptions\)')
+rejects a [null](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/null 'https://docs\.microsoft\.com/en\-us/dotnet/csharp/language\-reference/keywords/null')[System\.Diagnostics\.Metrics\.MeterOptions](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.metrics.meteroptions 'System\.Diagnostics\.Metrics\.MeterOptions') and a foreign [System\.Diagnostics\.Metrics\.MeterOptions\.Scope](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.metrics.meteroptions.scope 'System\.Diagnostics\.Metrics\.MeterOptions\.Scope'),
+throws [System\.ObjectDisposedException](https://learn.microsoft.com/en-us/dotnet/api/system.objectdisposedexception 'System\.ObjectDisposedException') after disposal, never mutates the caller's options, and caches
+meters by name, version, and order-insensitive tag set (duplicate tag keys are significant - see
+[Create\(MeterOptions\)](Compono.Metrics.CapturingMeterFactory.Create(System.Diagnostics.Metrics.MeterOptions).md 'Compono\.Metrics\.CapturingMeterFactory\.Create\(System\.Diagnostics\.Metrics\.MeterOptions\)')). Disposing a [System\.Diagnostics\.Metrics\.Meter](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.metrics.meter 'System\.Diagnostics\.Metrics\.Meter') a consumer obtained from [Create\(MeterOptions\)](Compono.Metrics.CapturingMeterFactory.Create(System.Diagnostics.Metrics.MeterOptions).md 'Compono\.Metrics\.CapturingMeterFactory\.Create\(System\.Diagnostics\.Metrics\.MeterOptions\)') is a
+no-op: the factory owns the meter's lifetime and releases it on [Dispose\(\)](Compono.Metrics.CapturingMeterFactory.Dispose().md 'Compono\.Metrics\.CapturingMeterFactory\.Dispose\(\)').
+
+Each factory owns one lazily created [System\.Diagnostics\.Metrics\.MeterListener](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.metrics.meterlistener 'System\.Diagnostics\.Metrics\.MeterListener'), created on the first [Create\(MeterOptions\)](Compono.Metrics.CapturingMeterFactory.Create(System.Diagnostics.Metrics.MeterOptions).md 'Compono\.Metrics\.CapturingMeterFactory\.Create\(System\.Diagnostics\.Metrics\.MeterOptions\)')
+and disposed with the factory. It enables only instruments whose [System\.Diagnostics\.Metrics\.Meter\.Scope](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.metrics.meter.scope 'System\.Diagnostics\.Metrics\.Meter\.Scope') is this factory,
+so two factories never see each other's measurements even for identical meter and instrument names. There
+is no static or shared capture state.
+
+Disposal is the test's responsibility ([System\.Diagnostics\.Metrics\.IMeterFactory](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.metrics.imeterfactory 'System\.Diagnostics\.Metrics\.IMeterFactory') already extends
+[System\.IDisposable](https://learn.microsoft.com/en-us/dotnet/api/system.idisposable 'System\.IDisposable')); composition never disposes the factory. An undisposed factory that created
+meters stays referenced by the BCL's static meter list for the process lifetime - the same cost as an
+undisposed `DefaultMeterFactory`.
+
+| Constructors | |
+| :--- | :--- |
+| [CapturingMeterFactory\(\)](Compono.Metrics.CapturingMeterFactory.CapturingMeterFactory().md 'Compono\.Metrics\.CapturingMeterFactory\.CapturingMeterFactory\(\)') | Creates a standalone [CapturingMeterFactory](Compono.Metrics.CapturingMeterFactory.md 'Compono\.Metrics\.CapturingMeterFactory'), usable with no Compono composition involved at all\. |
+
+| Methods | |
+| :--- | :--- |
+| [Create\(MeterOptions\)](Compono.Metrics.CapturingMeterFactory.Create(System.Diagnostics.Metrics.MeterOptions).md 'Compono\.Metrics\.CapturingMeterFactory\.Create\(System\.Diagnostics\.Metrics\.MeterOptions\)') | Creates a [System\.Diagnostics\.Metrics\.Meter](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.metrics.meter 'System\.Diagnostics\.Metrics\.Meter') bound to this factory\. The same name, version, and tag set \(order\-insensitive, [System\.Object\.Equals\(System\.Object,System\.Object\)](https://learn.microsoft.com/en-us/dotnet/api/system.object.equals#system-object-equals(system-object-system-object) 'System\.Object\.Equals\(System\.Object,System\.Object\)') on values\) returns the same [System\.Diagnostics\.Metrics\.Meter](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.metrics.meter 'System\.Diagnostics\.Metrics\.Meter'); anything else creates a new one\. Duplicate tag keys are significant: `[k=1, k=1]` is a different set from `[k=1, j=2]`\. |
+| [Dispose\(\)](Compono.Metrics.CapturingMeterFactory.Dispose().md 'Compono\.Metrics\.CapturingMeterFactory\.Dispose\(\)') | Disposes every meter this factory created \(raising `MeasurementsCompleted`\), then its [System\.Diagnostics\.Metrics\.MeterListener](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.metrics.meterlistener 'System\.Diagnostics\.Metrics\.MeterListener')\. Idempotent and thread\-safe\. Captured measurements stay readable afterwards; measurements recorded on the disposed meters' instruments are no longer captured\. Disposing a [System\.Diagnostics\.Metrics\.Meter](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.metrics.meter 'System\.Diagnostics\.Metrics\.Meter') a consumer obtained from [Create\(MeterOptions\)](Compono.Metrics.CapturingMeterFactory.Create(System.Diagnostics.Metrics.MeterOptions).md 'Compono\.Metrics\.CapturingMeterFactory\.Create\(System\.Diagnostics\.Metrics\.MeterOptions\)') is a no\-op \- the factory owns the meter's lifetime, matching `DefaultMeterFactory`\. |
diff --git a/docs/reference/api/Compono.Metrics/Compono.Metrics.CompositionBuilderExtensions.UseMetrics(thisCompono.CompositionBuilder).md b/docs/reference/api/Compono.Metrics/Compono.Metrics.CompositionBuilderExtensions.UseMetrics(thisCompono.CompositionBuilder).md
new file mode 100644
index 00000000..d67da9b2
--- /dev/null
+++ b/docs/reference/api/Compono.Metrics/Compono.Metrics.CompositionBuilderExtensions.UseMetrics(thisCompono.CompositionBuilder).md
@@ -0,0 +1,36 @@
+#### [Compono\.Metrics](index.md 'index')
+### [Compono\.Metrics](Compono.Metrics.md 'Compono\.Metrics').[CompositionBuilderExtensions](Compono.Metrics.CompositionBuilderExtensions.md 'Compono\.Metrics\.CompositionBuilderExtensions')
+
+## CompositionBuilderExtensions\.UseMetrics\(this CompositionBuilder\) Method
+
+Registers a stage\-6 test\-double provider \(`Compono.Metrics.MetricsProvider`\) so a bare
+[System\.Diagnostics\.Metrics\.IMeterFactory](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.metrics.imeterfactory 'System\.Diagnostics\.Metrics\.IMeterFactory') composes as a new
+[CapturingMeterFactory](Compono.Metrics.CapturingMeterFactory.md 'Compono\.Metrics\.CapturingMeterFactory') per request\.
+
+```csharp
+public static Compono.CompositionBuilder UseMetrics(this Compono.CompositionBuilder builder);
+```
+#### Parameters
+
+
+
+`builder` [CompositionBuilder](../Compono/Compono.CompositionBuilder.md 'Compono\.CompositionBuilder')
+
+The builder to register into\.
+
+#### Returns
+[CompositionBuilder](../Compono/Compono.CompositionBuilder.md 'Compono\.CompositionBuilder')
+The same [builder](Compono.Metrics.CompositionBuilderExtensions.UseMetrics(thisCompono.CompositionBuilder).md#Compono.Metrics.CompositionBuilderExtensions.UseMetrics(thisCompono.CompositionBuilder).builder 'Compono\.Metrics\.CompositionBuilderExtensions\.UseMetrics\(this Compono\.CompositionBuilder\)\.builder'), for chaining\.
+
+#### Exceptions
+
+[System\.ArgumentNullException](https://learn.microsoft.com/en-us/dotnet/api/system.argumentnullexception 'System\.ArgumentNullException')
+[builder](Compono.Metrics.CompositionBuilderExtensions.UseMetrics(thisCompono.CompositionBuilder).md#Compono.Metrics.CompositionBuilderExtensions.UseMetrics(thisCompono.CompositionBuilder).builder 'Compono\.Metrics\.CompositionBuilderExtensions\.UseMetrics\(this Compono\.CompositionBuilder\)\.builder') is [null](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/null 'https://docs\.microsoft\.com/en\-us/dotnet/csharp/language\-reference/keywords/null')\.
+
+### Remarks
+Register this \before\`UseNSubstitute()` if
+[System\.Diagnostics\.Metrics\.IMeterFactory](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.metrics.imeterfactory 'System\.Diagnostics\.Metrics\.IMeterFactory') should resolve through Compono\.Metrics rather
+than an NSubstitute substitute \- Compono's stage\-6 providers resolve in registration order
+\(first\-registered\-wins\), an existing, documented, `Accepted` pattern \(ADR\-0024\) this package
+follows rather than replacing\. An exact `Register(...)` always wins over
+`UseMetrics()` regardless of order\.
\ No newline at end of file
diff --git a/docs/reference/api/Compono.Metrics/Compono.Metrics.CompositionBuilderExtensions.md b/docs/reference/api/Compono.Metrics/Compono.Metrics.CompositionBuilderExtensions.md
new file mode 100644
index 00000000..46f20839
--- /dev/null
+++ b/docs/reference/api/Compono.Metrics/Compono.Metrics.CompositionBuilderExtensions.md
@@ -0,0 +1,16 @@
+#### [Compono\.Metrics](index.md 'index')
+### [Compono\.Metrics](Compono.Metrics.md 'Compono\.Metrics')
+
+## CompositionBuilderExtensions Class
+
+Registers [Compono\.Metrics](Compono.Metrics.md 'Compono\.Metrics') support into a [CompositionBuilder](../Compono/Compono.CompositionBuilder.md 'Compono\.CompositionBuilder')\.
+
+```csharp
+public static class CompositionBuilderExtensions
+```
+
+Inheritance [System\.Object](https://learn.microsoft.com/en-us/dotnet/api/system.object 'System\.Object') → CompositionBuilderExtensions
+
+| Methods | |
+| :--- | :--- |
+| [UseMetrics\(this CompositionBuilder\)](Compono.Metrics.CompositionBuilderExtensions.UseMetrics(thisCompono.CompositionBuilder).md 'Compono\.Metrics\.CompositionBuilderExtensions\.UseMetrics\(this Compono\.CompositionBuilder\)') | Registers a stage\-6 test\-double provider \(`Compono.Metrics.MetricsProvider`\) so a bare [System\.Diagnostics\.Metrics\.IMeterFactory](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.metrics.imeterfactory 'System\.Diagnostics\.Metrics\.IMeterFactory') composes as a new [CapturingMeterFactory](Compono.Metrics.CapturingMeterFactory.md 'Compono\.Metrics\.CapturingMeterFactory') per request\. |
diff --git a/docs/reference/api/Compono.Metrics/Compono.Metrics.MeasurementVerificationBuilder_T_.AtLeast(int).md b/docs/reference/api/Compono.Metrics/Compono.Metrics.MeasurementVerificationBuilder_T_.AtLeast(int).md
new file mode 100644
index 00000000..a25b750b
--- /dev/null
+++ b/docs/reference/api/Compono.Metrics/Compono.Metrics.MeasurementVerificationBuilder_T_.AtLeast(int).md
@@ -0,0 +1,21 @@
+#### [Compono\.Metrics](index.md 'index')
+### [Compono\.Metrics](Compono.Metrics.md 'Compono\.Metrics').[MeasurementVerificationBuilder<T>](Compono.Metrics.MeasurementVerificationBuilder_T_.md 'Compono\.Metrics\.MeasurementVerificationBuilder\')
+
+## MeasurementVerificationBuilder\\.AtLeast\(int\) Method
+
+Asserts the accumulated filters matched at least [times](Compono.Metrics.MeasurementVerificationBuilder_T_.AtLeast(int).md#Compono.Metrics.MeasurementVerificationBuilder_T_.AtLeast(int).times 'Compono\.Metrics\.MeasurementVerificationBuilder\\.AtLeast\(int\)\.times') times\.
+
+```csharp
+public void AtLeast(int times);
+```
+#### Parameters
+
+
+
+`times` [System\.Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32 'System\.Int32')
+
+#### Exceptions
+
+[TestDoubleVerificationException](../Compono/Compono.TestDoubleVerificationException.md 'Compono\.TestDoubleVerificationException')
+The filters matched fewer than
+ [times](Compono.Metrics.MeasurementVerificationBuilder_T_.AtLeast(int).md#Compono.Metrics.MeasurementVerificationBuilder_T_.AtLeast(int).times 'Compono\.Metrics\.MeasurementVerificationBuilder\\.AtLeast\(int\)\.times') times\.
\ No newline at end of file
diff --git a/docs/reference/api/Compono.Metrics/Compono.Metrics.MeasurementVerificationBuilder_T_.AtMost(int).md b/docs/reference/api/Compono.Metrics/Compono.Metrics.MeasurementVerificationBuilder_T_.AtMost(int).md
new file mode 100644
index 00000000..ff629799
--- /dev/null
+++ b/docs/reference/api/Compono.Metrics/Compono.Metrics.MeasurementVerificationBuilder_T_.AtMost(int).md
@@ -0,0 +1,21 @@
+#### [Compono\.Metrics](index.md 'index')
+### [Compono\.Metrics](Compono.Metrics.md 'Compono\.Metrics').[MeasurementVerificationBuilder<T>](Compono.Metrics.MeasurementVerificationBuilder_T_.md 'Compono\.Metrics\.MeasurementVerificationBuilder\')
+
+## MeasurementVerificationBuilder\\.AtMost\(int\) Method
+
+Asserts the accumulated filters matched at most [times](Compono.Metrics.MeasurementVerificationBuilder_T_.AtMost(int).md#Compono.Metrics.MeasurementVerificationBuilder_T_.AtMost(int).times 'Compono\.Metrics\.MeasurementVerificationBuilder\\.AtMost\(int\)\.times') times\.
+
+```csharp
+public void AtMost(int times);
+```
+#### Parameters
+
+
+
+`times` [System\.Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32 'System\.Int32')
+
+#### Exceptions
+
+[TestDoubleVerificationException](../Compono/Compono.TestDoubleVerificationException.md 'Compono\.TestDoubleVerificationException')
+The filters matched more than
+ [times](Compono.Metrics.MeasurementVerificationBuilder_T_.AtMost(int).md#Compono.Metrics.MeasurementVerificationBuilder_T_.AtMost(int).times 'Compono\.Metrics\.MeasurementVerificationBuilder\\.AtMost\(int\)\.times') times\.
\ No newline at end of file
diff --git a/docs/reference/api/Compono.Metrics/Compono.Metrics.MeasurementVerificationBuilder_T_.Exactly(int).md b/docs/reference/api/Compono.Metrics/Compono.Metrics.MeasurementVerificationBuilder_T_.Exactly(int).md
new file mode 100644
index 00000000..30c4d9c2
--- /dev/null
+++ b/docs/reference/api/Compono.Metrics/Compono.Metrics.MeasurementVerificationBuilder_T_.Exactly(int).md
@@ -0,0 +1,21 @@
+#### [Compono\.Metrics](index.md 'index')
+### [Compono\.Metrics](Compono.Metrics.md 'Compono\.Metrics').[MeasurementVerificationBuilder<T>](Compono.Metrics.MeasurementVerificationBuilder_T_.md 'Compono\.Metrics\.MeasurementVerificationBuilder\')
+
+## MeasurementVerificationBuilder\\.Exactly\(int\) Method
+
+Asserts the accumulated filters matched exactly [times](Compono.Metrics.MeasurementVerificationBuilder_T_.Exactly(int).md#Compono.Metrics.MeasurementVerificationBuilder_T_.Exactly(int).times 'Compono\.Metrics\.MeasurementVerificationBuilder\\.Exactly\(int\)\.times') times\.
+
+```csharp
+public void Exactly(int times);
+```
+#### Parameters
+
+
+
+`times` [System\.Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32 'System\.Int32')
+
+#### Exceptions
+
+[TestDoubleVerificationException](../Compono/Compono.TestDoubleVerificationException.md 'Compono\.TestDoubleVerificationException')
+The filters did not match exactly
+ [times](Compono.Metrics.MeasurementVerificationBuilder_T_.Exactly(int).md#Compono.Metrics.MeasurementVerificationBuilder_T_.Exactly(int).times 'Compono\.Metrics\.MeasurementVerificationBuilder\\.Exactly\(int\)\.times') times\.
\ No newline at end of file
diff --git a/docs/reference/api/Compono.Metrics/Compono.Metrics.MeasurementVerificationBuilder_T_.Matching(System.Func_Compono.Metrics.CapturedMeasurement_T_,bool_).md b/docs/reference/api/Compono.Metrics/Compono.Metrics.MeasurementVerificationBuilder_T_.Matching(System.Func_Compono.Metrics.CapturedMeasurement_T_,bool_).md
new file mode 100644
index 00000000..7673b246
--- /dev/null
+++ b/docs/reference/api/Compono.Metrics/Compono.Metrics.MeasurementVerificationBuilder_T_.Matching(System.Func_Compono.Metrics.CapturedMeasurement_T_,bool_).md
@@ -0,0 +1,25 @@
+#### [Compono\.Metrics](index.md 'index')
+### [Compono\.Metrics](Compono.Metrics.md 'Compono\.Metrics').[MeasurementVerificationBuilder<T>](Compono.Metrics.MeasurementVerificationBuilder_T_.md 'Compono\.Metrics\.MeasurementVerificationBuilder\')
+
+## MeasurementVerificationBuilder\\.Matching\(Func\,bool\>\) Method
+
+Restricts matches to measurements satisfying an arbitrary [predicate](Compono.Metrics.MeasurementVerificationBuilder_T_.Matching(System.Func_Compono.Metrics.CapturedMeasurement_T_,bool_).md#Compono.Metrics.MeasurementVerificationBuilder_T_.Matching(System.Func_Compono.Metrics.CapturedMeasurement_T_,bool_).predicate 'Compono\.Metrics\.MeasurementVerificationBuilder\\.Matching\(System\.Func\,bool\>\)\.predicate') \- the
+ escape hatch for anything the named filters above don't cover \(an exact tag\-set match, a tolerance, and
+ so on\)\.
+
+```csharp
+public Compono.Metrics.MeasurementVerificationBuilder Matching(System.Func,bool> predicate);
+```
+#### Parameters
+
+
+
+`predicate` [System\.Func<](https://learn.microsoft.com/en-us/dotnet/api/system.func-2 'System\.Func\`2')[Compono\.Metrics\.CapturedMeasurement<](Compono.Metrics.CapturedMeasurement_T_.md 'Compono\.Metrics\.CapturedMeasurement\')[T](Compono.Metrics.MeasurementVerificationBuilder_T_.md#Compono.Metrics.MeasurementVerificationBuilder_T_.T 'Compono\.Metrics\.MeasurementVerificationBuilder\\.T')[>](Compono.Metrics.CapturedMeasurement_T_.md 'Compono\.Metrics\.CapturedMeasurement\')[,](https://learn.microsoft.com/en-us/dotnet/api/system.func-2 'System\.Func\`2')[System\.Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean 'System\.Boolean')[>](https://learn.microsoft.com/en-us/dotnet/api/system.func-2 'System\.Func\`2')
+
+#### Returns
+[Compono\.Metrics\.MeasurementVerificationBuilder<](Compono.Metrics.MeasurementVerificationBuilder_T_.md 'Compono\.Metrics\.MeasurementVerificationBuilder\')[T](Compono.Metrics.MeasurementVerificationBuilder_T_.md#Compono.Metrics.MeasurementVerificationBuilder_T_.T 'Compono\.Metrics\.MeasurementVerificationBuilder\\.T')[>](Compono.Metrics.MeasurementVerificationBuilder_T_.md 'Compono\.Metrics\.MeasurementVerificationBuilder\')
+
+#### Exceptions
+
+[System\.ArgumentNullException](https://learn.microsoft.com/en-us/dotnet/api/system.argumentnullexception 'System\.ArgumentNullException')
+[predicate](Compono.Metrics.MeasurementVerificationBuilder_T_.Matching(System.Func_Compono.Metrics.CapturedMeasurement_T_,bool_).md#Compono.Metrics.MeasurementVerificationBuilder_T_.Matching(System.Func_Compono.Metrics.CapturedMeasurement_T_,bool_).predicate 'Compono\.Metrics\.MeasurementVerificationBuilder\\.Matching\(System\.Func\,bool\>\)\.predicate') is [null](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/null 'https://docs\.microsoft\.com/en\-us/dotnet/csharp/language\-reference/keywords/null')\.
\ No newline at end of file
diff --git a/docs/reference/api/Compono.Metrics/Compono.Metrics.MeasurementVerificationBuilder_T_.Never().md b/docs/reference/api/Compono.Metrics/Compono.Metrics.MeasurementVerificationBuilder_T_.Never().md
new file mode 100644
index 00000000..455c5291
--- /dev/null
+++ b/docs/reference/api/Compono.Metrics/Compono.Metrics.MeasurementVerificationBuilder_T_.Never().md
@@ -0,0 +1,15 @@
+#### [Compono\.Metrics](index.md 'index')
+### [Compono\.Metrics](Compono.Metrics.md 'Compono\.Metrics').[MeasurementVerificationBuilder<T>](Compono.Metrics.MeasurementVerificationBuilder_T_.md 'Compono\.Metrics\.MeasurementVerificationBuilder\')
+
+## MeasurementVerificationBuilder\\.Never\(\) Method
+
+Asserts the accumulated filters never matched\.
+
+```csharp
+public void Never();
+```
+
+#### Exceptions
+
+[TestDoubleVerificationException](../Compono/Compono.TestDoubleVerificationException.md 'Compono\.TestDoubleVerificationException')
+The filters matched at least once\.
\ No newline at end of file
diff --git a/docs/reference/api/Compono.Metrics/Compono.Metrics.MeasurementVerificationBuilder_T_.Once().md b/docs/reference/api/Compono.Metrics/Compono.Metrics.MeasurementVerificationBuilder_T_.Once().md
new file mode 100644
index 00000000..b1bab198
--- /dev/null
+++ b/docs/reference/api/Compono.Metrics/Compono.Metrics.MeasurementVerificationBuilder_T_.Once().md
@@ -0,0 +1,15 @@
+#### [Compono\.Metrics](index.md 'index')
+### [Compono\.Metrics](Compono.Metrics.md 'Compono\.Metrics').[MeasurementVerificationBuilder<T>](Compono.Metrics.MeasurementVerificationBuilder_T_.md 'Compono\.Metrics\.MeasurementVerificationBuilder\')
+
+## MeasurementVerificationBuilder\\.Once\(\) Method
+
+Asserts the accumulated filters matched exactly once\.
+
+```csharp
+public void Once();
+```
+
+#### Exceptions
+
+[TestDoubleVerificationException](../Compono/Compono.TestDoubleVerificationException.md 'Compono\.TestDoubleVerificationException')
+The filters did not match exactly once\.
\ No newline at end of file
diff --git a/docs/reference/api/Compono.Metrics/Compono.Metrics.MeasurementVerificationBuilder_T_.WithTag(string,object).md b/docs/reference/api/Compono.Metrics/Compono.Metrics.MeasurementVerificationBuilder_T_.WithTag(string,object).md
new file mode 100644
index 00000000..1e6db5b7
--- /dev/null
+++ b/docs/reference/api/Compono.Metrics/Compono.Metrics.MeasurementVerificationBuilder_T_.WithTag(string,object).md
@@ -0,0 +1,30 @@
+#### [Compono\.Metrics](index.md 'index')
+### [Compono\.Metrics](Compono.Metrics.md 'Compono\.Metrics').[MeasurementVerificationBuilder<T>](Compono.Metrics.MeasurementVerificationBuilder_T_.md 'Compono\.Metrics\.MeasurementVerificationBuilder\')
+
+## MeasurementVerificationBuilder\\.WithTag\(string, object\) Method
+
+Restricts matches to measurements that contain a tag with key [key](Compono.Metrics.MeasurementVerificationBuilder_T_.WithTag(string,object).md#Compono.Metrics.MeasurementVerificationBuilder_T_.WithTag(string,object).key 'Compono\.Metrics\.MeasurementVerificationBuilder\\.WithTag\(string, object\)\.key') \(ordinal\)
+ whose value satisfies [System\.Object\.Equals\(System\.Object,System\.Object\)](https://learn.microsoft.com/en-us/dotnet/api/system.object.equals#system-object-equals(system-object-system-object) 'System\.Object\.Equals\(System\.Object,System\.Object\)')\. Other tags are ignored, and there is
+ no numeric coercion \(`200`, an [System\.Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32 'System\.Int32'), doesn't match `200L`\)\. Chain calls for
+ several tags\.
+
+```csharp
+public Compono.Metrics.MeasurementVerificationBuilder WithTag(string key, object? value);
+```
+#### Parameters
+
+
+
+`key` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String')
+
+
+
+`value` [System\.Object](https://learn.microsoft.com/en-us/dotnet/api/system.object 'System\.Object')
+
+#### Returns
+[Compono\.Metrics\.MeasurementVerificationBuilder<](Compono.Metrics.MeasurementVerificationBuilder_T_.md 'Compono\.Metrics\.MeasurementVerificationBuilder\')[T](Compono.Metrics.MeasurementVerificationBuilder_T_.md#Compono.Metrics.MeasurementVerificationBuilder_T_.T 'Compono\.Metrics\.MeasurementVerificationBuilder\\.T')[>](Compono.Metrics.MeasurementVerificationBuilder_T_.md 'Compono\.Metrics\.MeasurementVerificationBuilder\')
+
+#### Exceptions
+
+[System\.ArgumentNullException](https://learn.microsoft.com/en-us/dotnet/api/system.argumentnullexception 'System\.ArgumentNullException')
+[key](Compono.Metrics.MeasurementVerificationBuilder_T_.WithTag(string,object).md#Compono.Metrics.MeasurementVerificationBuilder_T_.WithTag(string,object).key 'Compono\.Metrics\.MeasurementVerificationBuilder\\.WithTag\(string, object\)\.key') is [null](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/null 'https://docs\.microsoft\.com/en\-us/dotnet/csharp/language\-reference/keywords/null')\.
\ No newline at end of file
diff --git a/docs/reference/api/Compono.Metrics/Compono.Metrics.MeasurementVerificationBuilder_T_.WithValue(T).md b/docs/reference/api/Compono.Metrics/Compono.Metrics.MeasurementVerificationBuilder_T_.WithValue(T).md
new file mode 100644
index 00000000..f95503d4
--- /dev/null
+++ b/docs/reference/api/Compono.Metrics/Compono.Metrics.MeasurementVerificationBuilder_T_.WithValue(T).md
@@ -0,0 +1,20 @@
+#### [Compono\.Metrics](index.md 'index')
+### [Compono\.Metrics](Compono.Metrics.md 'Compono\.Metrics').[MeasurementVerificationBuilder<T>](Compono.Metrics.MeasurementVerificationBuilder_T_.md 'Compono\.Metrics\.MeasurementVerificationBuilder\')
+
+## MeasurementVerificationBuilder\\.WithValue\(T\) Method
+
+Restricts matches to measurements whose value equals [value](Compono.Metrics.MeasurementVerificationBuilder_T_.WithValue(T).md#Compono.Metrics.MeasurementVerificationBuilder_T_.WithValue(T).value 'Compono\.Metrics\.MeasurementVerificationBuilder\\.WithValue\(T\)\.value') exactly, using
+ [System\.Collections\.Generic\.EqualityComparer<>\.Default](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.equalitycomparer-1.default 'System\.Collections\.Generic\.EqualityComparer\`1\.Default')\. Floating\-point equality is exact \- use
+ [Matching\(Func<CapturedMeasurement<T>,bool>\)](Compono.Metrics.MeasurementVerificationBuilder_T_.Matching(System.Func_Compono.Metrics.CapturedMeasurement_T_,bool_).md 'Compono\.Metrics\.MeasurementVerificationBuilder\\.Matching\(System\.Func\,bool\>\)') for a tolerance\.
+
+```csharp
+public Compono.Metrics.MeasurementVerificationBuilder WithValue(T value);
+```
+#### Parameters
+
+
+
+`value` [T](Compono.Metrics.MeasurementVerificationBuilder_T_.md#Compono.Metrics.MeasurementVerificationBuilder_T_.T 'Compono\.Metrics\.MeasurementVerificationBuilder\\.T')
+
+#### Returns
+[Compono\.Metrics\.MeasurementVerificationBuilder<](Compono.Metrics.MeasurementVerificationBuilder_T_.md 'Compono\.Metrics\.MeasurementVerificationBuilder\')[T](Compono.Metrics.MeasurementVerificationBuilder_T_.md#Compono.Metrics.MeasurementVerificationBuilder_T_.T 'Compono\.Metrics\.MeasurementVerificationBuilder\\.T')[>](Compono.Metrics.MeasurementVerificationBuilder_T_.md 'Compono\.Metrics\.MeasurementVerificationBuilder\')
\ No newline at end of file
diff --git a/docs/reference/api/Compono.Metrics/Compono.Metrics.MeasurementVerificationBuilder_T_.WithoutTag(string).md b/docs/reference/api/Compono.Metrics/Compono.Metrics.MeasurementVerificationBuilder_T_.WithoutTag(string).md
new file mode 100644
index 00000000..b1f333d7
--- /dev/null
+++ b/docs/reference/api/Compono.Metrics/Compono.Metrics.MeasurementVerificationBuilder_T_.WithoutTag(string).md
@@ -0,0 +1,23 @@
+#### [Compono\.Metrics](index.md 'index')
+### [Compono\.Metrics](Compono.Metrics.md 'Compono\.Metrics').[MeasurementVerificationBuilder<T>](Compono.Metrics.MeasurementVerificationBuilder_T_.md 'Compono\.Metrics\.MeasurementVerificationBuilder\')
+
+## MeasurementVerificationBuilder\\.WithoutTag\(string\) Method
+
+Restricts matches to measurements that have no tag with key [key](Compono.Metrics.MeasurementVerificationBuilder_T_.WithoutTag(string).md#Compono.Metrics.MeasurementVerificationBuilder_T_.WithoutTag(string).key 'Compono\.Metrics\.MeasurementVerificationBuilder\\.WithoutTag\(string\)\.key') \(ordinal\)\.
+
+```csharp
+public Compono.Metrics.MeasurementVerificationBuilder WithoutTag(string key);
+```
+#### Parameters
+
+
+
+`key` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String')
+
+#### Returns
+[Compono\.Metrics\.MeasurementVerificationBuilder<](Compono.Metrics.MeasurementVerificationBuilder_T_.md 'Compono\.Metrics\.MeasurementVerificationBuilder\')[T](Compono.Metrics.MeasurementVerificationBuilder_T_.md#Compono.Metrics.MeasurementVerificationBuilder_T_.T 'Compono\.Metrics\.MeasurementVerificationBuilder\\.T')[>](Compono.Metrics.MeasurementVerificationBuilder_T_.md 'Compono\.Metrics\.MeasurementVerificationBuilder\')
+
+#### Exceptions
+
+[System\.ArgumentNullException](https://learn.microsoft.com/en-us/dotnet/api/system.argumentnullexception 'System\.ArgumentNullException')
+[key](Compono.Metrics.MeasurementVerificationBuilder_T_.WithoutTag(string).md#Compono.Metrics.MeasurementVerificationBuilder_T_.WithoutTag(string).key 'Compono\.Metrics\.MeasurementVerificationBuilder\\.WithoutTag\(string\)\.key') is [null](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/null 'https://docs\.microsoft\.com/en\-us/dotnet/csharp/language\-reference/keywords/null')\.
\ No newline at end of file
diff --git a/docs/reference/api/Compono.Metrics/Compono.Metrics.MeasurementVerificationBuilder_T_.md b/docs/reference/api/Compono.Metrics/Compono.Metrics.MeasurementVerificationBuilder_T_.md
new file mode 100644
index 00000000..8e0c8f60
--- /dev/null
+++ b/docs/reference/api/Compono.Metrics/Compono.Metrics.MeasurementVerificationBuilder_T_.md
@@ -0,0 +1,37 @@
+#### [Compono\.Metrics](index.md 'index')
+### [Compono\.Metrics](Compono.Metrics.md 'Compono\.Metrics')
+
+## MeasurementVerificationBuilder\