-
Notifications
You must be signed in to change notification settings - Fork 39
Remove labels parametrisation #63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove labels parametrisation #63
Conversation
…els parametrisation
cc @tomerd |
Hi @MrLotU! Thanks for considering this PR. This PR has a few assumptions in mind, just wanted to check if I got the idea right. I keep looking at the library performance and the biggest culprit for metric emission flow is virtual table lookups when figuring out parametrisation on PromMetric types. Since |
|
||
self.quantiles = quantiles | ||
|
||
self.labels = labels |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parent Summary was always created with empty labels. subHistogram labels were stored twice: as a key in subSummaries
and as a field in corresponding subSummary
value. I just removed the duplication.
Hey @avolokhov, Thanks for your PR, and my apologies it took me so long to respond to it. Your point about performance makes a lot of sense, and I agree there will probably not be many people interacting with the current label structs directly, and I also see no reason people would not be able to move to the new dimension based approach. I've added 2 (minor) commits to your PR, mostly addressing documentation & examples, but also changing somefunctional aspects:
Please let me know what you think! |
Perfect, thanks for the cleanup, @MrLotU. Sorry I was careless about the documentation. |
* Sanitize Dimensions (#68) * Add failing test for sanitising dimension * Fix test * Add new DimensionsSanitizer * Remove labels parametrisation (#63) * Stop leaking 'le', 'quantile' in Summary/Histogram labels, remove labels parametrisation * chore: Remove base labels protocol and add ExpressibleByArrayLiteral * chore: Cleanup documentation. Remove deprecations Co-authored-by: Jari (LotU) <[email protected]> * Add async/await APIs (#67) * Add async/await APIs * Revert unrelated change * Add #if swift for 5.2 * Fix Swift version number check * Add task API Co-authored-by: Tim Condon <[email protected]> Co-authored-by: Anton <[email protected]>
This PR removes labels parametrisation which fixes a leaking bucket/quantile serialisation detail that may have led to a problem if quantile/bucket is unintentionally set from the outside code as well as optimises metric emission performance.
This is a breaking change since custom labels will not be supported any more, however there's an argument that labels are indeed just a list of key value pairs, any customisation on top of it can as well be done as a wrapper to
PrometheusClient
. The part of the api that serves asswift-metrics
backend remained fully compatible.Checklist
Motivation and Context
PrometheusClient
api surface, removing unnecessary overloadsDescription
This PR brings a few optimisations to how SwiftPrometheus handle labels:
le
in DimensionHistogramLabels andquantile
in DimensionSummaryLabels: these fields were never supposed to be set and are never used in an actual computations. In this PR I leveraged the fact that these fields are only used during serialisation and made correspondingEncodableDimensions-
types internal. This allowed me to make all metric types to accept plainDimensionLabels
, which resulted in less code and less fluffyPrometheusClient
api. From the performance point of view this change is beneficial because it removes a generic and reduces a number of virtual lookups on metric emission flow.