One of the benefits of swift-metrics being an API-only package is that it doesn't contain anything you don't need. The drawback being that it may not contain some of the things you do want!
As such I'd like to pitch a small package containing a set of tools related to
- Logging factory: a
MetricsFactorywhich logs any changes to the underlying instruments. Logging would be limited to
- Delegating factory:
MetricsFactorywhich delegates to a "current" factory. Since it is only possible to bootstrap the metrics system once per process (testable imports aside) it makes testing more difficult as noted in https://github.com/apple/swift-metrics/issues/60. The factory would be a singleton which would delegate to a swappable, user-provided factory. It would also have to keep track of where each instrument originates in order to correctly
destroythem. This would allow the factory to be swapped out depending on test requirements. It could also handle the awkwardness of installing itself since the user would otherwise have to do keep track of this in tests.
- Capture factory: a
MetricsFactorywhich records structured events in a way that is suitable for testing. The rough idea being "I executed this code path and I want to check that this counter was incremented by this value and has this label and these dimensions". This requires some more exploration as to what shape this would take to be maximally useful here.
I'm curious as to whether the community thinks there's enough value in having a such a package, whether the proposed tools would be useful, and if there are any other suggestions for factories or otherwise which could be included here.