mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 20:27:08 +00:00
Generate Prometheus metrics in an executor job (#121058)
This commit is contained in:
parent
16827ea09e
commit
36e74cd9a6
@ -26,7 +26,7 @@ from homeassistant.components.cover import (
|
||||
ATTR_CURRENT_POSITION,
|
||||
ATTR_CURRENT_TILT_POSITION,
|
||||
)
|
||||
from homeassistant.components.http import HomeAssistantView
|
||||
from homeassistant.components.http import KEY_HASS, HomeAssistantView
|
||||
from homeassistant.components.humidifier import ATTR_AVAILABLE_MODES, ATTR_HUMIDITY
|
||||
from homeassistant.components.light import ATTR_BRIGHTNESS
|
||||
from homeassistant.components.sensor import SensorDeviceClass
|
||||
@ -729,7 +729,11 @@ class PrometheusView(HomeAssistantView):
|
||||
"""Handle request for Prometheus metrics."""
|
||||
_LOGGER.debug("Received Prometheus metrics request")
|
||||
|
||||
hass = request.app[KEY_HASS]
|
||||
body = await hass.async_add_executor_job(
|
||||
prometheus_client.generate_latest, prometheus_client.REGISTRY
|
||||
)
|
||||
return web.Response(
|
||||
body=prometheus_client.generate_latest(prometheus_client.REGISTRY),
|
||||
body=body,
|
||||
content_type=CONTENT_TYPE_TEXT_PLAIN,
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user