Added compression support in pushgateway#1144
Added compression support in pushgateway#1144csmarchbanks merged 4 commits intoprometheus:masterfrom
Conversation
Signed-off-by: ritesh-avesha <[email protected]>
4e71a82 to
fd91251
Compare
csmarchbanks
left a comment
There was a problem hiding this comment.
Thanks!
A few comments but generally excited to see this work. Plus it looks like some linters are failing.
prometheus_client/exposition.py
Outdated
| for k, v in sorted(grouping_key.items())) | ||
|
|
||
| data = b'' | ||
| headers = [('Content-Type', CONTENT_TYPE_PLAIN_0_0_4)] |
There was a problem hiding this comment.
I don't love defining this default header in two places, perhaps append here? Or does delete even need this header as there is no content type?
There was a problem hiding this comment.
Some existing tests require this header, hence have kept it for now
prometheus_client/exposition.py
Outdated
| try: | ||
| import snappy | ||
| except ImportError as exc: | ||
| raise RuntimeError('Snappy compression requires the python-snappy package to be installed.') from exc |
There was a problem hiding this comment.
Trying an import on each request feels a bit slow, could we do this once and then have a variable for if snappy is enabled or not?
There was a problem hiding this comment.
Thanks for the feedback, have moved the import
| self.assertEqual(decompressed, b'# HELP g help\n# TYPE g gauge\ng 0.0\n') | ||
|
|
||
| def test_push_with_snappy_compression(self): | ||
| snappy = pytest.importorskip('snappy') |
There was a problem hiding this comment.
It would be good to add snappy to one of the test envs such as
Line 11 in 1783ca8
There was a problem hiding this comment.
Thanks, have added.
Signed-off-by: ritesh-avesha <[email protected]>
Signed-off-by: ritesh-avesha <[email protected]>
Signed-off-by: ritesh-avesha <[email protected]>
Pushgateway (version >= 1.5.0) supports gzip and snappy compression (v > 1.6.0). This helps optimizing in network constrained environments
compressionargument (gzip/snappy) topush_to_gatewayandpushadd_to_gateway@csmarchbanks