asgi-prometheus


Nameasgi-prometheus JSON
Version 1.2.3 PyPI version JSON
download
home_pageNone
SummarySupport Prometheus metrics for ASGI applications
upload_time2024-07-31 13:25:31
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseMIT License
keywords asyncio trio curio asgi prometheus
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ASGI-Prometheus
###############

.. _description:

**asgi-prometheus** -- Support Prometheus metrics for ASGI applications (Asyncio_ / Trio_, / Curio_)

.. _badges:

.. image:: https://github.com/klen/asgi-prometheus/workflows/tests/badge.svg
    :target: https://github.com/klen/asgi-prometheus/actions
    :alt: Tests Status

.. image:: https://img.shields.io/pypi/v/asgi-prometheus
    :target: https://pypi.org/project/asgi-prometheus/
    :alt: PYPI Version

.. image:: https://img.shields.io/pypi/pyversions/asgi-prometheus
    :target: https://pypi.org/project/asgi-prometheus/
    :alt: Python Versions

.. _contents:

.. contents::

.. _requirements:

Requirements
=============

- python >= 3.9

.. _installation:

Installation
=============

**asgi-prometheus** should be installed using pip: ::

    pip install asgi-prometheus

Usage
=====

Common ASGI applications:

.. code:: python

    from asgi_prometheus import PrometheusMiddleware


    async def my_app(scope, receive, send):
        """Read session and get the current user data from it or from request query."""
        await send({"type": "http.response.start", "status": status, "headers": headers})
        await send({"type": "http.response.body", "body": b"Hello World!"})

    app = PrometheusMiddleware(my_app, metrics_url="/metrics", group_paths=['/'])

    # http GET / -> OK
    # http GET /metrics -> [Prometheus metrics]


As `ASGI-Tools`_ Internal middleware

.. code:: python

    from asgi_tools import App
    from asgi_prometheus import PrometheusMiddleware

    app = App()
    app.middleware(PrometheusMiddleware.setup(group_paths=['/views', '/api']))

    @app.route('/')
    async def index(request):
        return 'Hello World!'

    # http GET / -> OK
    # http GET /prometheus -> [Prometheus metrics (default URL)]


Options
========

.. code:: python

   from asgi_sessions import PrometheusMiddleware

   app = PrometheusMiddleware(

        # Your ASGI application
        app,

        # Metrics URL for Prometheus (set empty string to disable)
        metrics_url='/prometheus',

        # List of path's prefixes to group. A path which starts from the prefix will be grouped.
        # For example: group_paths=['/api/users'], "/api/users/1", "/api/users/2" will be grouped into "/api/users*"
        group_paths=[],

   )

.. _bugtracker:

Bug tracker
===========

If you have any suggestions, bug reports or
annoyances please report them to the issue tracker
at https://github.com/klen/asgi-prometheus/issues

.. _contributing:

Contributing
============

Development of the project happens at: https://github.com/klen/asgi-prometheus

.. _license:

License
========

Licensed under a `MIT license`_.


.. _links:

