Skip to content

Commit

Permalink
Code review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
andmat900 committed Jun 7, 2024
1 parent 8db6718 commit d5ff7fe
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions projects/etos_suite_runner/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions projects/etos_suite_runner/src/etos_suite_runner/esr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 5 additions & 3 deletions projects/etos_suite_runner/src/etos_suite_runner/lib/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit d5ff7fe

Please sign in to comment.