FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

feat(storage): add OpenTelemetry metrics gating and configuration module by shradhakatyal · Pull Request #18407 · googleapis/google-cloud-python · GitHub

Repository navigation

feat(storage): add OpenTelemetry metrics gating and configuration module - #18407

Merged
shradhakatyal merged 6 commits into
googleapis:mainfrom
shradhakatyal:feat/gcs-otel-metrics-gating
Oct 8, 2026
Merged

shradhakatyal merged 6 commits into
googleapis:mainfrom
shradhakatyal:feat/gcs-otel-metrics-gating

Conversation

shradhakatyal commented Sep 17, 2026 •
edited
Loading

Copy link
Copy Markdown
Contributor

Introduce the foundational OpenTelemetry client metrics gating and configuration module for Google Cloud Storage.

  • Add _opentelemetry_metrics.py with a development gate (_ENABLE_METRICS_DEV_GATE) and environment variable parsing (GCP_STORAGE_PYTHON_ENABLE_OTEL_METRICS, GCP_STORAGE_PYTHON_ENABLE_OTEL_DEBUG_METRICS).
  • Implement is_metrics_enabled() and is_advanced_metrics_enabled() evaluation helpers with precedence hierarchy (dev gate -> client setting -> environment variable -> default).
  • Provide get_common_attributes() and get_meter() helpers for OpenTelemetry metrics instrumentation.
  • Add unit tests in test__opentelemetry_metrics.py covering gating resolution, environment variable overrides, ImportError fallback, and attribute helpers.

gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Code Review

This pull request introduces OpenTelemetry metrics support to the Google Cloud Storage Python client by adding a new internal module _opentelemetry_metrics.py and updating the Client class to support enable_metrics and enable_advanced_metrics configurations. The review feedback highlights a correctness bug where advanced metrics could be incorrectly enabled even if base metrics are disabled. To resolve this, the reviewer suggests updating is_advanced_metrics_enabled to accept and evaluate both settings, adjusting the client properties accordingly, and adding a unit test to verify this edge case.

shradhakatyal force-pushed the feat/gcs-otel-metrics-gating branch from 9abe5c5 to 4b18e9f Compare September 23, 2026 08:19
shradhakatyal changed the title feat(storage): add OpenTelemetry metrics gating and configuration feat(storage): add OpenTelemetry metrics gating and configuration module Sep 23, 2026
shradhakatyal marked this pull request as ready for review September 23, 2026 16:49
shradhakatyal requested a review from a team as a code owner September 23, 2026 16:49
shradhakatyal force-pushed the feat/gcs-otel-metrics-gating branch from a00e861 to fe6ca67 Compare September 24, 2026 05:55

Copy link
Copy Markdown
Contributor Author

/gcbrun (a00e861)

- Add _opentelemetry_metrics.py with internal dev gate and environment variable parsing
- Implement is_metrics_enabled and is_advanced_metrics_enabled evaluation helpers
- Provide get_common_attributes and get_meter helpers for OpenTelemetry metrics
- Add comprehensive unit tests in test__opentelemetry_metrics.py
- Set _ENABLE_METRICS_DEV_GATE to True in test_opentelemetry_import_error_on_load
- Wrap importlib.reload(_opentelemetry_metrics) cleanup in a try...finally block
…th 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
shradhakatyal force-pushed the feat/gcs-otel-metrics-gating branch from fe6ca67 to b188742 Compare September 29, 2026 08:50

Copy link
Copy Markdown
Contributor Author

/gcbrun b188742

cpriti-os left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thanks for putting the gating in one place — precedence (default < env var < client option) looks right and the tests cover both override directions. A few inline comments below; the main ones are the advanced-metrics coupling and get_meter gating.

- Decouple is_advanced_metrics_enabled from is_metrics_enabled
- Gate get_meter on active standard or advanced metrics enablement
- Handle empty/whitespace and unrecognized values in _parse_bool_env with a warning
- Use client_setting parameter name in TypeError messages
- Expand unit tests for independent advanced metrics, env var parsing, and get_meter

Copy link
Copy Markdown
Contributor Author

/gcbrun (b4b4853)

… and missing OTel tests

- Rename client_setting to enable_metrics and enable_advanced_metrics in gating functions
- Expand get_meter docstring with Args and Returns sections
- Verify explicit enablement flags return False/None when opentelemetry is missing

Copy link
Copy Markdown
Contributor Author

/gcbrun 253d5ff

cpriti-os left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM, thanks for addressing all the feedback. One naming change before merging (inline).

…ting module

- Rename is_advanced_metrics_enabled to is_debug_metrics_enabled
- Rename enable_advanced_metrics parameter to enable_debug_metrics in is_debug_metrics_enabled and get_meter
- Update unit tests and docstrings to use debug metrics naming

Copy link
Copy Markdown
Contributor Author

/gcbrun 9c0f924

shradhakatyal merged commit 654e768 into googleapis:main Oct 8, 2026
52 checks passed
release-please Bot mentioned this pull request Oct 8, 2026
noahdietz pushed a commit that referenced this pull request Oct 8, 2026
🤖 I have created a release *beep* *boop*
---


<details><summary>gapic-generator: 1.43.0</summary>

##
[1.43.0](gapic-generator-v1.42.0...gapic-generator-v1.43.0)
(2026-10-08)


### Features

