Skip to content

Allow passing labels in new/4, add format/2 #12

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

Closed
wants to merge 15 commits into from

Conversation

the-mikedavis
Copy link
Contributor

These are some changes to make it easier to expose metrics stored in seshat via prometheus. Two changes:

  • Allow attaching an extra label() :: term() in a new seshat:new/4 function. This is exposed in seshat:format/1 as the key of the values map. We can use this in RabbitMQ to attach the queue resource for a QQ to its counter so that we can switch from reading out of the ra_metrics ETS table to using Ra counters. seshat:new/3 uses the Name as the label which means there's no change in behavior for callers using seshat:new/3.
  • Add a seshat:format/2 function to format metrics for only one member of a group. We can use this in RabbitMQ to read and expose Khepri's metrics without scanning the whole ETS table for the ra group.

@the-mikedavis the-mikedavis force-pushed the md/extras-for-prometheus branch from 9d6e984 to ae9f1a1 Compare September 3, 2024 16:28
@the-mikedavis the-mikedavis force-pushed the md/extras-for-prometheus branch from ae9f1a1 to 2b09eab Compare September 4, 2024 20:30
@mkuratczyk mkuratczyk force-pushed the md/extras-for-prometheus branch from 2b09eab to d1dc676 Compare February 24, 2025 14:08
@mkuratczyk mkuratczyk force-pushed the md/extras-for-prometheus branch 11 times, most recently from c05be20 to 72b907c Compare March 7, 2025 17:18
@mkuratczyk mkuratczyk force-pushed the md/extras-for-prometheus branch from 72b907c to 85f6091 Compare March 12, 2025 11:37
@mkuratczyk mkuratczyk force-pushed the md/extras-for-prometheus branch 2 times, most recently from 785161d to a4ddeea Compare April 22, 2025 08:23
the-mikedavis and others added 10 commits April 22, 2025 10:37
Currently the extra info is only returned by `seshat:format/1`: it's
useful to attach information you might use for Prometheus labels.
Previously we used the counter's name as passed to `seshat:new/3` in
the place of this label.

Attaching extra info is useful for QQs in RabbitMQ for example. They
need to attach the queue name and vhost so that info can be exposed to
Prometheus.
This will be useful in RabbitMQ to expose Khepri metrics for example:
we want to select just Khepri's metrics out of the `ra` group.
A metrics without labels has a name which could
be used as the label value, but it's not clear
what label key should be in this case.
For example, if a metric is declared like this:
    seshat:new(Group, ghost, [{foo, 1, counter, "Total foos given"}]),
then what it'd look like in the Prometheus endpoint?
```
foo{...="ghost"} N
```
Rename things to more resemble how Seshat is used
in real life.
Refactor to make variable names consistent:

* Name sometimes referred to the metric name, and sometimes to the
  object emiting the metrics; going forward, it's either Id (object) or
  Name (metric)
* counter index was sometimes referred to as Position (now, always Index)
* metric help was sometiems referred to as Description (now, always
  Help)
* Fields/FieldSpec/FieldName were used inconsistently (because Fields
  and FieldSpec can be the same thing); hopefully it's more clear now
* counter referece was sometimes Ref and sometimes CRef (now, always
  CRef)
seshat:text_format/3 produces a binary that contains the text
representation of the metrics in the Prometheus exposition format,
so that it can be returned as-is by a Prometheus endpoint
@mkuratczyk mkuratczyk force-pushed the md/extras-for-prometheus branch from c521040 to 0b08222 Compare April 22, 2025 08:46
@mkuratczyk mkuratczyk force-pushed the md/extras-for-prometheus branch from 0b08222 to 98da67c Compare April 22, 2025 08:51
@kjnilsson kjnilsson self-requested a review May 7, 2025 07:59
@mkuratczyk
Copy link
Contributor

Given how much this PR has evolved (barely matches this description), closing this PR. A new one is coming soon

@mkuratczyk mkuratczyk closed this May 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants