Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable-7] fix(opentelemetry): avoid storing inmemory if logs are disabled (#8373) #8391

Merged
merged 1 commit into from
May 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelogs/fragments/8373-honour-disable-logs.yaml
Original file line number Diff line number Diff line change
@@ -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).

12 changes: 9 additions & 3 deletions plugins/callback/opentelemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,12 @@ def set_options(self, task_keys=None, var_options=None, direct=None):
# See https://github.com/open-telemetry/opentelemetry-specification/issues/740
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):
self.ansible_playbook = basename(playbook._file_name)

Expand Down Expand Up @@ -547,23 +553,23 @@ def v2_runner_on_failed(self, result, ignore_errors=False):
self.tasks_data,
status,
result,
self._dump_results(result._result)
self.dump_results(result)
)

def v2_runner_on_ok(self, result):
self.opentelemetry.finish_task(
self.tasks_data,
'ok',
result,
self._dump_results(result._result)
self.dump_results(result)
)

def v2_runner_on_skipped(self, result):
self.opentelemetry.finish_task(
self.tasks_data,
'skipped',
result,
self._dump_results(result._result)
self.dump_results(result)
)

def v2_playbook_on_include(self, included_file):
Expand Down
Loading