Add support for tracing script execution#48276
Add support for tracing script execution#48276emontnemery merged 2 commits intohome-assistant:devfrom
Conversation
|
Hey there @home-assistant/core, mind taking a look at this pull request as its been labeled with an integration ( |
| await self._changed.wait() | ||
|
|
||
| async def _async_run(self, variables, context): | ||
| with trace_script( |
There was a problem hiding this comment.
Do we need to create a new context here?
There was a problem hiding this comment.
No. Script context is passed in, that's fine.
| @@ -335,6 +339,16 @@ async def async_turn_on(self, **kwargs): | |||
| self.hass.async_create_task(coro) | |||
There was a problem hiding this comment.
The result of this is never checked, and exceptions may be silently swallowed.
Should that be fixed?
| from homeassistant.core import Context | ||
| from homeassistant.helpers.trace import TraceElement, trace_id_set | ||
| from homeassistant.util import dt as dt_util | ||
| from homeassistant.components.trace import AutomationTrace, async_store_trace |
There was a problem hiding this comment.
Shouldn't AutomationTrace be renamed or, if it is automation specific, be in this file?
There was a problem hiding this comment.
|
|
||
|
|
||
| @contextmanager | ||
| def trace_automation(hass, item_id, config, context): |
There was a problem hiding this comment.
if it's automation specific, should we keep calling it automation_id ?
| return result | ||
|
|
||
|
|
||
| class AutomationTrace(ActionTrace): |
There was a problem hiding this comment.
Let's move this to automation/trace.py
| return result | ||
|
|
||
|
|
||
| class ScriptTrace(ActionTrace): |
| # mypy: allow-untyped-calls, allow-untyped-defs | ||
|
|
||
| TRACE_DOMAINS = ["automation"] | ||
| TRACE_DOMAINS = ["automation", "script"] |
There was a problem hiding this comment.
| TRACE_DOMAINS = ["automation", "script"] | |
| TRACE_DOMAINS = ("automation", "script") |
Proposed change
Add support for tracing script execution
Type of change
Additional information
Checklist
black --fast homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all..coveragerc.The integration reached or maintains the following Integration Quality Scale:
To help with the load of incoming pull requests: