Skip to content

Commit fe6ca67

Browse files
committed
refactor(storage): align debug metrics environment variable naming with OTEL convention
- Rename GCP_STORAGE_PYTHON_ENABLE_DEBUG_METRICS to GCP_STORAGE_PYTHON_ENABLE_OTEL_DEBUG_METRICS - Rename ENABLE_DEBUG_METRICS_ENV_VAR constant to ENABLE_OTEL_DEBUG_METRICS_ENV_VAR - Update corresponding unit tests in test__opentelemetry_metrics.py
1 parent e2a7562 commit fe6ca67

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

‎packages/google-cloud-storage/google/cloud/storage/_opentelemetry_metrics.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
# 2. Standardized Configuration and Environment Variable Names
3434
# ---------------------------------------------------------------------------
3535
ENABLE_OTEL_METRICS_ENV_VAR = "GCP_STORAGE_PYTHON_ENABLE_OTEL_METRICS"
36-
ENABLE_DEBUG_METRICS_ENV_VAR = "GCP_STORAGE_PYTHON_ENABLE_DEBUG_METRICS"
36+
ENABLE_OTEL_DEBUG_METRICS_ENV_VAR = "GCP_STORAGE_PYTHON_ENABLE_OTEL_DEBUG_METRICS"
3737

3838
_DEFAULT_ENABLE_METRICS = False
3939
_DEFAULT_ENABLE_DEBUG_METRICS = False
@@ -110,7 +110,9 @@ def is_advanced_metrics_enabled(
110110
if client_setting is not None:
111111
return client_setting
112112

113-
return _parse_bool_env(ENABLE_DEBUG_METRICS_ENV_VAR, _DEFAULT_ENABLE_DEBUG_METRICS)
113+
return _parse_bool_env(
114+
ENABLE_OTEL_DEBUG_METRICS_ENV_VAR, _DEFAULT_ENABLE_DEBUG_METRICS
115+
)
114116

115117

116118
# ---------------------------------------------------------------------------

‎packages/google-cloud-storage/tests/unit/test__opentelemetry_metrics.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def test_advanced_metrics_requires_base_metrics(monkeypatch):
125125
"""Advanced metrics cannot be active if base metrics are disabled."""
126126
monkeypatch.setattr(_opentelemetry_metrics, "_ENABLE_METRICS_DEV_GATE", True)
127127
monkeypatch.setenv("GCP_STORAGE_PYTHON_ENABLE_OTEL_METRICS", "false")
128-
monkeypatch.setenv("GCP_STORAGE_PYTHON_ENABLE_DEBUG_METRICS", "true")
128+
monkeypatch.setenv("GCP_STORAGE_PYTHON_ENABLE_OTEL_DEBUG_METRICS", "true")
129129

130130
assert _opentelemetry_metrics.is_advanced_metrics_enabled() is False
131131
assert (
@@ -140,7 +140,7 @@ def test_advanced_metrics_enabled(monkeypatch):
140140
"""Advanced metrics is enabled when both base and debug flags are True."""
141141
monkeypatch.setattr(_opentelemetry_metrics, "_ENABLE_METRICS_DEV_GATE", True)
142142
monkeypatch.setenv("GCP_STORAGE_PYTHON_ENABLE_OTEL_METRICS", "true")
143-
monkeypatch.setenv("GCP_STORAGE_PYTHON_ENABLE_DEBUG_METRICS", "true")
143+
monkeypatch.setenv("GCP_STORAGE_PYTHON_ENABLE_OTEL_DEBUG_METRICS", "true")
144144

145145
assert _opentelemetry_metrics.is_advanced_metrics_enabled() is True
146146

@@ -151,13 +151,13 @@ def test_advanced_metrics_client_setting_overrides_env_var(monkeypatch):
151151
monkeypatch.setenv("GCP_STORAGE_PYTHON_ENABLE_OTEL_METRICS", "true")
152152

153153
# Client enables while debug env var is False
154-
monkeypatch.setenv("GCP_STORAGE_PYTHON_ENABLE_DEBUG_METRICS", "false")
154+
monkeypatch.setenv("GCP_STORAGE_PYTHON_ENABLE_OTEL_DEBUG_METRICS", "false")
155155
assert (
156156
_opentelemetry_metrics.is_advanced_metrics_enabled(client_setting=True) is True
157157
)
158158

159159
# Client disables while debug env var is True
160-
monkeypatch.setenv("GCP_STORAGE_PYTHON_ENABLE_DEBUG_METRICS", "true")
160+
monkeypatch.setenv("GCP_STORAGE_PYTHON_ENABLE_OTEL_DEBUG_METRICS", "true")
161161
assert (
162162
_opentelemetry_metrics.is_advanced_metrics_enabled(client_setting=False)
163163
is False

0 commit comments

Comments
 (0)