6
6
try :
7
7
from opentelemetry import trace as trace_api
8
8
from opentelemetry .trace .status import StatusCanonicalCode
9
- from opentelemetry .sdk .trace import TracerProvider , export
10
- from opentelemetry .sdk .trace .export .in_memory_span_exporter import InMemorySpanExporter
11
9
except ImportError :
12
10
pass
13
11
16
14
17
15
from tests ._helpers import OpenTelemetryBase , HAS_OPENTELEMETRY_INSTALLED
18
16
17
+
19
18
def _make_rpc_error (error_cls , trailing_metadata = None ):
20
19
import grpc
21
20
@@ -29,8 +28,10 @@ def _make_session():
29
28
30
29
return mock .Mock (autospec = Session , instance = True )
31
30
31
+
32
32
# Skip all of these tests if we don't have OpenTelemetry
33
33
if HAS_OPENTELEMETRY_INSTALLED :
34
+
34
35
class TestNoTracing (unittest .TestCase ):
35
36
def setUp (self ):
36
37
self ._temp_opentelemetry = sys .modules ["opentelemetry" ]
@@ -46,7 +47,6 @@ def test_no_trace_call(self):
46
47
with _opentelemetry_tracing .trace_call ("Test" , _make_session ()) as no_span :
47
48
self .assertIsNone (no_span )
48
49
49
-
50
50
class TestTracing (OpenTelemetryBase ):
51
51
def test_trace_call (self ):
52
52
extra_attributes = {
@@ -75,9 +75,7 @@ def test_trace_call(self):
75
75
self .assertEqual (span .kind , trace_api .SpanKind .CLIENT )
76
76
self .assertEqual (span .attributes , expected_attributes )
77
77
self .assertEqual (span .name , "CloudSpanner.Test" )
78
- self .assertEqual (
79
- span .status .canonical_code , trace_api .status .StatusCanonicalCode .OK
80
- )
78
+ self .assertEqual (span .status .canonical_code , StatusCanonicalCode .OK )
81
79
82
80
def test_trace_error (self ):
83
81
extra_attributes = {"db.instance" : "database_name" }
0 commit comments