From 036ed5672f46017462b588fc5c9a99e41fce8207 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Fri, 30 Jan 2026 13:30:06 +0100 Subject: [PATCH] fix!: remove deprecated prometheus metrics (#21788) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description Removes the following deprecated Prometheus metrics: - `coderd_api_workspace_latest_build_total` → use `coderd_api_workspace_latest_build` instead - `coderd_oauth2_external_requests_rate_limit_total` → use `coderd_oauth2_external_requests_rate_limit` instead These metrics were deprecated in #12976 because gauge metrics should avoid the `_total` suffix per [Prometheus naming conventions](https://prometheus.io/docs/practices/naming/). ## Changes - Removed deprecated metric `coderd_api_workspace_latest_build_total` from `coderd/prometheusmetrics/prometheusmetrics.go` - Removed deprecated metric `coderd_oauth2_external_requests_rate_limit_total` from `coderd/promoauth/oauth2.go` - Updated tests to use the non-deprecated metric name Fixes #12999 --- coderd/prometheusmetrics/prometheusmetrics.go | 15 ------------- coderd/promoauth/oauth2.go | 22 +++---------------- coderd/promoauth/oauth2_test.go | 4 ++-- docs/admin/integrations/prometheus.md | 2 -- scripts/metricsdocgen/metrics | 7 ------ 5 files changed, 5 insertions(+), 45 deletions(-) diff --git a/coderd/prometheusmetrics/prometheusmetrics.go b/coderd/prometheusmetrics/prometheusmetrics.go index f1962cc287..fe40cb522c 100644 --- a/coderd/prometheusmetrics/prometheusmetrics.go +++ b/coderd/prometheusmetrics/prometheusmetrics.go @@ -132,19 +132,6 @@ func Workspaces(ctx context.Context, logger slog.Logger, registerer prometheus.R duration = defaultRefreshRate } - // TODO: deprecated: remove in the future - // 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", @@ -198,8 +185,6 @@ func Workspaces(ctx context.Context, logger slog.Logger, registerer prometheus.R for _, w := range ws { status := string(w.LatestBuildStatus) workspaceLatestBuildTotals.WithLabelValues(status).Add(1) - // TODO: deprecated: remove in the future - workspaceLatestBuildTotalsDeprecated.WithLabelValues(status).Add(1) workspaceLatestBuildStatuses.WithLabelValues( status, diff --git a/coderd/promoauth/oauth2.go b/coderd/promoauth/oauth2.go index 6ab54b604f..91b34dbd95 100644 --- a/coderd/promoauth/oauth2.go +++ b/coderd/promoauth/oauth2.go @@ -70,11 +70,9 @@ 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 + rateLimit *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. @@ -109,18 +107,6 @@ func NewFactory(registry prometheus.Registerer) *Factory { // Some IDPs have different buckets for different rate limits. "resource", }), - // TODO: deprecated: remove in the future - // 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", @@ -198,8 +184,6 @@ 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)) diff --git a/coderd/promoauth/oauth2_test.go b/coderd/promoauth/oauth2_test.go index ab8e7c3314..a2cb6f9bc4 100644 --- a/coderd/promoauth/oauth2_test.go +++ b/coderd/promoauth/oauth2_test.go @@ -209,7 +209,7 @@ func TestGithubRateLimits(t *testing.T) { } pass := true if !c.ExpectNoMetrics { - pass = pass && assert.Equal(t, promhelp.GaugeValue(t, reg, "coderd_oauth2_external_requests_rate_limit_total", labels), c.Limit, "limit") + pass = pass && assert.Equal(t, promhelp.GaugeValue(t, reg, "coderd_oauth2_external_requests_rate_limit", labels), c.Limit, "limit") pass = pass && assert.Equal(t, promhelp.GaugeValue(t, reg, "coderd_oauth2_external_requests_rate_limit_remaining", labels), c.Remaining, "remaining") pass = pass && assert.Equal(t, promhelp.GaugeValue(t, reg, "coderd_oauth2_external_requests_rate_limit_used", labels), c.Used, "used") if !c.at.IsZero() { @@ -218,7 +218,7 @@ func TestGithubRateLimits(t *testing.T) { pass = pass && assert.InDelta(t, promhelp.GaugeValue(t, reg, "coderd_oauth2_external_requests_rate_limit_reset_in_seconds", labels), int(until.Seconds()), 2, "reset in") } } else { - pass = pass && assert.Nil(t, promhelp.MetricValue(t, reg, "coderd_oauth2_external_requests_rate_limit_total", labels), "not exists") + pass = pass && assert.Nil(t, promhelp.MetricValue(t, reg, "coderd_oauth2_external_requests_rate_limit", labels), "not exists") } // Helpful debugging diff --git a/docs/admin/integrations/prometheus.md b/docs/admin/integrations/prometheus.md index ffa1957b73..aa2b9056fd 100644 --- a/docs/admin/integrations/prometheus.md +++ b/docs/admin/integrations/prometheus.md @@ -142,7 +142,6 @@ deployment. They will always be available from the agent. | `coderd_api_requests_processed_total` | counter | The total number of processed API requests | `code` `method` `path` | | `coderd_api_websocket_durations_seconds` | histogram | Websocket duration distribution of requests in seconds. | `path` | | `coderd_api_workspace_latest_build` | gauge | The latest workspace builds with a status. | `status` | -| `coderd_api_workspace_latest_build_total` | gauge | DEPRECATED: use coderd_api_workspace_latest_build instead | `status` | | `coderd_insights_applications_usage_seconds` | gauge | The application usage per template. | `application_name` `slug` `template_name` | | `coderd_insights_parameters` | gauge | The parameter usage per template. | `parameter_name` `parameter_type` `parameter_value` `template_name` | | `coderd_insights_templates_active_users` | gauge | The number of active users of the template. | `template_name` | @@ -156,7 +155,6 @@ deployment. They will always be available from the agent. | `coderd_oauth2_external_requests_rate_limit_next_reset_unix` | gauge | Unix timestamp of the next interval | `name` `resource` | | `coderd_oauth2_external_requests_rate_limit_remaining` | gauge | The remaining number of allowed requests in this interval. | `name` `resource` | | `coderd_oauth2_external_requests_rate_limit_reset_in_seconds` | gauge | Seconds until the next interval | `name` `resource` | -| `coderd_oauth2_external_requests_rate_limit_total` | gauge | DEPRECATED: use coderd_oauth2_external_requests_rate_limit instead | `name` `resource` | | `coderd_oauth2_external_requests_rate_limit_used` | gauge | The number of requests made in this interval. | `name` `resource` | | `coderd_oauth2_external_requests_total` | counter | The total number of api calls made to external oauth2 providers. 'status_code' will be 0 if the request failed with no response. | `name` `source` `status_code` | | `coderd_prebuilt_workspace_claim_duration_seconds` | histogram | Time to claim a prebuilt workspace by organization, template, and preset. | `organization_name` `preset_name` `template_name` | diff --git a/scripts/metricsdocgen/metrics b/scripts/metricsdocgen/metrics index 78b5772f07..c57cd12cbb 100644 --- a/scripts/metricsdocgen/metrics +++ b/scripts/metricsdocgen/metrics @@ -14,10 +14,6 @@ coderd_oauth2_external_requests_rate_limit_reset_in_seconds{name="secondary-gith # TYPE coderd_oauth2_external_requests_rate_limit gauge coderd_oauth2_external_requests_rate_limit{name="primary-github",resource="core-unauthorized"} 5000 coderd_oauth2_external_requests_rate_limit{name="secondary-github",resource="core-unauthorized"} 5000 -# HELP coderd_oauth2_external_requests_rate_limit_total DEPRECATED: use coderd_oauth2_external_requests_rate_limit instead -# TYPE coderd_oauth2_external_requests_rate_limit_total gauge -coderd_oauth2_external_requests_rate_limit_total{name="primary-github",resource="core-unauthorized"} 5000 -coderd_oauth2_external_requests_rate_limit_total{name="secondary-github",resource="core-unauthorized"} 5000 # HELP coderd_oauth2_external_requests_rate_limit_used The number of requests made in this interval. # TYPE coderd_oauth2_external_requests_rate_limit_used gauge coderd_oauth2_external_requests_rate_limit_used{name="primary-github",resource="core"} 148 @@ -654,9 +650,6 @@ coderd_api_requests_processed_total{code="401",method="POST",path="/api/v2/files # HELP coderd_api_workspace_latest_build The latest workspace builds with a status. # TYPE coderd_api_workspace_latest_build gauge coderd_api_workspace_latest_build{status="succeeded"} 1 -# HELP coderd_api_workspace_latest_build_total DEPRECATED: use coderd_api_workspace_latest_build instead -# TYPE coderd_api_workspace_latest_build_total gauge -coderd_api_workspace_latest_build_total{status="succeeded"} 1 # HELP coderd_insights_applications_usage_seconds The application usage per template. # TYPE coderd_insights_applications_usage_seconds gauge coderd_insights_applications_usage_seconds{application_name="JetBrains",slug="",template_name="code-server-pod"} 1