From d5ff7fe7666fca36d2580b35016cf13491d05d71 Mon Sep 17 00:00:00 2001 From: Andrei Matveyeu Date: Fri, 7 Jun 2024 14:58:23 +0200 Subject: [PATCH] Code review changes --- projects/etos_suite_runner/setup.cfg | 4 ++-- projects/etos_suite_runner/src/etos_suite_runner/esr.py | 5 +---- .../etos_suite_runner/src/etos_suite_runner/lib/suite.py | 8 +++++--- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/projects/etos_suite_runner/setup.cfg b/projects/etos_suite_runner/setup.cfg index 15bc0c5..30f9c78 100644 --- a/projects/etos_suite_runner/setup.cfg +++ b/projects/etos_suite_runner/setup.cfg @@ -28,8 +28,8 @@ install_requires = PyScaffold==3.2.3 packageurl-python~=0.11 cryptography>=42.0.4,<43.0.0 - etos_lib==4.3.0 - etos_environment_provider~=4.3 + #etos_lib==4.3.1 + #etos_environment_provider~=4.3 opentelemetry-api~=1.21 opentelemetry-exporter-otlp~=1.21 opentelemetry-sdk~=1.21 diff --git a/projects/etos_suite_runner/src/etos_suite_runner/esr.py b/projects/etos_suite_runner/src/etos_suite_runner/esr.py index 9fdbe21..4c004f4 100644 --- a/projects/etos_suite_runner/src/etos_suite_runner/esr.py +++ b/projects/etos_suite_runner/src/etos_suite_runner/esr.py @@ -67,9 +67,6 @@ def __init__(self) -> None: int(os.getenv("ESR_WAIT_FOR_ENVIRONMENT_TIMEOUT")), ) - self.otel_context = None - self.otel_context_token = None - def __del__(self): """Destructor.""" if self.otel_context_token is not None: @@ -120,7 +117,7 @@ def _request_environment(self, ids: list[str], otel_context_carrier: dict) -> No :param otel_context_carrier: a dict carrying current OpenTelemetry context. """ # OpenTelemetry contexts aren't propagated to threads automatically. - # For this reason otel_context needs to be restantiated due to + # For this reason otel_context needs to be reinstantiated due to # this method running in a separate thread. otel_context = TraceContextTextMapPropagator().extract(carrier=otel_context_carrier) otel_context_token = opentelemetry.context.attach(otel_context) diff --git a/projects/etos_suite_runner/src/etos_suite_runner/lib/suite.py b/projects/etos_suite_runner/src/etos_suite_runner/lib/suite.py index c27036d..452b29b 100644 --- a/projects/etos_suite_runner/src/etos_suite_runner/lib/suite.py +++ b/projects/etos_suite_runner/src/etos_suite_runner/lib/suite.py @@ -18,7 +18,7 @@ import logging import threading import time -from typing import Iterator +from typing import Iterator, Union from eiffellib.events import EiffelTestSuiteStartedEvent from environment_provider.lib.registry import ProviderRegistry @@ -202,8 +202,7 @@ def __init__( etos: ETOS, params: ESRParameters, suite: dict, - # pylint: disable=dangerous-default-value - otel_context_carrier: dict = {}, + otel_context_carrier: Union[dict, None] = None, ) -> None: """Initialize a TestSuite instance.""" self.etos = etos @@ -213,6 +212,9 @@ def __init__( self.logger.addFilter(DuplicateFilter(self.logger)) self.sub_suites = [] + if otel_context_carrier is None: + otel_context_carrier = {} + self.otel_context_carrier = otel_context_carrier self.otel_context = TraceContextTextMapPropagator().extract( carrier=self.otel_context_carrier