Skip to content

Conversation

@ritesh-avesha
Copy link

Pushgateway (version >= 1.5.0) supports gzip and snappy compression (v > 1.6.0). This helps optimizing in network constrained environments

  • Add a single compression argument (gzip/snappy) to push_to_gateway and pushadd_to_gateway
    @csmarchbanks

Signed-off-by: ritesh-avesha <ritesh@aveshasystems.com>
@ritesh-avesha ritesh-avesha force-pushed the pushgateway-compression branch from 4e71a82 to fd91251 Compare November 8, 2025 14:16
Copy link
Member

@csmarchbanks csmarchbanks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

A few comments but generally excited to see this work. Plus it looks like some linters are failing.

for k, v in sorted(grouping_key.items()))

data = b''
headers = [('Content-Type', CONTENT_TYPE_PLAIN_0_0_4)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Comment on lines +758 to +761
try:
import snappy
except ImportError as exc:
raise RuntimeError('Snappy compression requires the python-snappy package to be installed.') from exc
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

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')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to add snappy to one of the test envs such as

{py3.9,pypy3.9}: twisted
so that CI runs this test in at least one environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants