apple / swift-metrics

Metrics API for Swift
https://apple.github.io/swift-metrics/
Apache License 2.0
650 stars 61 forks source link

MetricsTestKit: expose all metrics publicly. This allows users to run checks on counters when they might not know the exact label #127

Closed hamzahrmalik closed 1 year ago

hamzahrmalik commented 1 year ago

Provide functions on TestMetrics to retrieve all counters/timers/recorders

Motivation:

Users may want to iterate over metrics to perform some complex assertions. For example, they might want to confirm that no metrics have been emitted with a certain dimension

Modifications:

Added functions for allRecorders, allTimers and allCounters which return arrays of TestRecorder, TestTimer and TestCounter

ktoso commented 1 year ago

@swift-server-bot add to allowlist

ktoso commented 1 year ago

This has a merge conflict now due to the introduced meters on main, could you rebase @hamzahrmalik ?

Otherwise LGTM so let's merge this and the follow up which adds tests to this 👍

hamzahrmalik commented 1 year ago

This has a merge conflict now due to the introduced meters on main, could you rebase @hamzahrmalik ?

Otherwise LGTM so let's merge this and the follow up which adds tests to this 👍

I actually think we should merge #128 first That one is simply a refactor, and will make this one very simple (just adding public modifiers)

ktoso commented 1 year ago

Yeah that works, merged #128 👍

ktoso commented 1 year ago

LGTM thanks!