-
Notifications
You must be signed in to change notification settings - Fork 842
Use specific exception for duplicate timeseries#1074
Use specific exception for duplicate timeseries #1074kajinamit wants to merge 1 commit intoprometheus:master from
Conversation
6e89bc8 to
c9a7636
Compare
@csmarchbanks
csmarchbanks
left a comment
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.
Just curious what you would do when you encounter a duplicate name vs a different ValueError? I am not opposed to this if it is helpful but would like to understand as well/not encourage bad practices.
c9a7636 to
858d79a
Compare
Just curious what you would do when you encounter a duplicate name vs a different ValueError? I am not opposed to this if it is helpful but would like to understand as well/not encourage bad practices.
We are currently using this client to export metrics of virtual machines running on a specific hypervisor. In this use case we have to register metrics dynamically, because virtual machines might be created/deleted/moved anytime. To achieve the dynamic detection, we check all virtual machines in a host and register metrics for them periodically, but we can't safely check if the virtual machine metrics were registered in the previous cycle without this. (For now we inspect _names_to_collectors before calling register but that's requires external access to a private item, which I want to get rid of)
Use sub-class of ValueError instead of ValueError, so that we can distinguish issues caused by wrong input (like invalid name format) from duplicate metrics being registered into the same registry. Signed-off-by: Takashi Kajinami <kajinamit@oss.nttdata.com>
858d79a to
26c0fca
Compare
Use sub-class of ValueError instead of ValueError, so that we can distinguish issues caused by wrong input (like invalid name format) from duplicate metrics being registered into the same registry.