-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add entra ID metrics #60537
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
Merged
Merged
Add entra ID metrics #60537
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| /* | ||
| * Teleport | ||
| * Copyright (C) 2025 Gravitational, Inc. | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU Affero General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU Affero General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Affero General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| package msgraph | ||
|
|
||
| import ( | ||
| "github.com/gravitational/trace" | ||
| "github.com/prometheus/client_golang/prometheus" | ||
|
|
||
| "github.com/gravitational/teleport" | ||
| ) | ||
|
|
||
| type clientMetrics struct { | ||
| // requestsTotal keeps track of the number of requests done by the client | ||
| // This metric is labeled by status code. | ||
| requestTotal *prometheus.CounterVec | ||
| // requestDuration keeps track of the request duration, in seconds. | ||
| requestDuration *prometheus.HistogramVec | ||
| } | ||
|
|
||
| const ( | ||
| metricSubsystem = "msgraph" | ||
| metricsLabelStatus = "status" | ||
| metricsLabelsMethod = "method" | ||
| ) | ||
|
|
||
| func newMetrics() *clientMetrics { | ||
| return &clientMetrics{ | ||
| requestTotal: prometheus.NewCounterVec(prometheus.CounterOpts{ | ||
| Namespace: teleport.MetricNamespace, | ||
| Subsystem: metricSubsystem, | ||
| Name: "request_total", | ||
| Help: "Total number of requests made to MS Graph", | ||
| }, []string{metricsLabelsMethod, metricsLabelStatus}), | ||
| requestDuration: prometheus.NewHistogramVec(prometheus.HistogramOpts{ | ||
| Namespace: teleport.MetricNamespace, | ||
| Subsystem: metricSubsystem, | ||
| Name: "request_duration_seconds", | ||
| Help: "Request to MS Graph duration in seconds.", | ||
| }, []string{metricsLabelsMethod}), | ||
| } | ||
| } | ||
|
|
||
| func (metrics *clientMetrics) register(r prometheus.Registerer) error { | ||
| return trace.NewAggregate( | ||
| r.Register(metrics.requestTotal), | ||
| r.Register(metrics.requestDuration), | ||
| ) | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
This will not scale in long run - we will keep implementing third party api SDK metrics for each external client. So each SDK will have custom metrics implemented in different way - But it it better than not having metric at all.
If we have a moment I would like to consider building generic third party API metrics in generic way:
#40579
But I don't see this as a blocker for this PR, but if possible we can wrap up #40579 and have a generic metrics arch shared across very SDK client.
WDYT ?
Uh oh!
There was an error while loading. Please reload this page.
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 considered doing this but this raises the problem of cardinality. We need some way to mask variable parts of the URI. We have a similar problem in the backend with our metrics and we have not solved it yet. I wanted to get metrics without refactoring the whole client to add a new
endpointstruct containing both the endpoint parts and the metrics maskThere 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.
My vote would be to start simple and iterate. The generic approach sounds nice at first, but adds a number of complexities that we don't need to solve today.