cwtimer

Pythonic timing tracker with reporting to Cloudwatch


Keywords
timer, aws, boto3, cloudwatch, python
License
MIT
Install
pip install cwtimer==0.0.2

Documentation

cwtimer

'cwtimer' does one simple thing, track the timing of a 'with' statement block and report to AWS Cloudwatch.

Install

$ pip install cwtimer

Example

from cwtimer import cwtimer
import time

with cwtimer(namespace='MyNameSpace', metric_name='MyMetric',
             dimensions={'MyDimension': 'Value'}):
    time.sleep(1)
    # 1.0s reported to cloudwatch metric

Simpler

from functools import partial
from cwtimer import cwtimer
import time

mytimer = partial(
    cwtimer,
    namespace='MyNameSpace',
    metric_name='MyMetric',
    dimensions={'MyDimension': 'Value'},
)

with mytimer():
    time.sleep(1)
    # 1.0s reported