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

[stabe-8] fix(opentelemetry): avoid storing inmemory if logs are disabled (#8373) (#8390)

fix(opentelemetry): avoid storing inmemory if logs are disabled (#8373)

* fix(opentelemetry): avoid storing inmemory if logs are disabled

* changelog

* fix syntax

* refactor

* chore

* chore

* chore

* fix

(cherry picked from commit d87b9fe0dc)

Co-authored-by: Victor Martinez <victormartinezrubio@gmail.com>
This commit is contained in:
Felix Fontein 2024-05-19 21:57:27 +02:00 committed by GitHub
parent eff8ca8d9b
commit 0a0e132d80
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 3 deletions

View file

@ -0,0 +1,3 @@
bugfixes:
- opentelemetry callback plugin - honour the ``disable_logs`` option to avoid storing task results since they are not used regardless (https://github.com/ansible-collections/community.general/pull/8373).

View file

@ -498,6 +498,12 @@ class CallbackModule(CallbackBase):
# See https://github.com/open-telemetry/opentelemetry-specification/issues/740 # See https://github.com/open-telemetry/opentelemetry-specification/issues/740
self.traceparent = self.get_option('traceparent') self.traceparent = self.get_option('traceparent')
def dump_results(self, result):
""" dump the results if disable_logs is not enabled """
if self.disable_logs:
return ""
return self._dump_results(result._result)
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)
@ -547,7 +553,7 @@ class CallbackModule(CallbackBase):
self.tasks_data, self.tasks_data,
status, status,
result, result,
self._dump_results(result._result) self.dump_results(result)
) )
def v2_runner_on_ok(self, result): def v2_runner_on_ok(self, result):
@ -555,7 +561,7 @@ class CallbackModule(CallbackBase):
self.tasks_data, self.tasks_data,
'ok', 'ok',
result, result,
self._dump_results(result._result) self.dump_results(result)
) )
def v2_runner_on_skipped(self, result): def v2_runner_on_skipped(self, result):
@ -563,7 +569,7 @@ class CallbackModule(CallbackBase):
self.tasks_data, self.tasks_data,
'skipped', 'skipped',
result, result,
self._dump_results(result._result) self.dump_results(result)
) )
def v2_playbook_on_include(self, included_file): def v2_playbook_on_include(self, included_file):