[
https://issues.apache.org/jira/browse/YUNIKORN-2210?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Peter Bacsko resolved YUNIKORN-2210.
------------------------------------
Fix Version/s: 1.5.0
Resolution: Fixed
> Metrics: use WithLabelValues instead of With
> ---------------------------------------------
>
> Key: YUNIKORN-2210
> URL: https://issues.apache.org/jira/browse/YUNIKORN-2210
> Project: Apache YuniKorn
> Issue Type: Sub-task
> Components: core - scheduler
> Reporter: Peter Bacsko
> Assignee: Peter Bacsko
> Priority: Major
> Labels: pull-request-available
> Fix For: 1.5.0
>
>
> In the metrics codebase, we use labels to specify the counters/gauges:
> {noformat}
> m.appMetricsLabel.With(prometheus.Labels{"state": state}).Dec()
> m.appMetricsSubsystem.With(prometheus.Labels{"state": state}).Dec()
> m.resourceMetricsLabel.With(prometheus.Labels{"state": state, "resource":
> resourceName}).Set(value)
> m.resourceMetricsSubsystem.With(prometheus.Labels{"state": state, "resource":
> resourceName}).Set(value)
> {noformat}
> However, {{prometheus.Labels}} is a {{map[string]string}}, so we always
> create a map. This is completely unnecessary and has measurable performance
> impact. Nothing serious, but visible.
> The following achieves the same, so we can save some memory:
> {noformat}
> m.appMetricsLabel.WithLabelValues(state).Dec()
> m.appMetricsSubsystem.WithLabelValues(state).Dec()
> m.resourceMetricsLabel.WithLabelValues(state, resourceName).Set(value)
> m.resourceMetricsSubsystem.WithLabelValues(state, resourceName).Set(value)
> {noformat}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]