{"id":22041942,"url":"https://github.com/cdayz/blacksheep-prometheus","last_synced_at":"2025-10-05T13:22:27.152Z","repository":{"id":40300073,"uuid":"377461463","full_name":"Cdayz/blacksheep-prometheus","owner":"Cdayz","description":"Prometheus integration for BlackSheep","archived":false,"fork":false,"pushed_at":"2023-03-06T13:00:57.000Z","size":124,"stargazers_count":5,"open_issues_count":6,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-08T00:52:48.510Z","etag":null,"topics":["asgi","asyncio","blacksheep","metrics","middleware","prometheus","python3"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Cdayz.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-06-16T10:44:10.000Z","updated_at":"2024-03-01T16:34:21.000Z","dependencies_parsed_at":"2023-02-01T02:46:07.701Z","dependency_job_id":null,"html_url":"https://github.com/Cdayz/blacksheep-prometheus","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cdayz%2Fblacksheep-prometheus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cdayz%2Fblacksheep-prometheus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cdayz%2Fblacksheep-prometheus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cdayz%2Fblacksheep-prometheus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Cdayz","download_url":"https://codeload.github.com/Cdayz/blacksheep-prometheus/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252978725,"owners_count":21834914,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asgi","asyncio","blacksheep","metrics","middleware","prometheus","python3"],"created_at":"2024-11-30T12:10:37.153Z","updated_at":"2025-10-05T13:22:22.101Z","avatar_url":"https://github.com/Cdayz.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Blacksheep Prometheus\n\n[![Build Status](https://github.com/Cdayz/blacksheep-prometheus/workflows/Continuous%20Integration/badge.svg)](https://github.com/Cdayz/blacksheep-prometheus/actions)\n[![codecov](https://codecov.io/gh/Cdayz/blacksheep-prometheus/branch/master/graph/badge.svg?token=YJTGKBTQSE)](https://codecov.io/gh/Cdayz/blacksheep-prometheus)\n[![Package Version](https://img.shields.io/pypi/v/blacksheep-prometheus?logo=PyPI\u0026logoColor=white)](https://pypi.org/project/blacksheep-prometheus/)\n[![PyPI Version](https://img.shields.io/pypi/pyversions/blacksheep-prometheus?logo=Python\u0026logoColor=white)](https://pypi.org/project/blacksheep-prometheus/)\n\n## Introduction\n\nPrometheus integration for Blacksheep.\n\n## Requirements\n\n* Python 3.7+\n* Blacksheep 1.0.7+\n\n## Installation\n\n```console\n$ pip install blacksheep-prometheus\n```\n\n## Usage\n\nA complete example that exposes prometheus metrics endpoint under default `/metrics/` endpoint.\n\n```python\nfrom blacksheep.server import Application\nfrom blacksheep_prometheus import use_prometheus_metrics\n\napp = Application()\nuse_prometheus_metrics(app)\n```\n\n### Options\n\n| Option name                       | Description                                         | Default value                     |\n|-----------------------------------|-----------------------------------------------------|-----------------------------------|\n|`requests_total_metric_name`       | name of metric for total requests                   |`'backsheep_requests_total'`       |\n|`responses_total_metric_name`      | name of metric for total responses                  |`'backsheep_responses_total'`      |\n|`request_time_seconds_metric_name` | name of metric for request timings                  |`'backsheep_request_time_seconds'` |\n|`exceptions_metric_name`           | name of metric for exceptions                       |`'backsheep_exceptions'`           |\n|`requests_in_progress_metric_name` | name of metric for in progress requests             |`'backsheep_requests_in_progress'` |\n|`filter_paths`                     | list of path's where do not need to collect metrics |`[]`                               |\n\n\n### Custom metrics\n\nblacksheep-prometheus will export all the prometheus metrics from the process, so custom metrics can be created by using the prometheus_client API.\n\n*Example:*\n```python\nfrom prometheus_client import Counter\nfrom blacksheep.server.responses import redirect\n\nREDIRECT_COUNT = Counter(\"redirect_total\", \"Count of redirects\", (\"from_view\",))\n\nasync def some_view(request):\n    REDIRECT_COUNT.labels(from_view=\"some_view\").inc()\n    return redirect(\"https://example.com\")\n```\n\nThe new metric will now be included in the the `/metrics` endpoint output:\n```\n...\nredirect_total{from_view=\"some_view\"} 2.0\n...\n```\n\n## Contributing\n\nThis project is absolutely open to contributions so if you have a nice idea, create an issue to let the community \ndiscuss it.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcdayz%2Fblacksheep-prometheus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcdayz%2Fblacksheep-prometheus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcdayz%2Fblacksheep-prometheus/lists"}