Maybe I'm going about this the wrong way, but I'd like to create dynamic gauges for users logged in to a system and the gauge will track the active jobs they are running. I think I would do this with something like the following:
USER_GAUGES = {}
def update_user_gauges():
for user, active_jobs in data_structure.items():
g = USER_GAUGES.set_default(user, Gauge(f"namespace_{user}_current_jobs"))
g.set(active_jobs)
And then I would like register update_user_gauges to get called when a scrape is about to happen (similar to doing Guage.set_function(callable)).
Is there a way to do this? Or am I going about this the wrong way and there is a better approach?
Thanks!