From eff8ca8d9b348470b4ca4e330c24a038632ba1a1 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Sun, 19 May 2024 21:32:06 +0200 Subject: [PATCH] [PR #8367/03240ad7 backport][stable-8] fix(opentelemetry): close span even if no logs are sent (#8389) fix(opentelemetry): close span even if no logs are sent (#8367) * fix(opentelemetry): close span even if no logs are sent * changelog (cherry picked from commit 03240ad7dc57aefc14b1ceba3e08abec0c62500b) Co-authored-by: Victor Martinez --- changelogs/fragments/8367-fix-close-span-if-no-logs.yaml | 2 ++ plugins/callback/opentelemetry.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/8367-fix-close-span-if-no-logs.yaml diff --git a/changelogs/fragments/8367-fix-close-span-if-no-logs.yaml b/changelogs/fragments/8367-fix-close-span-if-no-logs.yaml new file mode 100644 index 0000000000..e0a90be311 --- /dev/null +++ b/changelogs/fragments/8367-fix-close-span-if-no-logs.yaml @@ -0,0 +1,2 @@ +bugfixes: + - "opentelemetry callback plugin - close spans always (https://github.com/ansible-collections/community.general/pull/8367)." diff --git a/plugins/callback/opentelemetry.py b/plugins/callback/opentelemetry.py index 492e420716..bd34a364c1 100644 --- a/plugins/callback/opentelemetry.py +++ b/plugins/callback/opentelemetry.py @@ -350,7 +350,8 @@ class OpenTelemetrySource(object): if not disable_logs: # This will avoid populating span attributes to the logs span.add_event(task_data.dump, attributes={} if disable_attributes_in_logs else attributes) - span.end(end_time=host_data.finish) + # Close span always + span.end(end_time=host_data.finish) def set_span_attributes(self, span, attributes): """ update the span attributes with the given attributes if not None """