.. _MIT license: http://opensource.org/licenses/MIT
.. _Asyncio: https://docs.python.org/3/library/asyncio.html
.. _klen: https://github.com/klen
.. _Trio: https://trio.readthedocs.io/en/stable/
.. _Curio: https://curio.readthedocs.io/en/latest/
.. _ASGI-Tools: https://github.com/klen/asgi-tools

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "asgi-prometheus",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "asyncio, trio, curio, asgi, prometheus",
    "author": null,
    "author_email": "Kirill Klenov <horneds@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/7e/f0/59eeda10f472c450969042b952ce3b6f390ef41d683b7986d909237f2b16/asgi_prometheus-1.2.3.tar.gz",
    "platform": null,
    "description": "ASGI-Prometheus\n###############\n\n.. _description:\n\n**asgi-prometheus** -- Support Prometheus metrics for ASGI applications (Asyncio_ / Trio_, / Curio_)\n\n.. _badges:\n\n.. image:: https://github.com/klen/asgi-prometheus/workflows/tests/badge.svg\n    :target: https://github.com/klen/asgi-prometheus/actions\n    :alt: Tests Status\n\n.. image:: https://img.shields.io/pypi/v/asgi-prometheus\n    :target: https://pypi.org/project/asgi-prometheus/\n    :alt: PYPI Version\n\n.. image:: https://img.shields.io/pypi/pyversions/asgi-prometheus\n    :target: https://pypi.org/project/asgi-prometheus/\n    :alt: Python Versions\n\n.. _contents:\n\n.. contents::\n\n.. _requirements:\n\nRequirements\n=============\n\n- python >= 3.9\n\n.. _installation:\n\nInstallation\n=============\n\n**asgi-prometheus** should be installed using pip: ::\n\n    pip install asgi-prometheus\n\nUsage\n=====\n\nCommon ASGI applications:\n\n.. code:: python\n\n    from asgi_prometheus import PrometheusMiddleware\n\n\n    async def my_app(scope, receive, send):\n        \"\"\"Read session and get the current user data from it or from request query.\"\"\"\n        await send({\"type\": \"http.response.start\", \"status\": status, \"headers\": headers})\n        await send({\"type\": \"http.response.body\", \"body\": b\"Hello World!\"})\n\n    app = PrometheusMiddleware(my_app, metrics_url=\"/metrics\", group_paths=['/'])\n\n    # http GET / -> OK\n    # http GET /metrics -> [Prometheus metrics]\n\n\nAs `ASGI-Tools`_ Internal middleware\n\n.. code:: python\n\n    from asgi_tools import App\n    from asgi_prometheus import PrometheusMiddleware\n\n    app = App()\n    app.middleware(PrometheusMiddleware.setup(group_paths=['/views', '/api']))\n\n    @app.route('/')\n    async def index(request):\n        return 'Hello World!'\n\n    # http GET / -> OK\n    # http GET /prometheus -> [Prometheus metrics (default URL)]\n\n\nOptions\n========\n\n.. code:: python\n\n   from asgi_sessions import PrometheusMiddleware\n\n   app = PrometheusMiddleware(\n\n        # Your ASGI application\n        app,\n\n        # Metrics URL for Prometheus (set empty string to disable)\n        metrics_url='/prometheus',\n\n        # List of path's prefixes to group. A path which starts from the prefix will be grouped.\n        # For example: group_paths=['/api/users'], \"/api/users/1\", \"/api/users/2\" will be grouped into \"/api/users*\"\n        group_paths=[],\n\n   )\n\n.. _bugtracker:\n\nBug tracker\n===========\n\nIf you have any suggestions, bug reports or\nannoyances please report them to the issue tracker\nat https://github.com/klen/asgi-prometheus/issues\n\n.. _contributing:\n\nContributing\n============\n\nDevelopment of the project happens at: https://github.com/klen/asgi-prometheus\n\n.. _license:\n\nLicense\n========\n\nLicensed under a `MIT license`_.\n\n\n.. _links:\n\n.. _MIT license: http://opensource.org/licenses/MIT\n.. _Asyncio: https://docs.python.org/3/library/asyncio.html\n.. _klen: https://github.com/klen\n.. _Trio: https://trio.readthedocs.io/en/stable/\n.. _Curio: https://curio.readthedocs.io/en/latest/\n.. _ASGI-Tools: https://github.com/klen/asgi-tools\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "Support Prometheus metrics for ASGI applications",
    "version": "1.2.3",
    "project_urls": {
        "homepage": "https://github.com/klen/asgi-prometheus",
        "repository": "https://github.com/klen/asgi-prometheus"
    },
    "split_keywords": [
        "asyncio",
        " trio",
        " curio",
        " asgi",
        " prometheus"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "016c43a1a98f014e9aab28bf3a1bd77d5182df12cd057131486352bde0013ec4",
                "md5": "9234b242fe5a3197db2d023f4e0514a1",
                "sha256": "c37e0d8dbd7561fd169511d4f0fde0c040d4e89e58ee4889a29fcf4bff0fef78"
            },
            "downloads": -1,
            "filename": "asgi_prometheus-1.2.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9234b242fe5a3197db2d023f4e0514a1",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 5041,
            "upload_time": "2024-07-31T13:25:29",
            "upload_time_iso_8601": "2024-07-31T13:25:29.456425Z",
            "url": "https://files.pythonhosted.org/packages/01/6c/43a1a98f014e9aab28bf3a1bd77d5182df12cd057131486352bde0013ec4/asgi_prometheus-1.2.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7ef059eeda10f472c450969042b952ce3b6f390ef41d683b7986d909237f2b16",
                "md5": "7094cb5982c524caeb8029cad3e2c5c3",
                "sha256": "8e047959ff1cef1b1bad9ddce46723a8f030ad7e7b98bb3d58e1b1619ad166b8"
            },
            "downloads": -1,
            "filename": "asgi_prometheus-1.2.3.tar.gz",
            "has_sig": false,
            "md5_digest": "7094cb5982c524caeb8029cad3e2c5c3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 5114,
            "upload_time": "2024-07-31T13:25:31",
            "upload_time_iso_8601": "2024-07-31T13:25:31.088307Z",
            "url": "https://files.pythonhosted.org/packages/7e/f0/59eeda10f472c450969042b952ce3b6f390ef41d683b7986d909237f2b16/asgi_prometheus-1.2.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-31 13:25:31",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "klen",
    "github_project": "asgi-prometheus",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "asgi-prometheus"
}
        
Elapsed time: 0.36496s