Skip to content
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

Use two separate methods for updating storage/distributor metrics #13

Open
daniil-berg opened this issue Sep 13, 2024 · 0 comments
Open
Assignees
Labels
refactoring Non-breaking changes that improve maintainability or readability typing Enhancing type safety of existing functions/classes

Comments

@daniil-berg
Copy link
Contributor

Currently the Monitoring._update_metrics method handles both StorageStatus and DistributorStatus arguments and simply swallows AttributeErrors, assuming that metric labels and status object type match.

def _update_metrics(self, status_obj: Union[StorageStatus, DistributorStatus], *labels: str) -> None:
for name, (metric, get_value) in self.metrics.items():
try:
val = get_value(status_obj) if get_value else getattr(status_obj, name)
except AttributeError:
pass # some metrics apply exclusively to the storage node or a distributor, but not both
else:
metric.labels(*labels).set(val or 0)

This should be made more type safe/robust, by having distinct methods for storage vs. distributor metrics.

@daniil-berg daniil-berg self-assigned this Sep 13, 2024
@daniil-berg daniil-berg added typing Enhancing type safety of existing functions/classes refactoring Non-breaking changes that improve maintainability or readability labels Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring Non-breaking changes that improve maintainability or readability typing Enhancing type safety of existing functions/classes
Projects
None yet
Development

No branches or pull requests

1 participant