Skip to main content

A library to easily measure what\'s going on in your python.

Project description

A library to easily measure what’s going on in your python.

Metrology allows you to add instruments to your python code and hook them to external reporting tools like Graphite so as to better understand what’s going on in your running python program.

Installing

To install :

pip install metrology

API

Gauge

A gauge is an instantaneous measurement of a value

class JobGauge(metrology.instruments.Gauge):
    def value(self):
        return len(queue)
gauge = Metrology.gauge('pending-jobs', JobGauge())

Counters

A counter is like a gauge, but you can increment or decrement its value

counter = Metrology.counter('pending-jobs')
counter.increment()
counter.decrement()
counter.count

Meters

A meter measures the rate of events over time (e.g., “requests per second”). In addition to the mean rate, you can also track 1, 5 and 15 minutes moving averages

meter = Metrology.meter('requests')
meter.mark()
meter.count

or as a decorator:

@Metrology.meter('requests')
def do_this_again():
    # do something

or with context manager:

with Metrology.meter('requests'):
    # do something

Timers

A timer measures both the rate that a particular piece of code is called and the distribution of its duration

timer = Metrology.timer('responses')
with timer:
    do_something()

or as a decorator:

@Metrology.timer('responses')
def response():
    # do_something

Utilization Timer

A specialized timer that calculates the percentage of wall-clock time that was spent

utimer = Metrology.utilization_timer('responses')
with utimer:
  do_something()

Reporters

Logger Reporter

A logging reporter that write metrics to a logger

reporter = LoggerReporter(level=logging.INFO, interval=10)
reporter.start()

Graphite Reporter

A graphite reporter that send metrics to graphite

reporter = GraphiteReporter('graphite.local', 2003)
reporter.start()

Librato Reporter

A librator metric reporter that send metrics to librato API

reporter = LibratoReporter("<email>", "<token>")
reporter.start()

Ganglia Reporter

A ganglia reporter that sends metrics to gmond.

reporter = GangliaReporter("Group Name", "localhost", 8649, "udp", interval=60)
reporter.start()

StatsD Reporter

A statsd reporter that sends metrics to statsd daemon.

reporter = StatsDReporter('localhost', 3333, conn_type='tcp')
reporter.start()

or use default UDP setting:

reporter = StatsDReporter('localhost', 3333)
reporter.start()

Acknowledgement

This is heavily inspired by the awesome metrics library.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

metrology-1.2.4.tar.gz (27.5 kB view details)

Uploaded Source

Built Distribution

metrology-1.2.4-py2.py3-none-any.whl (24.1 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file metrology-1.2.4.tar.gz.

File metadata

  • Download URL: metrology-1.2.4.tar.gz
  • Upload date:
  • Size: 27.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for metrology-1.2.4.tar.gz
Algorithm Hash digest
SHA256 8f591a59c961ae3536c7e7a04911cc7075ad169afd3a3963f60c55c11ae059ac
MD5 9e905fad02a2c21c27592eebe51b6561
BLAKE2b-256 5aa764875944c7be61c982058c5f3b5e043929016143c499fe6b5525c903b5f5

See more details on using hashes here.

File details

Details for the file metrology-1.2.4-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for metrology-1.2.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 544c8dd45a698a099a8c107f390565f359cbd84f8cb75c12d7b2f538adc622ac
MD5 697ba5f6f7b5c84a48f265795592c3e4
BLAKE2b-256 343ac35c69f8468d239d0bf20a76cb1163f874c91a8d72678597eb5e3e1e4a7d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page