swift-prometheus icon indicating copy to clipboard operation
swift-prometheus copied to clipboard

refactor(API): deprecate non-descriptor metric creation methods

Open incertum opened this issue 1 month ago • 7 comments

Deprecates all metric creation methods that accept loose string parameters for name and help text.

This standardizes metric creation on the MetricNameDescriptor type, which requires a metricName, unitName and helpText for all metrics. This improves compliance with official Prometheus client library guidelines ("A MetricFamily MUST have a name, HELP, TYPE, and UNIT metadata.").

The deprecated methods will be removed in a future major version (see https://github.com/swift-server/swift-prometheus/issues/145).

CC @ktoso, thank you!

incertum avatar Oct 14 '25 19:10 incertum

Additional note: We should avoid redirecting to the public APIs that have now been marked as deprecated. I wanted to first ask for your opinion on this @ktoso . Happy to make these additional changes.

incertum avatar Oct 15 '25 21:10 incertum

Additional note: We should avoid redirecting to the public APIs that have now been marked as deprecated. I wanted to first ask for your opinion on this @ktoso . Happy to make these additional changes.

I've pushed a suggestion.

incertum avatar Oct 21 '25 00:10 incertum

Please re re-review the latest minor fixes re CI failures, thanks! @FranzBusch @ktoso

incertum avatar Oct 27 '25 21:10 incertum

Can we avoid removing the warnings as errors setting? Are the deprecation warnings in the tests? If so you an mark the tests as deprecated which will silence those warnings.

FranzBusch avatar Oct 28 '25 10:10 FranzBusch

Can we avoid removing the warnings as errors setting? Are the deprecation warnings in the tests? If so you an mark the tests as deprecated which will silence those warnings.

While it silenced it locally swift test -Xswiftc -warnings-as-errors 2 CI tests are now again erroring out.

incertum avatar Oct 28 '25 22:10 incertum

While it silenced it locally swift test -Xswiftc -warnings-as-errors 2 CI tests are now again erroring out.

It looks like only 5.10 and 6.0 are producing these warnings. Can we instead disable warnings-as-errors on just those versions. FWIW, we should also drop support for 5.10.

FranzBusch avatar Oct 29 '25 11:10 FranzBusch

While it silenced it locally swift test -Xswiftc -warnings-as-errors 2 CI tests are now again erroring out.

It looks like only 5.10 and 6.0 are producing these warnings. Can we instead disable warnings-as-errors on just those versions. FWIW, we should also drop support for 5.10.

I have updated the override matrix (it wasn't yet configured for 6.0 and 6.1). It turns out that while having -Xswiftc -warnings-as-errors works on a macOS it appears just not to work the "same way" on these Linux runners.

I would propose to defer this and unblock this PR for now.

incertum avatar Oct 29 '25 16:10 incertum

I'll go ahead and merge this. If we believe that additional refinements are beneficial, we can open a follow-up PR.

incertum avatar Nov 04 '25 21:11 incertum