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

opentelemetry: honour ignore errors (#3837) (#3847)

* opentelemetry: honour the ignore_errors

* fix-encoding-pragma

* Add changelog fragment

* opentelemetry: ignore produces unset span status

(cherry picked from commit ce6d0a749e)

Co-authored-by: Victor Martinez <victormartinezrubio@gmail.com>
This commit is contained in:
patchback[bot] 2021-12-04 19:55:17 +01:00 committed by GitHub
parent 7a6770c731
commit cc76d684d5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- opentelemetry_plugin - honour ``ignore_errors`` when a task has failed instead of reporting an error (https://github.com/ansible-collections/community.general/pull/3837).

View file

@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
# (C) 2021, Victor Martinez <VictorMartinezRubio@gmail.com> # (C) 2021, Victor Martinez <VictorMartinezRubio@gmail.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
@ -267,6 +268,8 @@ class OpenTelemetrySource(object):
elif host_data.status == 'skipped': elif host_data.status == 'skipped':
message = res['skip_reason'] if 'skip_reason' in res else 'skipped' message = res['skip_reason'] if 'skip_reason' in res else 'skipped'
status = Status(status_code=StatusCode.UNSET) status = Status(status_code=StatusCode.UNSET)
elif host_data.status == 'ignored':
status = Status(status_code=StatusCode.UNSET)
span.set_status(status) span.set_status(status)
if isinstance(task_data.args, dict) and "gather_facts" not in task_data.action: if isinstance(task_data.args, dict) and "gather_facts" not in task_data.action:
@ -462,10 +465,15 @@ class CallbackModule(CallbackBase):
) )
def v2_runner_on_failed(self, result, ignore_errors=False): def v2_runner_on_failed(self, result, ignore_errors=False):
if ignore_errors:
status = 'ignored'
else:
status = 'failed'
self.errors += 1 self.errors += 1
self.opentelemetry.finish_task( self.opentelemetry.finish_task(
self.tasks_data, self.tasks_data,
'failed', status,
result result
) )