Commit e9e67a2
committed
fix: fix logic for plain text fallback format
This pull requests fixes a logic error in metrics_writer.go where metrics
headers are replaced when a protobuf format is requested. However, the
existing logic is never used because the content type negotiation is already
done in a previous step (in metrics_handler.go). There, the content type for
proto-based formats is changed to text/plain before passing the argument
to SanitizeHeaders.
The pull request changes the condition in SanitizeHeaders to check for
the plain-text format instead of protobuf. I changed the signature of
SanitizeHeaders to accept expfmt.Format instead of string. This makes checking
the content type a bit cleaner. If this is considered a breaking change, we
can also change it to a string prefix comparison.
I encountered the error when I tried to use native histogram parsing in
prometheus and found errors while parsing kube-state-metrics' metrics.
The issue is already described in #2587.
Signed-off-by: Timon Engelke <timon.engelke@inovex.de>1 parent 95b29ac commit e9e67a2
File tree
3 files changed
+15
-14
lines changed- pkg
- metrics_store
- metricshandler
3 files changed
+15
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | | - | |
| 95 | + | |
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
107 | | - | |
108 | | - | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
109 | 110 | | |
110 | 111 | | |
111 | 112 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
276 | 276 | | |
277 | 277 | | |
278 | 278 | | |
279 | | - | |
280 | | - | |
| 279 | + | |
| 280 | + | |
281 | 281 | | |
282 | 282 | | |
283 | 283 | | |
| |||
293 | 293 | | |
294 | 294 | | |
295 | 295 | | |
296 | | - | |
297 | | - | |
| 296 | + | |
| 297 | + | |
298 | 298 | | |
299 | 299 | | |
300 | 300 | | |
| |||
316 | 316 | | |
317 | 317 | | |
318 | 318 | | |
319 | | - | |
320 | | - | |
| 319 | + | |
| 320 | + | |
321 | 321 | | |
322 | 322 | | |
323 | 323 | | |
| |||
331 | 331 | | |
332 | 332 | | |
333 | 333 | | |
334 | | - | |
335 | | - | |
| 334 | + | |
| 335 | + | |
336 | 336 | | |
337 | 337 | | |
338 | 338 | | |
| |||
356 | 356 | | |
357 | 357 | | |
358 | 358 | | |
359 | | - | |
| 359 | + | |
360 | 360 | | |
361 | 361 | | |
362 | 362 | | |
| |||
404 | 404 | | |
405 | 405 | | |
406 | 406 | | |
407 | | - | |
| 407 | + | |
408 | 408 | | |
409 | 409 | | |
410 | 410 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
220 | 220 | | |
221 | 221 | | |
222 | 222 | | |
223 | | - | |
| 223 | + | |
224 | 224 | | |
225 | 225 | | |
226 | 226 | | |
| |||
0 commit comments