-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
[TestAgent] [Telemetry] cannot "instantiate" multiple agents with prometheus telemetry on #11273
Comments
Our |
Yes! That's certainly a great way to "own our destiny" (from the consul side). I'm not too sure if the trade offs of writing a custom And even if it ends up being the "easier" changes, I think it's not as elegant as fixing this in Open to more debate here, of course! |
So I was playing around with the ergonomics of using
Unfortunately, while we can create multiple
IMO, even if we disregard the issue above (or pretend that I missed something obvious), I do believe that it makes for odd ergonomics to expose "prometheus things" outside of go-metrics. So I was going to re-work hashicorp/go-metrics#129 to make the |
I'm gonna There's probably still more to do regarding:
but I'm gonna go out on a limb and say that "unregister"-ing/ cleanup should be mostly done by go-metrics (the underlying abstraction). If there are needs to do it in the agent, we can revisit this issue. |
Overview
We leverage a
TestAgent
type to stand up agents in our unit tests. In init-ing aTestAgent
and managing its lifecycle, we use a mix of internal APIs and testing functions.When it comes to telemetry set up,
TestAgent
calls onInitTelemetry()
.Multiple
TestAgent
s with Prometheus metrics turned on cannot come up due to the underlying registration process.Current Behavior
-->
: testagent.go:106: failed to create base deps: failed to initialize telemetry: duplicate metrics collector registration attempted
This is still a working theory but, it seems that because we configure the same gauges, counters and summaries, we essentially make the same collector hash and trigger the underlying error in the registration process:
https://github.com/prometheus/client_golang/blob/master/prometheus/registry.go#L331-L344
Or see[1] for a related possible root cause.
Desired Behavior
I want us to be able to instantiate multiple agents with telemetry (whether prometheus or not) turned on.
Proposed Fix
IMO, we need to do the following:
go-metrics
needs to expose the functionality to "unregister" a prom sink.Misc
[1]: If the above statement is true
the same gauges, counters and summaries, we essentially make the same collector
, then I was expecting that prefixing the metrics with a different string to work. But this code snipped fails in the same way as well:I think if we actually look at the
PrometheusSink
implementation ingo-metrics
theDescribe()
calls may actually cause the collisions. So it may well be that by actually describing the gauges, counters, summaries there that we could "fix" this problem.The text was updated successfully, but these errors were encountered: