• Stars
    star
    307
  • Rank 136,109 (Top 3 %)
  • Language
    Python
  • License
    MIT License
  • Created over 12 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

Metrology

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()

Tagging metrics

All metrics can be tagged if the reporter supports it (currently: Graphite, Librato, Logger. The StatsD reporter supports the Datadog tag format because no official tag standard has been devised by the project). Tags can be arbitrary key-value pairs. Just assign a dict as metric name. A 'name'-entry is required.

counter = Metrology.counter({
  'name': 'pending-jobs',
  'host': 'backend',
  'priority': 'high'
})
counter.increment()
counter.decrement()
counter.count

All metric types support tagging.

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.

More Repositories

1

flask-mysql

Flask extension for python-mysql
Python
116
star
2

heroku-geo-buildpack

Geo libraries for Heroku
Shell
114
star
3

logfmt-ruby

Parse log lines in the logfmt style.
Ruby
65
star
4

trunk

Making postgres listen/notify easier.
Python
58
star
5

statsd

A client library for statsd written in Go
Go
48
star
6

go-metrics-graphite

Graphite client for the go-metrics
Go
36
star
7

manifesto

Pluggable cache manifest for Django
Python
33
star
8

lzo

lzo implements reading and writing of lzop format compressed files
Go
29
star
9

atomic

An atomic class that guarantees atomic updates to its contained value.
Python
23
star
10

templates

Bundle templates
Go
17
star
11

circuitry

A circuit breaker implementation in Go
Go
12
star
12

instax

Monitoring celery with statsd
Python
12
star
13

flask-statsd

Access statsd from you app
Python
11
star
14

sequel-caller-location

Add comments or the caller location to your SQL
Ruby
9
star
15

kales

A modern OpenCalais client
Python
9
star
16

peafowl

Peafowl is a powerful but simple messaging server that enables reliable distributed queuing with an absolutely minimal overhead by using memcache protocol for maximum cross-platform compatibility.
Python
9
star
17

perlinpinpin

Convert french fuzzy date to a python datetime object.
Python
8
star
18

tusk

Distributed lock with Postgres
Python
7
star
19

pricing

A pyke example
Python
7
star
20

flink-kotlin

Kotlin support for Apache Flink
Kotlin
7
star
21

starlark

Starlark as a standalone java library.
Starlark
6
star
22

treehash

A SHA256 Tree Hash implementation in Go
Go
5
star
23

sequel-vault

Encrypt Sequel attribute
Ruby
5
star
24

aws

An Amazon S3 client and a bit more.
Go
5
star
25

law

It's the law
Go
5
star
26

sequel-password

Sequel plugins to handle password hashing
Ruby
4
star
27

pelican-heroku

Deploy your pelican site on Heroku
Python
4
star
28

astrolabe

Fast, high resolution timer library for recording performance metrics
Python
3
star
29

macaroon

Cookies with contextual caveats
Kotlin
3
star
30

pipeline

Compose I/O pipeline
Go
3
star
31

accrual

A Ο† accrual failure detector
Go
3
star
32

chartbeat

A charbeat/newsbeat API wrapper.
Python
2
star
33

lz4

lz4 implements reading and writing of lz4 format compressed file or stream
Go
2
star
34

dynamodb

An intelligible dynamodb client
Go
2
star
35

integrity

Verify checksum data pages for PostgreSQL
Go
2
star
36

woodpecker

Collecting metrics over discrete time intervals
Swift
1
star
37

signals

S3 Streaming Client
Kotlin
1
star
38

ratio

Rate limited I/O
Go
1
star
39

ganglia

Sending metric to Ganglia
Python
1
star
40

havilland

A generic single flight
Go
1
star
41

fernet-rack

A rack middleware for authentication with fernet
Ruby
1
star
42

entrance-to-english-bay

Entrance to English Bay weather data.
TypeScript
1
star
43

halibut-bank

Halibut Bank buoy weather data
TypeScript
1
star
44

bang

Bang! Load your web app.
Go
1
star