Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix data-race in metric without code and method but with WithLabelFromCtx #1318

Merged
merged 1 commit into from Aug 1, 2023

Commits on Jul 31, 2023

  1. Fix data-race in metric without code and method but with `WithLabelFr…

    …omCtx`
    
    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>
    tigrato committed Jul 31, 2023
    Configuration menu
    Copy the full SHA
    5113fb6 View commit details
    Browse the repository at this point in the history