Compare commits

...

5 commits

Author SHA1 Message Date
softwarefactory-project-zuul[bot]
da1713ed3e
Merge pull request #440 from jsquyres/pr/json-callback-path
json[l] callback: add play/task path info

Add the play and task path info (i.e., filename and line number) to the JSON that is emitted from the json and jsonl callback plugins, allowing more accurate post-mortem analysis.
SUMMARY
Add the play and task path info (i.e., filename and line number) to the JSON that is emitted from the json and jsonl callback plugins, allowing more accurate post-mortem analysis.
ISSUE TYPE

Feature Pull Request

COMPONENT NAME

ansible.posix.json
ansible.posix.jsonl

ADDITIONAL INFORMATION
By also including the file/line number in the JSON data emitted, post-mortem analysis can unambiguously tie play/task log data to the specific play / task that generated it.  Without this information, it could be difficult for automated processes to precisely map log output back to the task that generated it (especially with playbooks that either do not name tasks, or do not name tasks uniquely).
Using this trivial playbook shows the change:
- hosts: localhost
  gather_facts: false
  tasks:
    - name: hello, world
      debug:
        msg: hello, world
When using the json callback, here's what it looks like before the change (for brevity, just the plays section of the output):
        {
            "play": {
                "duration": {
                    "end": "2023-04-08T11:35:39.694000Z",
                    "start": "2023-04-08T11:35:39.657056Z"
                },
                "id": "acde4800-1122-6387-7abd-000000000001",
                "name": "localhost",
            },
            "tasks": [
                {
                    "hosts": {
                        "localhost": {
                            "_ansible_no_log": null,
                            "_ansible_verbose_always": true,
                            "action": "debug",
                            "changed": false,
                            "msg": "hello, world"
                        }
                    },
                    "task": {
                        "duration": {
                            "end": "2023-04-08T11:35:39.694000Z",
                            "start": "2023-04-08T11:35:39.672132Z"
                        },
                        "id": "acde4800-1122-6387-7abd-000000000003",
                        "name": "hello, world",
                    }
                }
            ]
        }
After the change, there is a new path key/value in both the play and the task:
        {
            "play": {
                "duration": {
                    "end": "2023-04-08T11:35:39.694000Z",
                    "start": "2023-04-08T11:35:39.657056Z"
                },
                "id": "acde4800-1122-6387-7abd-000000000001",
                "name": "localhost",
                "path": "/tmp/plays/hello.yaml:1"
            },
            "tasks": [
                {
                    "hosts": {
                        "localhost": {
                            "_ansible_no_log": null,
                            "_ansible_verbose_always": true,
                            "action": "debug",
                            "changed": false,
                            "msg": "hello, world"
                        }
                    },
                    "task": {
                        "duration": {
                            "end": "2023-04-08T11:35:39.694000Z",
                            "start": "2023-04-08T11:35:39.672132Z"
                        },
                        "id": "acde4800-1122-6387-7abd-000000000003",
                        "name": "hello, world",
                        "path": "/tmp/plays/hello.yaml:4"
                    }
                }
            ]
        }
The effect is the same in the jsonl plugin, but the output is squashed into a single line.

Reviewed-by: Adam Miller <admiller@redhat.com>
2023-04-18 03:24:12 +00:00
softwarefactory-project-zuul[bot]
7fb9cc95c3
Merge pull request #435 from ziegenberg/fix-412
docs: fix profile_tasks callback documentation

SUMMARY

This fixes the markup.
Fixes: #412
ISSUE TYPE


Docs Pull Request

COMPONENT NAME

profile_tasks
ADDITIONAL INFORMATION


None.

Reviewed-by: Hideki Saito <saito@fgrep.org>
Reviewed-by: Adam Miller <admiller@redhat.com>
2023-04-18 01:52:07 +00:00
Jeff Squyres
940d914904 json[l] callback: add play/task path info
Add the play and task path info (i.e., filename and line number) to
the JSON that is emitted from the json and jsonl callback plugins,
allowing more accurate post-mortem analysis.

Signed-off-by: Jeff Squyres <jsquyres@cisco.com>
2023-04-12 09:55:44 -04:00
Daniel Ziegenberg
7d069b597f
add changelog fragment
Signed-off-by: Daniel Ziegenberg <daniel@ziegenberg.at>
2023-04-10 15:13:22 +02:00
Daniel Ziegenberg
009ed3bed5
docs: fix profile_tasks callback documentation
Fixes: #412

Signed-off-by: Daniel Ziegenberg <daniel@ziegenberg.at>
2023-03-24 11:47:00 +01:00
5 changed files with 10 additions and 1 deletions

View file

@ -0,0 +1,3 @@
---
trivial:
- fix profile_tasks callback documentation by using correct markup

View file

@ -0,0 +1,2 @@
minor_changes:
- json and jsonl - Add the ``path`` attribute into the play and task output

View file

@ -67,6 +67,7 @@ class CallbackModule(CallbackBase):
'play': { 'play': {
'name': play.get_name(), 'name': play.get_name(),
'id': to_text(play._uuid), 'id': to_text(play._uuid),
'path': to_text(play.get_path()),
'duration': { 'duration': {
'start': current_time() 'start': current_time()
} }
@ -79,6 +80,7 @@ class CallbackModule(CallbackBase):
'task': { 'task': {
'name': task.get_name(), 'name': task.get_name(),
'id': to_text(task._uuid), 'id': to_text(task._uuid),
'path': to_text(task.get_path()),
'duration': { 'duration': {
'start': current_time() 'start': current_time()
} }

View file

@ -69,6 +69,7 @@ class CallbackModule(CallbackBase):
'play': { 'play': {
'name': play.get_name(), 'name': play.get_name(),
'id': to_text(play._uuid), 'id': to_text(play._uuid),
'path': to_text(play.get_path()),
'duration': { 'duration': {
'start': current_time() 'start': current_time()
} }
@ -81,6 +82,7 @@ class CallbackModule(CallbackBase):
'task': { 'task': {
'name': task.get_name(), 'name': task.get_name(),
'id': to_text(task._uuid), 'id': to_text(task._uuid),
'path': to_text(task.get_path()),
'duration': { 'duration': {
'start': current_time() 'start': current_time()
} }

View file

@ -17,7 +17,7 @@ DOCUMENTATION = '''
- Ansible callback plugin for timing individual tasks and overall execution time. - Ansible callback plugin for timing individual tasks and overall execution time.
- "Mashup of 2 excellent original works: https://github.com/jlafon/ansible-profile, - "Mashup of 2 excellent original works: https://github.com/jlafon/ansible-profile,
https://github.com/junaid18183/ansible_home/blob/master/ansible_plugins/callback_plugins/timestamp.py.old" https://github.com/junaid18183/ansible_home/blob/master/ansible_plugins/callback_plugins/timestamp.py.old"
- "Format: C(<task start timestamp> (<length of previous task>) <current elapsed playbook execution time>)" - "Format: C(<task start timestamp>) C(<length of previous task>) C(<current elapsed playbook execution time>)"
- It also lists the top/bottom time consuming tasks in the summary (configurable) - It also lists the top/bottom time consuming tasks in the summary (configurable)
- Before 2.4 only the environment variables were available for configuration. - Before 2.4 only the environment variables were available for configuration.
requirements: requirements: