Skip to content

Commit a062620

Browse files
committed
disable csm in samples
1 parent 3c2215d commit a062620

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

‎packages/google-cloud-bigtable/samples/conftest.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,14 @@
1717
import signal
1818
import uuid
1919
from typing import Optional
20+
from unittest import mock
2021

2122
import pytest
2223
from google.api_core import exceptions, retry
2324

2425
from google.cloud import bigtable_admin
26+
from google.cloud.bigtable.data._async import client as async_client
27+
from google.cloud.bigtable.data._sync_autogen import client as sync_client
2528
from tests.system.utils import clear_stale_instances
2629

2730
_CREATED_INSTANCE_NAME: Optional[str] = None
@@ -61,6 +64,13 @@ def pytest_configure(config) -> None:
6164
"""Creates a temporary Bigtable instance if BIGTABLE_INSTANCE is not set."""
6265
global _CREATED_INSTANCE_NAME
6366

67+
# Disable client-side metrics export during sample tests to avoid
68+
# per-snippet MetricServiceClient initialization and background export threads.
69+
async_client.BigtableMetricsExporter = mock.MagicMock
70+
async_client.GoogleCloudMetricsHandler = mock.MagicMock
71+
sync_client.BigtableMetricsExporter = mock.MagicMock
72+
sync_client.GoogleCloudMetricsHandler = mock.MagicMock
73+
6474
if getattr(config.option, "help", False) or getattr(
6575
config.option, "collectonly", False
6676
):

0 commit comments

Comments
 (0)