From 4a03abf6a7fe21ffdf88d79495929dd1c6adda89 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 11 Nov 2024 11:13:48 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/pubtools/_impl/tracing.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/pubtools/_impl/tracing.py b/src/pubtools/_impl/tracing.py index f1a1828..3b3261d 100644 --- a/src/pubtools/_impl/tracing.py +++ b/src/pubtools/_impl/tracing.py @@ -20,7 +20,10 @@ def func(): from opentelemetry.sdk.trace import TracerProvider from opentelemetry.sdk.trace.export import BatchSpanProcessor, ConsoleSpanExporter from opentelemetry.trace import Status, StatusCode - from opentelemetry.trace.propagation.tracecontext import TraceContextTextMapPropagator + from opentelemetry.trace.propagation.tracecontext import ( + TraceContextTextMapPropagator, + ) + OPENTELEMETRY_AVAILABLE = True except ImportError: # Clients aren't expected to have open-telemetry. This flag will be used in @@ -66,11 +69,16 @@ def _reset(self): # trace.set_tracer_provider global singleton set below can *never* be set up # more than once in a single process. - self._enabled_trace = (os.getenv("OTEL_TRACING", "").lower() == "true") \ - and OPENTELEMETRY_AVAILABLE - if (os.getenv("OTEL_TRACING", "").lower() == "true") and not OPENTELEMETRY_AVAILABLE: - log.debug("Tracing is enabled but the open telemetry package is " - "unavailable. Tracing functionality will be disabled.") + self._enabled_trace = ( + os.getenv("OTEL_TRACING", "").lower() == "true" + ) and OPENTELEMETRY_AVAILABLE + if ( + os.getenv("OTEL_TRACING", "").lower() == "true" + ) and not OPENTELEMETRY_AVAILABLE: + log.debug( + "Tracing is enabled but the open telemetry package is " + "unavailable. Tracing functionality will be disabled." + ) if self._enabled_trace and not self._processor: log.info("Creating TracingWrapper instance") exporter = pm.hook.otel_exporter() or ConsoleSpanExporter()