Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix data-race in metric without code and method but with `WithLabelFr…
…omCtx` (prometheus#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 <[email protected]>
- Loading branch information