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 54c1690a22..58cfa057b7 100644 --- a/plugins/callback/opentelemetry.py +++ b/plugins/callback/opentelemetry.py @@ -402,7 +402,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 """