Skip to content
This repository was archived by the owner on Mar 31, 2026. It is now read-only.

Commit 8c5b50b

Browse files
committed
Address review feedback
1 parent 6c8bb88 commit 8c5b50b

File tree

3 files changed

+13
-26
lines changed

3 files changed

+13
-26
lines changed

google/cloud/spanner_v1/_opentelemetry_tracing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
TRACER_NAME = "cloud.google.com/python/spanner"
3636
TRACER_VERSION = gapic_version.__version__
3737
extended_tracing_globally_disabled = (
38-
os.environ.get("SPANNER_ENABLE_EXTENDED_TRACING", "").lower() == "false"
38+
os.getenv("SPANNER_ENABLE_EXTENDED_TRACING", "").lower() == "false"
3939
)
4040

4141

@@ -68,7 +68,7 @@ def trace_call(name, session, extra_attributes=None, observability_options=None)
6868
# on by default.
6969
enable_extended_tracing = True
7070

71-
if type(observability_options) == dict: # Avoid false positives with mock.Mock
71+
if isinstance(observability_options, dict): # Avoid false positives with mock.Mock
7272
tracer_provider = observability_options.get("tracer_provider", None)
7373
enable_extended_tracing = observability_options.get(
7474
"enable_extended_tracing", enable_extended_tracing

google/cloud/spanner_v1/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ class Client(ClientWithProject):
126126
for all ReadRequests and ExecuteSqlRequests that indicates which replicas
127127
or regions should be used for non-transactional reads or queries.
128128
129-
:type labels: dict (str -> any) or None
129+
:type observability_options: dict (str -> any) or None
130130
:param observability_options: (Optional) the configuration to control
131131
the tracer's behavior.
132132
tracer_provider is the injected tracer provider

tests/system/test_observability_options.py

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@
1414

1515
import mock
1616
import pytest
17-
import unittest
1817

1918
from . import _helpers
20-
from google.cloud.spanner_v1 import Client, DirectedReadOptions
19+
from google.cloud.spanner_v1 import Client
2120

2221
HAS_OTEL_INSTALLED = False
2322

@@ -35,32 +34,20 @@
3534
pass
3635

3736

38-
@pytest.mark.skipif(not HAS_OTEL_INSTALLED, reason="OpenTelemetry needed.")
39-
@pytest.mark.skipif(not _helpers.USE_EMULATOR, reason="Emulator needed.")
37+
@pytest.mark.skipif(
38+
not HAS_OTEL_INSTALLED, reason="OpenTelemetry is necessary to test traces."
39+
)
40+
@pytest.mark.skipif(
41+
not _helpers.USE_EMULATOR, reason="mulator is necessary to test traces."
42+
)
4043
def test_observability_options_propagation():
4144
PROJECT = _helpers.EMULATOR_PROJECT
42-
PATH = "projects/%s" % (PROJECT,)
4345
CONFIGURATION_NAME = "config-name"
4446
INSTANCE_ID = _helpers.INSTANCE_ID
45-
INSTANCE_NAME = "%s/instances/%s" % (PATH, INSTANCE_ID)
4647
DISPLAY_NAME = "display-name"
4748
DATABASE_ID = _helpers.unique_id("temp_db")
4849
NODE_COUNT = 5
49-
PROCESSING_UNITS = 5000
5050
LABELS = {"test": "true"}
51-
TIMEOUT_SECONDS = 80
52-
LEADER_OPTIONS = ["leader1", "leader2"]
53-
DIRECTED_READ_OPTIONS = {
54-
"include_replicas": {
55-
"replica_selections": [
56-
{
57-
"location": "us-west1",
58-
"type_": DirectedReadOptions.ReplicaSelection.Type.READ_ONLY,
59-
},
60-
],
61-
"auto_failover_disabled": True,
62-
},
63-
}
6451

6552
def test_propagation(enable_extended_tracing):
6653
global_tracer_provider = TracerProvider(sampler=ALWAYS_ON)
@@ -95,13 +82,13 @@ def test_propagation(enable_extended_tracing):
9582

9683
try:
9784
instance.create()
98-
except:
85+
except Exception:
9986
pass
10087

10188
db = instance.database(DATABASE_ID)
10289
try:
10390
db.create()
104-
except:
91+
except Exception:
10592
pass
10693

10794
assert db.observability_options == observability_options
@@ -134,7 +121,7 @@ def test_propagation(enable_extended_tracing):
134121
try:
135122
db.delete()
136123
instance.delete()
137-
except:
124+
except Exception:
138125
pass
139126

140127
# Test the respective options for enable_extended_tracing

0 commit comments

Comments
 (0)