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 promhttp error handling #726

Merged
merged 1 commit into from Mar 13, 2020
Merged

Fix promhttp error handling #726

merged 1 commit into from Mar 13, 2020

Commits on Mar 12, 2020

  1. Fix promhttp error handling

    Essentially, just don't try to set a status code and send any error
    message in the body once metrics gathering has succeeded. At that
    point, the most likely reason for errors is anyway that the client has
    disconnected, in which sending an error is moot. The other possible
    reason for an error is a problem during metrics encoding. This is
    unlikely to happen (it's a coding error here in client_golang in any
    case), and if it is happening, the odds are we have already sent
    something to the ResponseWriter, which means we cannot set a status
    code anymore. The doc comment for HTTPErrorOnError now describes these
    circumstances explicitly and recommends to set a logger to report that
    kind of error.
    
    This should fix the reason for the infamous `superfluous
    response.WriteHeader call` message.
    
    Signed-off-by: beorn7 <beorn@grafana.com>
    beorn7 committed Mar 12, 2020
    Copy the full SHA
    586178b View commit details
    Browse the repository at this point in the history