__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
from typing import Callable
from urllib.parse import parse_qs
from .exposition import _bake_output
from .registry import CollectorRegistry, REGISTRY
def make_asgi_app(registry: CollectorRegistry = REGISTRY, disable_compression: bool = False) -> Callable:
"""Create a ASGI app which serves the metrics from a registry."""
async def prometheus_app(scope, receive, send):
assert scope.get("type") == "http"
# Prepare parameters
params = parse_qs(scope.get('query_string', b''))
accept_header = ",".join([
value.decode("utf8") for (name, value) in scope.get('headers')
if name.decode("utf8").lower() == 'accept'
])
accept_encoding_header = ",".join([
value.decode("utf8") for (name, value) in scope.get('headers')
if name.decode("utf8").lower() == 'accept-encoding'
])
# Bake output
status, headers, output = _bake_output(registry, accept_header, accept_encoding_header, params, disable_compression)
formatted_headers = []
for header in headers:
formatted_headers.append(tuple(x.encode('utf8') for x in header))
# Return output
payload = await receive()
if payload.get("type") == "http.request":
await send(
{
"type": "http.response.start",
"status": int(status.split(' ')[0]),
"headers": formatted_headers,
}
)
await send({"type": "http.response.body", "body": output})
return prometheus_app
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| __pycache__ | Folder | 0755 |
|
|
| bridge | Folder | 0755 |
|
|
| openmetrics | Folder | 0755 |
|
|
| twisted | Folder | 0755 |
|
|
| __init__.py | File | 1.77 KB | 0644 |
|
| asgi.py | File | 1.57 KB | 0644 |
|
| context_managers.py | File | 2.29 KB | 0644 |
|
| core.py | File | 860 B | 0644 |
|
| decorator.py | File | 15.43 KB | 0644 |
|
| exposition.py | File | 25.56 KB | 0644 |
|
| gc_collector.py | File | 1.48 KB | 0644 |
|
| metrics.py | File | 27.45 KB | 0644 |
|
| metrics_core.py | File | 15.18 KB | 0644 |
|
| mmap_dict.py | File | 5.27 KB | 0644 |
|
| multiprocess.py | File | 7.36 KB | 0644 |
|
| parser.py | File | 7.26 KB | 0644 |
|
| platform_collector.py | File | 1.83 KB | 0644 |
|
| process_collector.py | File | 3.77 KB | 0644 |
|
| py.typed | File | 0 B | 0644 |
|
| registry.py | File | 6.05 KB | 0644 |
|
| samples.py | File | 1.65 KB | 0644 |
|
| utils.py | File | 594 B | 0644 |
|
| values.py | File | 4.88 KB | 0644 |
|