Coder Social home page Coder Social logo

damiendube / metrology Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cyberdelia/metrology

0.0 2.0 0.0 184 KB

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

Home Page: http://metrology.readthedocs.org

License: MIT License

Python 94.09% Shell 5.91%

metrology's Introduction

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

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

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

Profilers

A profiler measures the distribution of the duration passed in a every part of the code

profiler = Metrology.profiler('slow-code')
with profiler:
    run_slow_code()

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

Acknowledgement

This is heavily inspired by the awesome metrics library.

metrology's People

Contributors

arturdryomov avatar cyberdelia avatar damiendube avatar jacobian avatar zvin avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.