1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-06-05 07:47:12 +00:00
community.general/tests/unit
Alexander Freiherr von Buddenbrock 23bd56990c
Start opentelemetry spans on host start instead of task start (#11434)
* Start opentelemetry spans on host start instead of task start

v2_playbook_on_task_start does not have the host information, so spans
would always start at the same time for every host in that task, even if
they started at different times, like when hosts > forks with strategy
host_pinned. This also hides the duration of the task for that host.

This change uses the newer v2_runner_on_start callback and adds the acutal
host start time to the span. The change is backwards compatible with ansible
versions that do not have v2_runner_on_start and makes no assumptions around
the ordering of v2_runner_on_start and v2_playbook_on_task_start.

* Add changelog fragment

* Remove redundant callback hooks

v2_runner_on_starts gets called by ansible right after the strategy has called on_task_start or on_handler_start. So there is no need to keep this code as the minimum ansible-core version is guaranteed to have this function. on_cleanup (removed around ansible-core 2.0) and on_no_hosts (removed around ansible-core 2.5) never get called.

* Fix unreachable hosts causing exceptions

If finish_task is never called for a host the result object stays None, which caused an exception in update_span_data. This was the case for unreachable hosts, as the callback plugin did not implement v2_runner_on_unreachable.

* Fix import order in test_opentelemetry
2026-05-17 11:28:15 +02:00
..
plugins Start opentelemetry spans on host start instead of task start (#11434) 2026-05-17 11:28:15 +02:00
requirements.txt nsupdate: add unit tests (#11677) 2026-03-26 21:37:16 +01:00
requirements.yml Adjust YAML files (#10233) 2025-06-15 09:13:16 +02:00