Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Nov 11, 2024
1 parent 2c6a40a commit 4a03abf
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/pubtools/_impl/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 4a03abf

Please sign in to comment.