Skip to main content

log-metrics

log-metrics is a tiny metrics logger, based on the l2met format. Meant for use on Heroku, his allows you to send custom metrics to Librato.

You can find more information on these custom metrics here.

Installation

$ pip install log-metrics

Usage

Everything takes place from the log_metrics module, which can be imported like so:

>>> import log_metrics

Samples

>>> log_metrics.sample('process.foo.memory.mb', '52.54')
sample#process.foo.memory.mb=52.54

Measurements

>>> log_metrics.measure('myfoo.ms', '150')
measure#myfoo.ms=150

Uniques

>>> log_metrics.unique('user.clicked', 'bob')
unique#user.clicked=bob
>>> log_metrics.unique('user.clicked', 'joey')
unique#user.clicked=joey
>>> log_metrics.unique('user.clicked', 'jenny')
unique#user.clicked=jenny

Counters

>>> log_metrics.increment('myfoo')
count#myfoo=1
>>> log_metrics.increment('myfoo', 3)
count#myfoo=3

Timers

>>> with log_metrics.timer('my-timed-context'):
...     time.sleep(1)
measure#my-timed-context.ms=1001.20
>>> @log_metrics.timer('my-timed-decorator'):
... def my_func():
...     time.sleep(0.5)
>>> my_func()
measure#my-timed-decorator.ms=504.20

Metric Groups

>>> with log_metrics.group() as g:
...     g.measure('my-measurement', 2)
...     g.increment('my-counter')
measure#my-measurement=2 count#my-counter=1
>>> g = log_metrics.group()
>>> g.measure('my-measurement', 2)
>>> g.increment('my-counter')
>>> g.emit()
measure#my-measurement=2 count#my-counter=1

Sources and Prefixes

Sources and prefixes can be defined like so:

>>> log_metrics.increment('my-counter', prefix='awesome')
count#awesome.my-counter=1
>>> log_metrics.measure('my-measurement', 50, source='testing')
source=testing measure#my-measurement=50

These arguments are also supported for group functions:

>>> g = log_metrics.group(prefix='my-prefix', source='my-metric-source')
>>> g.increment('my-amount')
>>> g.increment('my-measurement')
>>> g.emit()
source=my-metric-source count#my-prefix.my-amount=1 count#my-prefix.my-amount1=1 count#my-prefix.my-amount2=1

History

0.0.4 (2014-04-17)

  • ‘group’ API now operational outside of a context manager.

  • Minor code changes.

0.0.3 (2014-04-14)

  • Introduced the ‘group’ API.

0.0.2 (2014-04-14)

  • Added more documentation for simple usage.

  • Worked on installation utilities.

  • Still no tests :(.

0.0.1 (2014-04-14)

  • Initial release.

Metadata

Release files for log-metrics 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for log-metrics 0.0.4
File Size Uploaded Provenance Actions
log-metrics-0.0.4.tar.gz 4.4 kB Without provenance Details for log-metrics-0.0.4.tar.gz

Release files / log-metrics-0.0.4.tar.gz

Download URL log-metrics-0.0.4.tar.gz
Size 4.4 kB
Tags Source
SHA-256 checksum
How to use checksums
893ff6fea326f139577aa6569b0eba93cf1216d0fadc9fe588b0a757fe82b479
BLAKE2b-256 checksum
How to use checksums
a96d5274c945fd62a78a2f6b12081ec8b4de105c2ede039ee5e42aac546a6ff9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for log-metrics 0.0.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.4 This release

1 release file No provenance

0

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page