From 753ec6c272273c5d941d43ce836e304e23c75ad0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Neum=C3=BCller?= Date: Fri, 18 Dec 2020 22:52:08 +0100 Subject: [PATCH] Add some repr()s to basic trace types. (#1485) --- CHANGELOG.md | 2 ++ opentelemetry-api/src/opentelemetry/trace/span.py | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f6bd54ab483..e2d0b55121b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ([#1420](https://github.com/open-telemetry/opentelemetry-python/pull/1420)) - `opentelemetry-exporter-zipkin` Add support for array attributes in Span and Resource exports ([#1285](https://github.com/open-telemetry/opentelemetry-python/pull/1285)) +- Added `__repr__` for `DefaultSpan`, added `trace_flags` to `__repr__` of + `SpanContext` ([#1485](https://github.com/open-telemetry/opentelemetry-python/pull/1485)]) ## [0.16b1](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v0.16b1) - 2020-11-26 ### Added diff --git a/opentelemetry-api/src/opentelemetry/trace/span.py b/opentelemetry-api/src/opentelemetry/trace/span.py index 6506f6f949d..507b0513684 100644 --- a/opentelemetry-api/src/opentelemetry/trace/span.py +++ b/opentelemetry-api/src/opentelemetry/trace/span.py @@ -237,11 +237,12 @@ def __delattr__(self, *args: str) -> None: def __repr__(self) -> str: return ( - "{}(trace_id={}, span_id={}, trace_state={!r}, is_remote={})" + "{}(trace_id={}, span_id={}, trace_flags=0x{:02x}, trace_state={!r}, is_remote={})" ).format( type(self).__name__, format_trace_id(self.trace_id), format_span_id(self.span_id), + self.trace_flags, self.trace_state, self.is_remote, ) @@ -291,6 +292,9 @@ def record_exception( ) -> None: pass + def __repr__(self) -> str: + return "DefaultSpan({!r})".format(self._context) + INVALID_SPAN_ID = 0x0000000000000000 INVALID_TRACE_ID = 0x00000000000000000000000000000000