client_golang/prometheus/promhttp
Tiago Silva 59c00e3e9c
Fix data-race in metric without code and method but with `WithLabelFromCtx` (#1318)
This commit fixes a data race that exists when the metric used in any
`promhttp` middleware doesn't collect the `code` and `method` but uses
`WithLabelFromCtx` to collect values from context.

The problem happens because when no `code` and `method` tags are
collected, the `labels` function returns a pre-initialized map
`emptyLabels` for every request.

When one or multipe `WithLabelFromCtx` options are configured, the
returned map from the `labels` function call is used to collect the
metrics from context which creates a multi-write data race.

Signed-off-by: Tiago Silva <tiago.silva@goteleport.com>
2023-08-01 17:11:17 +01:00
..
delegator.go
http.go add process start time header to client_golang prometheus (#1278) 2023-05-26 12:58:36 +01:00
http_test.go Do not allocate memory when there's no constraints (#1296) 2023-06-27 12:21:36 +01:00
instrument_client.go Revert "Remove unnecessary check if label is nil in observeWithExemplar (#1235)" 2023-05-03 09:41:26 +01:00
instrument_client_test.go
instrument_server.go Fix data-race in metric without code and method but with `WithLabelFromCtx` (#1318) 2023-08-01 17:11:17 +01:00
instrument_server_test.go Fix data-race in metric without code and method but with `WithLabelFromCtx` (#1318) 2023-08-01 17:11:17 +01:00
option.go Added clarification. 2023-05-03 09:41:34 +01:00
option_test.go