Skip to content

Send runtime measurements of your Python code to InfluxDB

License

Notifications You must be signed in to change notification settings

trehn/timekeeper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Timekeeper is a library for instrumentation of live Python code by sending measurements to InfluxDB.

Requires Python 2.7 or 3.2+, and InfluxDB 0.9.0+.

Usage

You can use a context manager or decorate a function to record the wall clock time of how long it took that function or block of code to complete:

from timekeeper import TimeKeeper

tk = TimeKeeper(
    "udp+influxdb://localhost/databasename",
    prefix="location-1.cluster-1.app-1.",  # if you prefer Graphite style over tags
    tags={"host": "location-1.cluster-1.app-1"},
)


@tk.decorate("some_slow_function", tags={"foo": "bar"})
def slowpoke():
    sleep(9001)


def slowpoke2():
    with tk.context("some_other_slow_function", tags={"foo": "baz"}):
        sleep(9001)

Installation

pip install timekeeper

PyPI downloads   PyPI version   Python 2.7   Python 3.2+   License

About

Send runtime measurements of your Python code to InfluxDB

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages