Name | markus JSON |
Version |
5.1.0
JSON |
| download |
home_page | None |
Summary | Metrics system for generating statistics about your app |
upload_time | 2024-10-30 23:26:31 |
maintainer | None |
docs_url | None |
author | Will Kahn-Greene |
requires_python | >=3.9 |
license | MPLv2 |
keywords |
metrics
datadog
statsd
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
======
Markus
======
Markus is a Python library for generating metrics.
:Code: https://github.com/willkg/markus
:Issues: https://github.com/willkg/markus/issues
:License: MPL v2
:Documentation: http://markus.readthedocs.io/en/latest/
Goals
=====
Markus makes it easier to generate metrics in your program by:
* providing multiple backends (Datadog statsd, statsd, logging, logging rollup,
and so on) for sending data to different places
* sending metrics to multiple backends at the same time
* providing a testing framework for easy testing
* providing a decoupled architecture making it easier to write code to generate
metrics without having to worry about making sure creating and configuring a
metrics client has been done--similar to the Python logging Python logging
module in this way
I use it at Mozilla in the collector of our crash ingestion pipeline. Peter used
it to build our symbols lookup server, too.
Install
=======
To install Markus, run::
$ pip install markus
(Optional) To install the requirements for the
``markus.backends.statsd.StatsdMetrics`` backend::
$ pip install 'markus[statsd]'
(Optional) To install the requirements for the
``markus.backends.datadog.DatadogMetrics`` backend::
$ pip install 'markus[datadog]'
Quick start
===========
Similar to using the logging library, every Python module can create a
``markus.main.MetricsInterface`` (loosely equivalent to a Python
logging logger) at any time including at module import time and use that to
generate metrics.
For example::
import markus
metrics = markus.get_metrics(__name__)
Creating a ``markus.main.MetricsInterface`` using ``__name__``
will cause it to generate all stats keys with a prefix determined from
``__name__`` which is a dotted Python path to that module.
Then you can use the ``markus.main.MetricsInterface`` anywhere in that
module::
@metrics.timer_decorator("chopping_vegetables")
def some_long_function(vegetable):
for veg in vegetable:
chop_vegetable()
metrics.incr("vegetable", value=1)
At application startup, configure Markus with the backends you want and any
options they require to publish metrics.
For example, let us configure Markus to publish metrics to the Python logging
infrastructure and Datadog::
import markus
markus.configure(
backends=[
{
# Publish metrics to the Python logging infrastructure
"class": "markus.backends.logging.LoggingMetrics",
},
{
# Publish metrics to Datadog
"class": "markus.backends.datadog.DatadogMetrics",
"options": {
"statsd_host": "example.com",
"statsd_port": 8125,
"statsd_namespace": ""
}
}
]
)
Once you've added code that publishes metrics, you'll want to test it and make
sure it's working correctly. Markus comes with a ``markus.testing.MetricsMock``
to make testing and asserting specific outcomes easier::
from markus.testing import MetricsMock
def test_something():
with MetricsMock() as mm:
# ... Do things that might publish metrics
# Make assertions on metrics published
mm.assert_incr_once("some.key", value=1)
Raw data
{
"_id": null,
"home_page": null,
"name": "markus",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "metrics, datadog, statsd",
"author": "Will Kahn-Greene",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/82/ee/3fe05626efbbdbdfc5897cd79da7d30c0daec974146cef439ad7805df3b0/markus-5.1.0.tar.gz",
"platform": null,
"description": "======\nMarkus\n======\n\nMarkus is a Python library for generating metrics.\n\n:Code: https://github.com/willkg/markus\n:Issues: https://github.com/willkg/markus/issues\n:License: MPL v2\n:Documentation: http://markus.readthedocs.io/en/latest/\n\n\nGoals\n=====\n\nMarkus makes it easier to generate metrics in your program by:\n\n* providing multiple backends (Datadog statsd, statsd, logging, logging rollup,\n and so on) for sending data to different places\n\n* sending metrics to multiple backends at the same time\n\n* providing a testing framework for easy testing\n\n* providing a decoupled architecture making it easier to write code to generate\n metrics without having to worry about making sure creating and configuring a\n metrics client has been done--similar to the Python logging Python logging\n module in this way\n\nI use it at Mozilla in the collector of our crash ingestion pipeline. Peter used\nit to build our symbols lookup server, too.\n\n\nInstall\n=======\n\nTo install Markus, run::\n\n $ pip install markus\n\n(Optional) To install the requirements for the\n``markus.backends.statsd.StatsdMetrics`` backend::\n\n $ pip install 'markus[statsd]'\n\n(Optional) To install the requirements for the\n``markus.backends.datadog.DatadogMetrics`` backend::\n\n $ pip install 'markus[datadog]'\n\n\nQuick start\n===========\n\nSimilar to using the logging library, every Python module can create a\n``markus.main.MetricsInterface`` (loosely equivalent to a Python\nlogging logger) at any time including at module import time and use that to\ngenerate metrics.\n\nFor example::\n\n import markus\n\n metrics = markus.get_metrics(__name__)\n\n\nCreating a ``markus.main.MetricsInterface`` using ``__name__``\nwill cause it to generate all stats keys with a prefix determined from\n``__name__`` which is a dotted Python path to that module.\n\nThen you can use the ``markus.main.MetricsInterface`` anywhere in that\nmodule::\n\n @metrics.timer_decorator(\"chopping_vegetables\")\n def some_long_function(vegetable):\n for veg in vegetable:\n chop_vegetable()\n metrics.incr(\"vegetable\", value=1)\n\n\nAt application startup, configure Markus with the backends you want and any\noptions they require to publish metrics.\n\nFor example, let us configure Markus to publish metrics to the Python logging\ninfrastructure and Datadog::\n\n import markus\n\n markus.configure(\n backends=[\n {\n # Publish metrics to the Python logging infrastructure\n \"class\": \"markus.backends.logging.LoggingMetrics\",\n },\n {\n # Publish metrics to Datadog\n \"class\": \"markus.backends.datadog.DatadogMetrics\",\n \"options\": {\n \"statsd_host\": \"example.com\",\n \"statsd_port\": 8125,\n \"statsd_namespace\": \"\"\n }\n }\n ]\n )\n\n\nOnce you've added code that publishes metrics, you'll want to test it and make\nsure it's working correctly. Markus comes with a ``markus.testing.MetricsMock``\nto make testing and asserting specific outcomes easier::\n\n from markus.testing import MetricsMock\n\n\n def test_something():\n with MetricsMock() as mm:\n # ... Do things that might publish metrics\n\n # Make assertions on metrics published\n mm.assert_incr_once(\"some.key\", value=1)\n",
"bugtrack_url": null,
"license": "MPLv2",
"summary": "Metrics system for generating statistics about your app",
"version": "5.1.0",
"project_urls": {
"Documentation": "https://markus.readthedocs.io/",
"Homepage": "https://github.com/willkg/markus",
"Issues": "https://github.com/willkg/markus/issues",
"Source": "https://github.com/willkg/markus/"
},
"split_keywords": [
"metrics",
" datadog",
" statsd"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "c6b11ec837b0fbfebff48b2ae265721d197aa32d7d2ec0a30bb0334c5172ec1d",
"md5": "c69bda7fe9b9a75ba4f8312e6424fc1a",
"sha256": "424172efdccc35172b8aadfdcd753412c3ed2b5651c3b3bc9e0b7e7f2e97da52"
},
"downloads": -1,
"filename": "markus-5.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c69bda7fe9b9a75ba4f8312e6424fc1a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 26209,
"upload_time": "2024-10-30T23:26:30",
"upload_time_iso_8601": "2024-10-30T23:26:30.458759Z",
"url": "https://files.pythonhosted.org/packages/c6/b1/1ec837b0fbfebff48b2ae265721d197aa32d7d2ec0a30bb0334c5172ec1d/markus-5.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "82ee3fe05626efbbdbdfc5897cd79da7d30c0daec974146cef439ad7805df3b0",
"md5": "4c1743c7445a09f22b13c0131cd4eb86",
"sha256": "a4ec2d6bb1dcf471638be11a10cb5708de8cc3092ade9cf3b38bb2f651ede33a"
},
"downloads": -1,
"filename": "markus-5.1.0.tar.gz",
"has_sig": false,
"md5_digest": "4c1743c7445a09f22b13c0131cd4eb86",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 38640,
"upload_time": "2024-10-30T23:26:31",
"upload_time_iso_8601": "2024-10-30T23:26:31.708637Z",
"url": "https://files.pythonhosted.org/packages/82/ee/3fe05626efbbdbdfc5897cd79da7d30c0daec974146cef439ad7805df3b0/markus-5.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-30 23:26:31",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "willkg",
"github_project": "markus",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "markus"
}