Skip to content
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

Refactor and extend the interface for metrics with configurable labels #1548

Merged
merged 3 commits into from
Oct 13, 2023

Conversation

lambdanis
Copy link
Contributor

@lambdanis lambdanis commented Oct 3, 2023

See commits for details.

Expose an interface for defining metrics with configurable labels.

@lambdanis lambdanis added area/metrics Related to prometheus metrics release-note/minor This PR introduces a minor user-visible change labels Oct 3, 2023
@lambdanis lambdanis requested a review from a team as a code owner October 3, 2023 10:36
@lambdanis lambdanis force-pushed the pr/lambdanis/metrics-api branch 3 times, most recently from e4a96e9 to 4b4010f Compare October 3, 2023 13:32
This is a non-functional change, only reorganising code for easier development.

Signed-off-by: Anna Kapuscinska <[email protected]>
This commit chnanges the logic behind counters with configurable labels. It
introduces a new type, labelFilter, which defines the known and enabled labels.
The labelFilter is included in the granularCounter type, which exposes filter
and mustFilter methods. With this approach, the label filtering doesn't rely on
the global config option. Additionally, granularCounter exposes WithLabelValues
method, so that metric updates can be done with the same interface as for
prometheus CounterVec.

Technically it is a breaking change, but only developer facing.

Signed-off-by: Anna Kapuscinska <[email protected]>
@kkourt kkourt merged commit c0fb1d3 into cilium:main Oct 13, 2023
27 checks passed
"github.com/cilium/tetragon/pkg/metrics/consts"
"github.com/cilium/tetragon/pkg/option"
"github.com/prometheus/client_golang/prometheus"
"golang.org/x/exp/slices"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey @lambdanis I think you reintroduced golang.org/x/exp/slices here, I don't know if it's intended since you removed that #1560.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just rebased one of my PR and noticed that go.mod needed to include the new dependency.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really don't understand how the tests pass here and not on my rebased PR... https://github.com/cilium/tetragon/actions/runs/6508448671/job/17677830078?pr=1562#step:5:610

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the tests passed on this PR a while ago, before some deps got updated?
Anyway, thanks for fixing this import.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/metrics Related to prometheus metrics release-note/minor This PR introduces a minor user-visible change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants