1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

[PR #8430/5041ebe5 backport][stable-9] fix(opentelemetry): remove request from the logs (#8458)

fix(opentelemetry): remove request from the logs (#8430)

* fix(opentelemetry): remove request from the logs

* add changelog

* filter by task

* add new bugfix

* rename

* support legacy and shortcat ansible tasks

* Update plugins/callback/opentelemetry.py

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 5041ebe5b2)

Co-authored-by: Victor Martinez <victormartinezrubio@gmail.com>
This commit is contained in:
patchback[bot] 2024-06-03 07:15:49 +02:00 committed by GitHub
parent f227038f38
commit 9b8011d692
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 5 deletions

View file

@ -0,0 +1,3 @@
bugfixes:
- opentelemetry callback - do not save the JSON response when using the ``ansible.builtin.uri`` module (https://github.com/ansible-collections/community.general/pull/8430).
- opentelemetry callback - do not save the content response when using the ``ansible.builtin.slurp`` module (https://github.com/ansible-collections/community.general/pull/8430).

View file

@ -556,11 +556,19 @@ class CallbackModule(CallbackBase):
self.otel_exporter_otlp_traces_protocol = self.get_option('otel_exporter_otlp_traces_protocol') self.otel_exporter_otlp_traces_protocol = self.get_option('otel_exporter_otlp_traces_protocol')
def dump_results(self, result): def dump_results(self, task, result):
""" dump the results if disable_logs is not enabled """ """ dump the results if disable_logs is not enabled """
if self.disable_logs: if self.disable_logs:
return "" return ""
return self._dump_results(result._result) # ansible.builtin.uri contains the response in the json field
save = dict(result._result)
if "json" in save and task.action in ("ansible.builtin.uri", "ansible.legacy.uri", "uri"):
save.pop("json")
# ansible.builtin.slurp contains the response in the content field
if "content" in save and task.action in ("ansible.builtin.slurp", "ansible.legacy.slurp", "slurp"):
save.pop("content")
return self._dump_results(save)
def v2_playbook_on_start(self, playbook): def v2_playbook_on_start(self, playbook):
self.ansible_playbook = basename(playbook._file_name) self.ansible_playbook = basename(playbook._file_name)
@ -611,7 +619,7 @@ class CallbackModule(CallbackBase):
self.tasks_data, self.tasks_data,
status, status,
result, result,
self.dump_results(result) self.dump_results(self.tasks_data[result._task._uuid], result)
) )
def v2_runner_on_ok(self, result): def v2_runner_on_ok(self, result):
@ -619,7 +627,7 @@ class CallbackModule(CallbackBase):
self.tasks_data, self.tasks_data,
'ok', 'ok',
result, result,
self.dump_results(result) self.dump_results(self.tasks_data[result._task._uuid], result)
) )
def v2_runner_on_skipped(self, result): def v2_runner_on_skipped(self, result):
@ -627,7 +635,7 @@ class CallbackModule(CallbackBase):
self.tasks_data, self.tasks_data,
'skipped', 'skipped',
result, result,
self.dump_results(result) self.dump_results(self.tasks_data[result._task._uuid], result)
) )
def v2_playbook_on_include(self, included_file): def v2_playbook_on_include(self, included_file):