Page MenuHomeSoftware Heritage

Add a statsd client module
ClosedPublic

Authored by olasd on Wed, Dec 19, 3:38 PM.

Details

Summary

prometheus-statsd-exporter uses the datadog format for its tags, so base our
client on their Python code, with the following modifications:

  • Removed python < 3.5 compat code
  • trimmed the imports down to be a single module
  • adjust some options:
    • drop unix socket connection option
    • add environment variable support for setting the statsd host and port (pulled the idea from the main python statsd module)
    • only send timer metrics in milliseconds (that's what prometheus-statsd-exporter expects)
    • drop DataDog-specific metric types (that are unsupported in prometheus-statsd-exporter)
  • made the tags a dict instead of a list (prometheus-statsd-exporter only supports tags with a value, mirroring prometheus)
  • improve unit test coverage
  • documentation cleanup
Test Plan

tox

Diff Detail

Repository
rDCORE Foundations and core functionalities
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

olasd created this revision.Wed, Dec 19, 3:38 PM
douardda requested changes to this revision.Thu, Dec 20, 11:05 AM
douardda added inline comments.
swh/core/statsd.py
57

wouldn't time.monotonic be preferable here?

77

what is self.elapsed needed for? tests? if so, document this (comment) plz

182

if ':' in tag ?

This revision now requires changes to proceed.Thu, Dec 20, 11:05 AM
olasd updated this revision to Diff 2789.Fri, Dec 21, 3:11 PM

Apply David's comments

olasd marked 3 inline comments as done.Fri, Dec 21, 3:11 PM
douardda accepted this revision.Mon, Jan 7, 10:56 AM
This revision is now accepted and ready to land.Mon, Jan 7, 10:56 AM
This revision was automatically updated to reflect the committed changes.