Add setup time detail to diagnostics (#117766)

This commit is contained in:
J. Nick Koston 2024-05-19 21:52:28 -10:00 committed by GitHub
parent 13ba8e62a9
commit 149120b749
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 25 additions and 11 deletions

View file

@ -24,6 +24,7 @@ from homeassistant.helpers.json import (
from homeassistant.helpers.system_info import async_get_system_info
from homeassistant.helpers.typing import ConfigType
from homeassistant.loader import async_get_custom_components, async_get_integration
from homeassistant.setup import async_get_domain_setup_times
from homeassistant.util.json import format_unserializable_data
from .const import DOMAIN, REDACTED, DiagnosticsSubType, DiagnosticsType
@ -178,17 +179,15 @@ async def _async_get_json_file_response(
"version": cc_obj.version,
"requirements": cc_obj.requirements,
}
payload = {
"home_assistant": hass_sys_info,
"custom_components": custom_components,
"integration_manifest": integration.manifest,
"setup_times": async_get_domain_setup_times(hass, domain),
"data": data,
}
try:
json_data = json.dumps(
{
"home_assistant": hass_sys_info,
"custom_components": custom_components,
"integration_manifest": integration.manifest,
"data": data,
},
indent=2,
cls=ExtendedJSONEncoder,
)
json_data = json.dumps(payload, indent=2, cls=ExtendedJSONEncoder)
except TypeError:
_LOGGER.error(
"Failed to serialize to JSON: %s/%s%s. Bad data at %s",
@ -197,7 +196,7 @@ async def _async_get_json_file_response(
f"/{DiagnosticsSubType.DEVICE.value}/{sub_id}"
if sub_id is not None
else "",
format_unserializable_data(find_paths_unserializable_data(data)),
format_unserializable_data(find_paths_unserializable_data(payload)),
)
return web.Response(status=HTTPStatus.INTERNAL_SERVER_ERROR)