Skip to content

Commit 1c4eb1d

Browse files
committed
rename flags
1 parent 67eee75 commit 1c4eb1d

File tree

3 files changed

+22
-20
lines changed

3 files changed

+22
-20
lines changed

cli/server.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,9 +417,9 @@ func server() *cobra.Command {
417417

418418
cliflag.StringVarP(root.Flags(), &accessURL, "access-url", "", "CODER_ACCESS_URL", "", "Specifies the external URL to access Coder.")
419419
cliflag.StringVarP(root.Flags(), &address, "address", "a", "CODER_ADDRESS", "127.0.0.1:3000", "The address to serve the API and dashboard.")
420-
cliflag.BoolVarP(root.Flags(), &promEnabled, "enable-prometheus", "", "CODER_ENABLE_PROMETHEUS", false, "Enable serving prometheus metrics on the addressdefined by --prometheus-address.")
420+
cliflag.BoolVarP(root.Flags(), &promEnabled, "prometheus-enable", "", "CODER_PROMETHEUS_ENABLE", false, "Enable serving prometheus metrics on the addressdefined by --prometheus-address.")
421421
cliflag.StringVarP(root.Flags(), &promAddress, "prometheus-address", "", "CODER_PROMETHEUS_ADDRESS", "127.0.0.1:2112", "The address to serve prometheus metrics.")
422-
cliflag.BoolVarP(root.Flags(), &promEnabled, "enable-pprof", "", "CODER_ENABLE_PPROF", false, "Enable serving pprof metrics on the address defined by --pprof-address.")
422+
cliflag.BoolVarP(root.Flags(), &promEnabled, "pprof-enable", "", "CODER_PPROF_ENABLE", false, "Enable serving pprof metrics on the address defined by --pprof-address.")
423423
cliflag.StringVarP(root.Flags(), &pprofAddress, "pprof-address", "", "CODER_PPROF_ADDRESS", "127.0.0.1:6060", "The address to serve pprof.")
424424
// systemd uses the CACHE_DIRECTORY environment variable!
425425
cliflag.StringVarP(root.Flags(), &cacheDir, "cache-dir", "", "CACHE_DIRECTORY", filepath.Join(os.TempDir(), "coder-cache"), "Specifies a directory to cache binaries for provision operations.")

coderd/httpmw/prometheus.go

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"time"
77

88
"github.com/go-chi/chi/v5"
9-
"github.com/go-chi/chi/v5/middleware"
9+
chimw "github.com/go-chi/chi/v5/middleware"
1010

1111
"github.com/prometheus/client_golang/prometheus"
1212
"github.com/prometheus/client_golang/prometheus/promauto"
@@ -19,18 +19,18 @@ var (
1919
Name: "requests_processed_total",
2020
Help: "The total number of processed API requests",
2121
}, []string{"code", "method", "path"})
22-
requestsConcurrent = promauto.NewGaugeVec(prometheus.GaugeOpts{
22+
requestsConcurrent = promauto.NewGauge(prometheus.GaugeOpts{
2323
Namespace: "coderd",
2424
Subsystem: "api",
2525
Name: "concurrent_requests",
2626
Help: "The number of concurrent API requests",
27-
}, []string{"method", "path"})
28-
websocketsConcurrent = promauto.NewGaugeVec(prometheus.GaugeOpts{
27+
})
28+
websocketsConcurrent = promauto.NewGauge(prometheus.GaugeOpts{
2929
Namespace: "coderd",
3030
Subsystem: "api",
3131
Name: "concurrent_websockets",
3232
Help: "The total number of concurrent API websockets",
33-
}, []string{"path"})
33+
})
3434
websocketsDist = promauto.NewHistogramVec(prometheus.HistogramOpts{
3535
Namespace: "coderd",
3636
Subsystem: "api",
@@ -64,11 +64,10 @@ func Prometheus(next http.Handler) http.Handler {
6464
start = time.Now()
6565
method = r.Method
6666
rctx = chi.RouteContext(r.Context())
67-
path = rctx.RoutePattern()
6867
)
69-
sw, ok := w.(middleware.WrapResponseWriter)
68+
sw, ok := w.(chimw.WrapResponseWriter)
7069
if !ok {
71-
panic("dev error: http.ResponseWriter is not middleware.WrapResponseWriter")
70+
panic("dev error: http.ResponseWriter is not chimw.WrapResponseWriter")
7271
}
7372

7473
var (
@@ -77,24 +76,26 @@ func Prometheus(next http.Handler) http.Handler {
7776
)
7877
// We want to count websockets separately.
7978
if isWebsocketUpgrade(r) {
80-
websocketsConcurrent.WithLabelValues(path).Inc()
81-
defer websocketsConcurrent.WithLabelValues(path).Dec()
79+
websocketsConcurrent.Inc()
80+
defer websocketsConcurrent.Dec()
8281

8382
dist = websocketsDist
84-
distOpts = []string{path}
8583
} else {
86-
requestsConcurrent.WithLabelValues(method, path).Inc()
87-
defer requestsConcurrent.WithLabelValues(method, path).Dec()
84+
requestsConcurrent.Inc()
85+
defer requestsConcurrent.Dec()
8886

8987
dist = requestsDist
90-
distOpts = []string{method, path}
88+
distOpts = []string{method}
9189
}
9290

9391
next.ServeHTTP(w, r)
92+
93+
path := rctx.RoutePattern()
94+
distOpts = append(distOpts, path)
9495
statusStr := strconv.Itoa(sw.Status())
9596

9697
requestsProcessed.WithLabelValues(statusStr, method, path).Inc()
97-
dist.WithLabelValues(distOpts...).Observe(float64(time.Since(start).Milliseconds()))
98+
dist.WithLabelValues(distOpts...).Observe(float64(time.Since(start)) / 1e6)
9899
})
99100
}
100101

site/src/api/typesGenerated.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ export interface CreateWorkspaceBuildRequest {
9191
// This is likely an enum in an external package ("github.com/coder/coder/coderd/database.WorkspaceTransition")
9292
readonly transition: string
9393
readonly dry_run: boolean
94+
readonly state: string
9495
}
9596

9697
// From codersdk/organizations.go:52:6
@@ -265,12 +266,12 @@ export interface UpdateUserProfileRequest {
265266
readonly username: string
266267
}
267268

268-
// From codersdk/workspaces.go:94:6
269+
// From codersdk/workspaces.go:95:6
269270
export interface UpdateWorkspaceAutostartRequest {
270271
readonly schedule: string
271272
}
272273

273-
// From codersdk/workspaces.go:114:6
274+
// From codersdk/workspaces.go:115:6
274275
export interface UpdateWorkspaceAutostopRequest {
275276
readonly schedule: string
276277
}
@@ -366,7 +367,7 @@ export interface WorkspaceAgentResourceMetadata {
366367
readonly cpu_mhz: number
367368
}
368369

369-
// From codersdk/workspacebuilds.go:17:6
370+
// From codersdk/workspacebuilds.go:18:6
370371
export interface WorkspaceBuild {
371372
readonly id: string
372373
readonly created_at: string

0 commit comments

Comments
 (0)