- Notifications
You must be signed in to change notification settings - Fork927
chore: deprecate gauge metrics with _total suffix (#12744)#12976
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
3 commits Select commitHold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
17 changes: 16 additions & 1 deletioncoderd/prometheusmetrics/prometheusmetrics.go
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 |
---|---|---|
@@ -79,10 +79,23 @@ func Workspaces(ctx context.Context, logger slog.Logger, registerer prometheus.R | ||
duration = defaultRefreshRate | ||
} | ||
// TODO: deprecated: remove in the future | ||
snark87 marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
// See: https://github.com/coder/coder/issues/12999 | ||
// Deprecation reason: gauge metrics should avoid suffix `_total`` | ||
workspaceLatestBuildTotalsDeprecated := prometheus.NewGaugeVec(prometheus.GaugeOpts{ | ||
Namespace: "coderd", | ||
Subsystem: "api", | ||
Name: "workspace_latest_build_total", | ||
Help: "DEPRECATED: use coderd_api_workspace_latest_build instead", | ||
}, []string{"status"}) | ||
if err := registerer.Register(workspaceLatestBuildTotalsDeprecated); err != nil { | ||
return nil, err | ||
} | ||
workspaceLatestBuildTotals := prometheus.NewGaugeVec(prometheus.GaugeOpts{ | ||
Namespace: "coderd", | ||
Subsystem: "api", | ||
Name: "workspace_latest_build", | ||
Help: "The current number of workspace builds by status.", | ||
}, []string{"status"}) | ||
if err := registerer.Register(workspaceLatestBuildTotals); err != nil { | ||
@@ -131,6 +144,8 @@ func Workspaces(ctx context.Context, logger slog.Logger, registerer prometheus.R | ||
for _, job := range jobs { | ||
status := codersdk.ProvisionerJobStatus(job.JobStatus) | ||
workspaceLatestBuildTotals.WithLabelValues(string(status)).Add(1) | ||
// TODO: deprecated: remove in the future | ||
workspaceLatestBuildTotalsDeprecated.WithLabelValues(string(status)).Add(1) | ||
} | ||
} | ||
2 changes: 1 addition & 1 deletioncoderd/prometheusmetrics/prometheusmetrics_test.go
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
24 changes: 20 additions & 4 deletionscoderd/promoauth/oauth2.go
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 |
---|---|---|
@@ -62,9 +62,11 @@ type metrics struct { | ||
// if the oauth supports it, rate limit metrics. | ||
// rateLimit is the defined limit per interval | ||
rateLimit *prometheus.GaugeVec | ||
// TODO: remove deprecated metrics in the future release | ||
rateLimitDeprecated *prometheus.GaugeVec | ||
rateLimitRemaining *prometheus.GaugeVec | ||
rateLimitUsed *prometheus.GaugeVec | ||
// rateLimitReset is unix time of the next interval (when the rate limit resets). | ||
rateLimitReset *prometheus.GaugeVec | ||
// rateLimitResetIn is the time in seconds until the rate limit resets. | ||
@@ -91,14 +93,26 @@ func NewFactory(registry prometheus.Registerer) *Factory { | ||
rateLimit: factory.NewGaugeVec(prometheus.GaugeOpts{ | ||
Namespace: "coderd", | ||
Subsystem: "oauth2", | ||
Name: "external_requests_rate_limit", | ||
Help: "The total number of allowed requests per interval.", | ||
}, []string{ | ||
"name", | ||
// Resource allows different rate limits for the same oauth2 provider. | ||
// Some IDPs have different buckets for different rate limits. | ||
"resource", | ||
}), | ||
// TODO: deprecated: remove in the future | ||
snark87 marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
// See: https://github.com/coder/coder/issues/12999 | ||
// Deprecation reason: gauge metrics should avoid suffix `_total`` | ||
rateLimitDeprecated: factory.NewGaugeVec(prometheus.GaugeOpts{ | ||
Namespace: "coderd", | ||
Subsystem: "oauth2", | ||
Name: "external_requests_rate_limit_total", | ||
Help: "DEPRECATED: use coderd_oauth2_external_requests_rate_limit instead", | ||
}, []string{ | ||
"name", | ||
"resource", | ||
}), | ||
rateLimitRemaining: factory.NewGaugeVec(prometheus.GaugeOpts{ | ||
Namespace: "coderd", | ||
Subsystem: "oauth2", | ||
@@ -176,6 +190,8 @@ func (f *Factory) NewGithub(name string, under OAuth2Config) *Config { | ||
} | ||
} | ||
// TODO: remove this metric in v3 | ||
f.metrics.rateLimitDeprecated.With(labels).Set(float64(limits.Limit)) | ||
f.metrics.rateLimit.With(labels).Set(float64(limits.Limit)) | ||
f.metrics.rateLimitRemaining.With(labels).Set(float64(limits.Remaining)) | ||
f.metrics.rateLimitUsed.With(labels).Set(float64(limits.Used)) | ||
6 changes: 4 additions & 2 deletionsdocs/admin/prometheus.md
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
11 changes: 9 additions & 2 deletionsscripts/metricsdocgen/metrics
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
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.