* **gapic-generator:** generate code samples for resumable upload RPCs
([#18501](#18501))
([c8926ab](c8926ab))
* generate client, transport, and unit test templates for resumable
uploads
([#18495](#18495))
([3f8d00b](3f8d00b))
* **observability:** implement universal 4-path OpenTelemetry tracing
([#18433](#18433))
([7d18b25](7d18b25))
</details>

<details><summary>google-ads-admanager: 0.10.7</summary>

##
[0.10.7](google-ads-admanager-v0.10.6...google-ads-admanager-v0.10.7)
(2026-10-08)


### Features

* update API sources and regenerate
([#18593](#18593))
([d0505e8](d0505e8))
</details>

<details><summary>google-api-core: 2.42.0</summary>

##
[2.42.0](google-api-core-v2.41.0...google-api-core-v2.42.0)
(2026-10-08)


### Features

* **observability:** implement universal 4-path OpenTelemetry tracing
([#18433](#18433))
([7d18b25](7d18b25))
</details>

<details><summary>google-cloud-apphub: 0.5.2</summary>

##
[0.5.2](google-cloud-apphub-v0.5.1...google-cloud-apphub-v0.5.2)
(2026-10-08)


### Features

* update API sources and regenerate
([#18593](#18593))
([d0505e8](d0505e8))
</details>

<details><summary>google-cloud-beyondcorp-appconnections:
0.8.2</summary>

##
[0.8.2](google-cloud-beyondcorp-appconnections-v0.8.1...google-cloud-beyondcorp-appconnections-v0.8.2)
(2026-10-08)


### Features

* update API sources and regenerate
([#18593](#18593))
([d0505e8](d0505e8))
</details>

<details><summary>google-cloud-beyondcorp-appconnectors: 0.8.2</summary>

##
[0.8.2](google-cloud-beyondcorp-appconnectors-v0.8.1...google-cloud-beyondcorp-appconnectors-v0.8.2)
(2026-10-08)


### Features

* update API sources and regenerate
([#18593](#18593))
([d0505e8](d0505e8))
</details>

<details><summary>google-cloud-beyondcorp-appgateways: 0.8.2</summary>

##
[0.8.2](google-cloud-beyondcorp-appgateways-v0.8.1...google-cloud-beyondcorp-appgateways-v0.8.2)
(2026-10-08)


### Features

* update API sources and regenerate
([#18593](#18593))
([d0505e8](d0505e8))
</details>

<details><summary>google-cloud-bigtable: 2.50.0</summary>

##
[2.50.0](google-cloud-bigtable-v2.49.0...google-cloud-bigtable-v2.50.0)
(2026-10-08)


### Features

* update API sources and regenerate
([#18593](#18593))
([d0505e8](d0505e8))
</details>

<details><summary>google-cloud-compute-v1beta: 0.12.8</summary>

##
[0.12.8](google-cloud-compute-v1beta-v0.12.7...google-cloud-compute-v1beta-v0.12.8)
(2026-10-08)


### Features

* update API sources and regenerate
([#18593](#18593))
([d0505e8](d0505e8))
</details>

<details><summary>google-cloud-dialogflow: 2.53.0</summary>

##
[2.53.0](google-cloud-dialogflow-v2.52.0...google-cloud-dialogflow-v2.53.0)
(2026-10-08)


### Features

* update API sources and regenerate
([#18593](#18593))
([d0505e8](d0505e8))
</details>

<details><summary>google-cloud-dialogflow-cx: 2.9.0</summary>

##
[2.9.0](google-cloud-dialogflow-cx-v2.8.0...google-cloud-dialogflow-cx-v2.9.0)
(2026-10-08)


### Features

* update API sources and regenerate
([#18593](#18593))
([d0505e8](d0505e8))
</details>

<details><summary>google-cloud-firestore: 2.34.1</summary>

##
[2.34.1](google-cloud-firestore-v2.34.0...google-cloud-firestore-v2.34.1)
(2026-10-08)


### Bug Fixes

* **firestore:** add generic typing for DocumentSnapshot
([#18587](#18587))
([947949b](947949b))
</details>

<details><summary>google-cloud-netapp: 0.10.3</summary>

##
[0.10.3](google-cloud-netapp-v0.10.2...google-cloud-netapp-v0.10.3)
(2026-10-08)


### Features

* update API sources and regenerate
([#18593](#18593))
([d0505e8](d0505e8))
</details>

<details><summary>google-cloud-redis-cluster: 0.5.4</summary>

##
[0.5.4](google-cloud-redis-cluster-v0.5.3...google-cloud-redis-cluster-v0.5.4)
(2026-10-08)


### Features

* update API sources and regenerate
([#18593](#18593))
([d0505e8](d0505e8))
</details>

<details><summary>google-cloud-storage: 3.17.0</summary>

##
[3.17.0](google-cloud-storage-v3.16.0...google-cloud-storage-v3.17.0)
(2026-10-08)


### Features

* **storage:** add OpenTelemetry metrics gating and configuration module
([#18407](#18407))
([654e768](654e768))
</details>

<details><summary>google-developer-knowledge: 0.1.4</summary>

##
[0.1.4](google-developer-knowledge-v0.1.3...google-developer-knowledge-v0.1.4)
(2026-10-08)


### Features

* update API sources and regenerate
([#18593](#18593))
([d0505e8](d0505e8))
</details>

<details><summary>google-devicesandservices-health: 0.1.4</summary>

##
[0.1.4](google-devicesandservices-health-v0.1.3...google-devicesandservices-health-v0.1.4)
(2026-10-08)


### Features

* **google-devicesandservices-health:** add v4beta
([#18597](#18597))
([d28458c](d28458c))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL