Skip to content

[v18] Backport metrics.Registry and entra metrics#61696

Merged
hugoShaka merged 8 commits intobranch/v18from
hugo/backport-metrics
Nov 24, 2025
Merged

[v18] Backport metrics.Registry and entra metrics#61696
hugoShaka merged 8 commits intobranch/v18from
hugo/backport-metrics

Conversation

hugoShaka and others added 7 commits November 21, 2025 16:39
* Add entra ID metrics

This commit adds metrics for entra ID sync. This is the OSS part, it
contains the msgraph client metrics.

As many different parts of Teleport are using the msgraph client and
might not have access to a metric registerer yet, the client gracefully
handles not being given a metric registry. In this case it won't
register its metrics, we don't want to continue polluting the global
metrics registry.

* lint
* test setting a non-nil registry in config

* expose teleport process metric registry

* remove metric config

* fixup! remove metric config
* Add support in process for additional metrics gatherers

Before this change, we were gathering from 2 metrics gatherers:
- the process registry
- the global registry

There are cases where we must add and remove metrics (e.g. plugins).
We could throw them into the global registry but:
- this would pollute the global registry and cause duplicates/conflicts
  in tests
- this would conflate all metrics from the same plugin kind. We support
  several instances of the same hosted plugin and we might want to
  keep distinct metrics.

This change makes the gatherers a list, and add a function so teleport.e
can add its own gatherer. A teleport.e PR using this mechanism will
follow.

* Protect gatherer slice with a mutex
When implementing reconciler metrics in #60581
I did not realize some GenericReconciler usage, including the one I
wanted to observe, were short-lived. The implementation had 2 blatant
issues:
- metrics were lost for each invocations
- creating a new reonciler would attempt to register the metric a second
  time and cause a conflict

This PR changes the reconciler metrics API so the caller is responsible
for creating and registering the metrics beforehand. This allows the
caller to create the metric struct once and pass them to successive
`NewGenericReconciler` calls.
* Introduce metrics.Registry and use it

* Update lib/metrics/registry.go

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>

* BlackHole -> BlackHoleRegistry

* merge lib/metrics and lib/observability/metrics

* lint

* address noah's feedback

---------

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>
* handle empty subsystems properly

* appeasing our italian engineering team
@hugoShaka hugoShaka added the no-changelog Indicates that a PR does not require a changelog entry label Nov 21, 2025
@hugoShaka hugoShaka enabled auto-merge November 24, 2025 14:42
@hugoShaka hugoShaka added this pull request to the merge queue Nov 24, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 24, 2025
@hugoShaka hugoShaka added this pull request to the merge queue Nov 24, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 24, 2025
@hugoShaka hugoShaka added this pull request to the merge queue Nov 24, 2025
Merged via the queue into branch/v18 with commit e632768 Nov 24, 2025
40 of 41 checks passed
@hugoShaka hugoShaka deleted the hugo/backport-metrics branch November 24, 2025 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport machine-id no-changelog Indicates that a PR does not require a changelog entry size/md

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants