-
Notifications
You must be signed in to change notification settings - Fork 179
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
actually describe PrometheusSink descriptors #129
Conversation
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.
Generally looks good. My biggest concern is any back compatibility issues, but this looks pretty safe.
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.
I am not all that familiar with these Prometheus interfaces, so I was reading over https://pkg.go.dev/github.com/prometheus/[email protected]/prometheus#Collector, specifically the docs for Describe
, and I noticed this:
This method idempotently sends the same descriptors throughout the lifetime of the Collector
I'm not sure if I am interpreting this correctly, but I think that might suggest a problem with this implementation. We will still have some ephemeral metrics that are not registered when the process starts. When those metrics are emitted our Describe
method will start returning different descriptions. I'm not sure what problem that will cause, but it seems like the implementation in this PR might violate that requirement.
I have another idea for how we might be able to solve this issue, I'll comment in the linked Consul issue to see if that might work or not.
Yes, that's spot on -- thanks for the call out! So funcs like:
store metrics outside of the respective I'm interpreting this behavior in two ways:
or
Pragmatic HatAs far as I can see, we only really care about Maybe then we could go with @markan's suggestion and just rely on the
or something else that uniquely identifies the |
My read of the Prometheus docs aligns with Daniels. It would seem their expectations around Does the alternate solution posed elsewhere of having a separate The Registry docs say: // Register registers a new Collector to be included in metrics
// collection. It returns an error if the descriptors provided by the
// Collector are invalid or if they — in combination with descriptors of
// already registered Collectors — do not fulfil the consistency and
// uniqueness criteria described in the documentation of metric.Desc. Which to me implies that the library expects all collectors within one registry to be "consistent" that is not emit the same metric from multiple places, while multiple custom Since the Registerer can already be passed in to the Prometheus sink , I think it's already possible to solve this in the calling code. If the boilerplate for doing that is significant and we think it's a pattern other users of this library are likely to need too, it may be worth adding a helper here that makes creating a new instance of the sink with a custom registerer simpler? |
Signed-off-by: FFMMM <[email protected]>
06ef1a3
to
d847a29
Compare
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.
Nice, LGTM! Just one small style recommendation
Co-authored-by: Daniel Nephin <[email protected]>
Overview
Stumbled across this as I was trying to instantiate two
TestAgent
s in consul. See hashicorp/consul#11273 for more context around that papercut.It all comes down to registering more than on PrometheusSink on a registerer.
Today, that's not possible since we
don't actually implementsend the same descriptor regardless of the sink being used..Describe()
.This approach runs over all the gauges, summaries and counters and sends.Desc()
to the chan.It also adds a "dummy" value to register "empty" sinks but it relies on a new field:PrometheusSink.name
.This approach introduces a new field,
PrometheusSink.name
, and creates a descriptor around it in order to avoid "collisions" with otherPrometheusSink
s.Testing
Related Issues