Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4682355

Browse files
snark87johnstcn
andauthored
chore: deprecate gauge metrics with _total suffix (#12744) (#12976)
* chore: deprecate gauge metrics with _total suffix (#12744)Deprecated metrics:- coderd_oauth2_external_requests_rate_limit_total- coderd_api_workspace_latest_build_total* Apply suggestions from code reviewadd link to follow-up issueCo-authored-by: Cian Johnston <public@cianjohnston.ie>---------Co-authored-by: Cian Johnston <public@cianjohnston.ie>
1 parent5780050 commit4682355

File tree

5 files changed

+50
-10
lines changed

5 files changed

+50
-10
lines changed

‎coderd/prometheusmetrics/prometheusmetrics.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,23 @@ func Workspaces(ctx context.Context, logger slog.Logger, registerer prometheus.R
7979
duration=defaultRefreshRate
8080
}
8181

82-
workspaceLatestBuildTotals:=prometheus.NewGaugeVec(prometheus.GaugeOpts{
82+
// TODO: deprecated: remove in the future
83+
// See: https://github.com/coder/coder/issues/12999
84+
// Deprecation reason: gauge metrics should avoid suffix `_total``
85+
workspaceLatestBuildTotalsDeprecated:=prometheus.NewGaugeVec(prometheus.GaugeOpts{
8386
Namespace:"coderd",
8487
Subsystem:"api",
8588
Name:"workspace_latest_build_total",
89+
Help:"DEPRECATED: use coderd_api_workspace_latest_build instead",
90+
}, []string{"status"})
91+
iferr:=registerer.Register(workspaceLatestBuildTotalsDeprecated);err!=nil {
92+
returnnil,err
93+
}
94+
95+
workspaceLatestBuildTotals:=prometheus.NewGaugeVec(prometheus.GaugeOpts{
96+
Namespace:"coderd",
97+
Subsystem:"api",
98+
Name:"workspace_latest_build",
8699
Help:"The current number of workspace builds by status.",
87100
}, []string{"status"})
88101
iferr:=registerer.Register(workspaceLatestBuildTotals);err!=nil {
@@ -131,6 +144,8 @@ func Workspaces(ctx context.Context, logger slog.Logger, registerer prometheus.R
131144
for_,job:=rangejobs {
132145
status:=codersdk.ProvisionerJobStatus(job.JobStatus)
133146
workspaceLatestBuildTotals.WithLabelValues(string(status)).Add(1)
147+
// TODO: deprecated: remove in the future
148+
workspaceLatestBuildTotalsDeprecated.WithLabelValues(string(status)).Add(1)
134149
}
135150
}
136151

‎coderd/prometheusmetrics/prometheusmetrics_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ func TestWorkspaceLatestBuildTotals(t *testing.T) {
159159
assert.NoError(t,err)
160160
sum:=0
161161
for_,m:=rangemetrics {
162-
ifm.GetName()!="coderd_api_workspace_latest_build_total" {
162+
ifm.GetName()!="coderd_api_workspace_latest_build" {
163163
continue
164164
}
165165

‎coderd/promoauth/oauth2.go

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,11 @@ type metrics struct {
6262

6363
// if the oauth supports it, rate limit metrics.
6464
// rateLimit is the defined limit per interval
65-
rateLimit*prometheus.GaugeVec
66-
rateLimitRemaining*prometheus.GaugeVec
67-
rateLimitUsed*prometheus.GaugeVec
65+
rateLimit*prometheus.GaugeVec
66+
// TODO: remove deprecated metrics in the future release
67+
rateLimitDeprecated*prometheus.GaugeVec
68+
rateLimitRemaining*prometheus.GaugeVec
69+
rateLimitUsed*prometheus.GaugeVec
6870
// rateLimitReset is unix time of the next interval (when the rate limit resets).
6971
rateLimitReset*prometheus.GaugeVec
7072
// rateLimitResetIn is the time in seconds until the rate limit resets.
@@ -91,14 +93,26 @@ func NewFactory(registry prometheus.Registerer) *Factory {
9193
rateLimit:factory.NewGaugeVec(prometheus.GaugeOpts{
9294
Namespace:"coderd",
9395
Subsystem:"oauth2",
94-
Name:"external_requests_rate_limit_total",
96+
Name:"external_requests_rate_limit",
9597
Help:"The total number of allowed requests per interval.",
9698
}, []string{
9799
"name",
98100
// Resource allows different rate limits for the same oauth2 provider.
99101
// Some IDPs have different buckets for different rate limits.
100102
"resource",
101103
}),
104+
// TODO: deprecated: remove in the future
105+
// See: https://github.com/coder/coder/issues/12999
106+
// Deprecation reason: gauge metrics should avoid suffix `_total``
107+
rateLimitDeprecated:factory.NewGaugeVec(prometheus.GaugeOpts{
108+
Namespace:"coderd",
109+
Subsystem:"oauth2",
110+
Name:"external_requests_rate_limit_total",
111+
Help:"DEPRECATED: use coderd_oauth2_external_requests_rate_limit instead",
112+
}, []string{
113+
"name",
114+
"resource",
115+
}),
102116
rateLimitRemaining:factory.NewGaugeVec(prometheus.GaugeOpts{
103117
Namespace:"coderd",
104118
Subsystem:"oauth2",
@@ -176,6 +190,8 @@ func (f *Factory) NewGithub(name string, under OAuth2Config) *Config {
176190
}
177191
}
178192

193+
// TODO: remove this metric in v3
194+
f.metrics.rateLimitDeprecated.With(labels).Set(float64(limits.Limit))
179195
f.metrics.rateLimit.With(labels).Set(float64(limits.Limit))
180196
f.metrics.rateLimitRemaining.With(labels).Set(float64(limits.Remaining))
181197
f.metrics.rateLimitUsed.With(labels).Set(float64(limits.Used))

‎docs/admin/prometheus.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,18 +120,20 @@ spec:
120120
| `coderd_api_request_latencies_seconds` | histogram | Latency distribution of requests in seconds. | `method` `path` |
121121
| `coderd_api_requests_processed_total` | counter | The total number of processed API requests | `code` `method` `path` |
122122
| `coderd_api_websocket_durations_seconds` | histogram | Websocket duration distribution of requests in seconds. | `path` |
123-
| `coderd_api_workspace_latest_build_total` | gauge | The latest workspace builds with a status. | `status` |
123+
| `coderd_api_workspace_latest_build` | gauge | The latest workspace builds with a status. | `status` |
124+
| `coderd_api_workspace_latest_build_total` | gauge | DEPRECATED:use coderd_api_workspace_latest_build instead | `status` |
124125
| `coderd_insights_applications_usage_seconds` | gauge | The application usage per template. | `application_name` `slug` `template_name` |
125126
| `coderd_insights_parameters` | gauge | The parameter usage per template. | `parameter_name` `parameter_type` `parameter_value` `template_name` |
126127
| `coderd_insights_templates_active_users` | gauge | The number of active users of the template. | `template_name` |
127128
| `coderd_license_active_users` | gauge | The number of active users. | |
128129
| `coderd_license_limit_users` | gauge | The user seats limit based on the active Coder license. | |
129130
| `coderd_license_user_limit_enabled` | gauge | Returns 1 if the current license enforces the user limit. | |
130131
| `coderd_metrics_collector_agents_execution_seconds` | histogram | Histogram for duration of agents metrics collection in seconds. | |
132+
| `coderd_oauth2_external_requests_rate_limit` | gauge | The total number of allowed requests per interval. | `name` `resource` |
131133
| `coderd_oauth2_external_requests_rate_limit_next_reset_unix` | gauge | Unix timestamp of the next interval | `name` `resource` |
132134
| `coderd_oauth2_external_requests_rate_limit_remaining` | gauge | The remaining number of allowed requests in this interval. | `name` `resource` |
133135
| `coderd_oauth2_external_requests_rate_limit_reset_in_seconds` | gauge | Seconds until the next interval | `name` `resource` |
134-
| `coderd_oauth2_external_requests_rate_limit_total` | gauge |The total number of allowed requests per interval. | `name` `resource` |
136+
| `coderd_oauth2_external_requests_rate_limit_total` | gauge |DEPRECATED:use coderd_oauth2_external_requests_rate_limit instead | `name` `resource` |
135137
| `coderd_oauth2_external_requests_rate_limit_used` | gauge | The number of requests made in this interval. | `name` `resource` |
136138
| `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` |
137139
| `coderd_provisionerd_job_timings_seconds` | histogram | The provisioner job time duration in seconds. | `provisioner` `status` |

‎scripts/metricsdocgen/metrics

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ coderd_oauth2_external_requests_rate_limit_remaining{name="secondary-github",res
1010
# TYPE coderd_oauth2_external_requests_rate_limit_reset_in_seconds gauge
1111
coderd_oauth2_external_requests_rate_limit_reset_in_seconds{name="primary-github",resource="core"} 63.617162731
1212
coderd_oauth2_external_requests_rate_limit_reset_in_seconds{name="secondary-github",resource="core"} 121.82186601
13-
# HELP coderd_oauth2_external_requests_rate_limit_total The total number of allowed requests per interval.
13+
# HELP coderd_oauth2_external_requests_rate_limit The total number of allowed requests per interval.
14+
# TYPE coderd_oauth2_external_requests_rate_limit gauge
15+
coderd_oauth2_external_requests_rate_limit{name="primary-github",resource="core-unauthorized"} 5000
16+
coderd_oauth2_external_requests_rate_limit{name="secondary-github",resource="core-unauthorized"} 5000
17+
# HELP coderd_oauth2_external_requests_rate_limit_total DEPRECATED: use coderd_oauth2_external_requests_rate_limit instead
1418
# TYPE coderd_oauth2_external_requests_rate_limit_total gauge
1519
coderd_oauth2_external_requests_rate_limit_total{name="primary-github",resource="core-unauthorized"} 5000
1620
coderd_oauth2_external_requests_rate_limit_total{name="secondary-github",resource="core-unauthorized"} 5000
@@ -644,7 +648,10 @@ coderd_api_requests_processed_total{code="401",method="GET",path="/api/v2/users/
644648
coderd_api_requests_processed_total{code="401",method="GET",path="/api/v2/users/{user}/*"} 2
645649
coderd_api_requests_processed_total{code="401",method="GET",path="/api/v2/workspaces"} 1
646650
coderd_api_requests_processed_total{code="401",method="POST",path="/api/v2/files"} 1
647-
# HELP coderd_api_workspace_latest_build_total The latest workspace builds with a status.
651+
# HELP coderd_api_workspace_latest_build The latest workspace builds with a status.
652+
# TYPE coderd_api_workspace_latest_build gauge
653+
coderd_api_workspace_latest_build{status="succeeded"} 1
654+
# HELP coderd_api_workspace_latest_build_total DEPRECATED: use coderd_api_workspace_latest_build instead
648655
# TYPE coderd_api_workspace_latest_build_total gauge
649656
coderd_api_workspace_latest_build_total{status="succeeded"} 1
650657
# HELP coderd_insights_applications_usage_seconds The application usage per template.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp