Skip to content

Commit

Permalink
fix(opentelemetry): avoid storing inmemory if logs are disabled (ansi…
Browse files Browse the repository at this point in the history
…ble-collections#8373)

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

* changelog

* fix syntax

* refactor

* chore

* chore

* chore

* fix
  • Loading branch information
v1v authored and austinlucaslake committed May 25, 2024
1 parent 68a5067 commit c5a586f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
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 @@ -555,6 +555,12 @@ def set_options(self, task_keys=None, var_options=None, direct=None):

self.otel_exporter_otlp_traces_protocol = self.get_option('otel_exporter_otlp_traces_protocol')

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 @@ -604,23 +610,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

0 comments on commit c5a586f

Please sign in to comment.