Commit Graph

13 Commits

Author SHA1 Message Date
beorn7 e92283d644 Fix linter ignores
Signed-off-by: beorn7 <beorn@grafana.com>
2021-03-16 17:19:03 +01:00
beorn7 586178b4ab 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>
2020-03-13 00:10:32 +01:00
beorn7 ad58180fde Add WriteHeader call to Flush
Flush is another of the methods that will call WriteHeader if it
hasn't happened yet. Since we want to call observeWriteHeader (if
set), we need to do the WriteHeader call already here, similar to what
we have done in Write and ReadFrom.

This commit also adds comments explaining the above to not tempt
developers to remove the WriteHeader call.

Signed-off-by: beorn7 <beorn@grafana.com>
2019-08-19 18:19:23 +02:00
Camilo Viecco facfcc21f8 fix regression issue 574
Signed-off-by: Camilo Viecco <camilo_viecco1@symantec.com>
2019-05-14 11:44:55 -07:00
Bjoern Rabenstein 1173d73405 Increase minimum required Go version to 1.9
This allows us to simplify a bunch of code while still supporting the
last four Go minor versions.

We have also run into minor annoyances a couple of times by now to
keep supporting 1.7 and 1.8.

It's time to pull the plug!

Signed-off-by: Bjoern Rabenstein <bjoern@rabenste.in>
2019-04-28 23:28:57 +02:00
Simon Pasquier 6894bb3c7c Add .golangci.yml
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2019-04-25 10:38:07 +02:00
beorn7 a006a7550a Remove unused constants and fields
Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-12-24 11:22:57 +01:00
Eric Daniels 2d0312e3dd
forgot some &s
Signed-off-by: Eric Daniels <eric@erdaniels.com>
2018-07-13 09:28:19 -04:00
Eric Daniels c02aadb406
remove references to delegators
Signed-off-by: Eric Daniels <eric@erdaniels.com>
2018-07-12 17:56:44 -04:00
Eric Daniels b3076e068e
Make delegators wrapping responseWriterDelegator have value receivers
Signed-off-by: Eric Daniels <eric@erdaniels.com>
2018-07-12 11:37:51 -04:00
beorn7 e87046a87e Fix more interface upgrade bugs 2018-02-02 15:53:28 +01:00
Torin Sandall 44a8a1218c Fix delegator return value for single hijacker
Previously, the pickDelegator function was not returning a
*hijackerDelegator so the return value did not implement the Hijacker
interface. As a result, code that attempts to hijack the connection
would fail when using a type assertion.

All the other cases returned the hijackerDelegator correctly.
2018-02-01 10:57:42 -08:00
beorn7 14730c70c0 promhttp: Bite the bullet and implement all 32 possible interface combos
As it turned out, it's not that esay to guess "common" combination of
interface upgrades. So I decided to just implement all 32 possible
combination of interface upgrades. (Only 16 with Go 1.7 and earlier.)

Clearly, this calls for code generation. But right now, we still need
to find out what's the best form of the code. For later additions,
implementing code generation might be useful.

Note that newDelegator is called for each HTTP request. Thus, this
commit aims to make the upgrade selection quick. (After the type
checks, it's just directly accessing an element in a slice.)
2017-06-02 19:03:08 +02:00