ansible-collections / community.general

Ansible Community General Collection
https://galaxy.ansible.com/ui/repo/published/community/general/
GNU General Public License v3.0
822 stars 1.52k forks source link

opentelemetry: Use nested spans to organize output for role dependencies or include_roles #8219

Open monsdar opened 6 months ago

monsdar commented 6 months ago

Summary

I am using the community.general.opentelemetry callback plugin to analyze the execution of my playbooks in Jaeger. Within my deployments I use roles that depend on other roles and roles that get included via ansible.builtin.include_role. Currently the execution of a playbook gets displayed in Jaegers timeline view as a sequence of traces.

I'm not 100% sure about the technical feasibility, but I'd like to suggest showing roles that are included by other roles as nested traces. That way when I have a lot of includes I could open/close them and focus on what's really interesting to me.

Issue Type

Feature Idea

Component Name

opentelemetry

Additional Information

No response

Code of Conduct

ansibullbot commented 6 months ago

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

ansibullbot commented 6 months ago

cc @v1v click here for bot help

v1v commented 6 months ago

Can you provide a playbook with examples of what you get and want? This would help determine whether it's feasible. 🙇

monsdar commented 5 months ago

I've got the following structure:

span_tests.yml

- name: Do some tests that use spans
  hosts: all
  tasks:
    - name: PlaybookFoo
      ansible.builtin.pause:
        seconds: 5
    - ansible.builtin.include_role:
        name: child_span
    - name: PlaybookBar
      ansible.builtin.pause:
        seconds: 5

roles/child_span/tasks/main.yml:

- name: ChildBaz
  ansible.builtin.pause:
    seconds: 5

This results in the following Jaeger trace:

image

I'd like to have the tasks from the role as nested into the include_role-span. That would allow to collapse the tasks and see how long the include has taken in general.

image

There are other operations besides include_role like include_tasks, include_playbookand their import counterparts. This could even work for role-dependencies.

I think for more complex roles changing to nested spans will make the resulting graphs much better to handle.