Skip to main content

Metrics system for generating statistics about your app

Project description

Markus is a metrics generation library for generating statistics about your app.

Code:

https://github.com/willkg/markus

Issues:

https://github.com/willkg/markus/issues

License:

MPL v2

Documentation:

http://markus.readthedocs.io/en/latest/

Status:

Alpha

Goals

Markus makes it easier to add metrics generation to your app by:

  • providing multiple backends (Datadog statsd, logging, and so on) for sending data to multiple places

  • sending metrics to multiple backends

  • providing a testing framework for easy testing

  • providing a decoupled infrastructure making it easier to use metrics without having to worry about making sure your metrics client is configured and instantiated before the things that want to use it; it’s similar to the Python logging module in this way

Install

Run:

$ pip install markus

To install Datadog StatsD backend:

$ pip install markus[datadog]

Quick start

Similar to using the logging library, every Python module can create a MetricsInterface (loosely equivalent to a Python logging logger) at any time and use that to post metrics including module import time.

For example:

import markus

metrics = markus.get_metrics(__name__)

Then you can use it anywhere in that module:

@metrics.timer_decorator('chopping_vegetables')
def some_long_function(vegetable):
    for veg in vegetable:
        chop_vegetable()
        metrics.incr('vegetable', 1)

At application startup, configure Markus with the backends you want to use to publish metrics and any options they require.

For example, lets configure metrics to publish to logs and Datadog:

import markus

markus.configure(
    backends=[
        {
            # Log metrics to the logs
            'class': 'markus.backend.logging.LoggingMetrics',
        },
        {
            # Log metrics to Datadog
            'class': 'markus.backend.datadog.DatadogMetrics',
            'options': {
                'host': 'example.com',
                'port': 8125,
                'namespace': ''
            }
        }
    ]
)

When you’re writing your tests, use the MetricsMock to make testing easier:

import markus
from markus.testing import MetricsMock


def test_something():
    with MetricsMock() as mm:
        # ... Do things that might publish metrics

        # This helps you debug and write your test
        mm.print_metrics()

        # Make assertions on metrics published
        assert mm.has_metric(markus.INCR, 'some.key', {'value': 1})

History

0.1 (April 10th, 2017)

Initial writing.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

markus-0.1.tar.gz (23.1 kB view details)

Uploaded Source

Built Distribution

markus-0.1-py2.py3-none-any.whl (13.7 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file markus-0.1.tar.gz.

File metadata

  • Download URL: markus-0.1.tar.gz
  • Upload date:
  • Size: 23.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for markus-0.1.tar.gz
Algorithm Hash digest
SHA256 12e06e8518bbcede7d646ab7c0fa5ca4449ff514dad05fce06968d65b0426ce1
MD5 c866b3988a240f33579a1569b16056af
BLAKE2b-256 6f515d46c517422d8db9ec9ffe73bab17730db8e727a03c48f93e1d1e73fc60d

See more details on using hashes here.

Provenance

File details

Details for the file markus-0.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for markus-0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 f7552c1fcfdb87f1713c1f9d3302b0c8dd52b266e28e63b69c96190dd8d2b631
MD5 c4566909f9dce99b537dadbee51aa69a
BLAKE2b-256 887df81b083dff28ba812ddcfb2a201d58e22da746359bba8a933627ad55d64f

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page