From b13a2057cc85c19aa9b4bec1f6f8266daa878107 Mon Sep 17 00:00:00 2001 From: Leighton Date: Tue, 17 Nov 2020 13:38:36 -0500 Subject: [PATCH] recording --- opentelemetry-api/src/opentelemetry/trace/status.py | 3 --- .../src/opentelemetry/sdk/trace/__init__.py | 10 +++------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/opentelemetry-api/src/opentelemetry/trace/status.py b/opentelemetry-api/src/opentelemetry/trace/status.py index 70897935799..ebc427db83b 100644 --- a/opentelemetry-api/src/opentelemetry/trace/status.py +++ b/opentelemetry-api/src/opentelemetry/trace/status.py @@ -19,9 +19,6 @@ logger = logging.getLogger(__name__) -EXCEPTION_STATUS_FIELD = "_otel_status_code" - - class StatusCode(enum.Enum): """Represents the canonical set of status codes of a finished Span.""" diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py b/opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py index facef291ac5..6328414ab37 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py @@ -44,11 +44,7 @@ from opentelemetry.sdk.util.instrumentation import InstrumentationInfo from opentelemetry.trace import SpanContext from opentelemetry.trace.propagation import SPAN_KEY -from opentelemetry.trace.status import ( - EXCEPTION_STATUS_FIELD, - Status, - StatusCode, -) +from opentelemetry.trace.status import Status, StatusCode from opentelemetry.util import time_ns, types logger = logging.getLogger(__name__) @@ -666,7 +662,7 @@ def __exit__( exc_tb: Optional[TracebackType], ) -> None: """Ends context manager and calls `end` on the `Span`.""" - if exc_val is not None: + if exc_val is not None and self.is_recording(): # Record the exception as an event # pylint:disable=protected-access if self._record_exception: @@ -857,7 +853,7 @@ def use_span( except Exception as exc: # pylint: disable=broad-except # Record the exception as an event - if isinstance(span, Span): + if isinstance(span, Span) and span.is_recording(): # pylint:disable=protected-access if span._record_exception: span.record_exception(exc)