Skip to content

Commit

Permalink
changed cluster id default
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-sanche committed Nov 27, 2023
1 parent d715cf7 commit ea7ad81
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
5 changes: 3 additions & 2 deletions google/cloud/bigtable/data/_metrics/data_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
LOGGER = logging.getLogger(__name__) if os.getenv("BIGTABLE_METRICS_LOGS", False) else None

DEFAULT_ZONE = "global"
DEFAULT_CLUSTER_ID = "unspecified"

BIGTABLE_METADATA_KEY = "x-goog-ext-425905942-bin"
SERVER_TIMING_METADATA_KEY = "server-timing"
Expand Down Expand Up @@ -89,7 +90,7 @@ class CompletedOperationMetric:
duration: float
completed_attempts: list[CompletedAttemptMetric]
final_status: StatusCode
cluster_id: str | None
cluster_id: str
zone: str
is_streaming: bool

Expand Down Expand Up @@ -261,7 +262,7 @@ def end_with_status(self, status: StatusCode | Exception) -> None:
completed_attempts=self.completed_attempts,
duration=time.monotonic() - self.start_time,
final_status=final_status,
cluster_id=self.cluster_id,
cluster_id=self.cluster_id or DEFAULT_CLUSTER_ID,
zone=self.zone or DEFAULT_ZONE,
is_streaming=self.is_streaming,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from google.cloud.bigtable.data._metrics.data_model import ActiveOperationMetric
from google.cloud.bigtable.data._metrics.data_model import CompletedAttemptMetric
from google.cloud.bigtable.data._metrics.data_model import CompletedOperationMetric
from google.cloud.bigtable.data._metrics.data_model import DEFAULT_ZONE


class _OpenTelemetryInstrumentSingleton:
"""
Expand Down Expand Up @@ -104,7 +104,6 @@ def __init__(
if app_profile_id:
self.shared_labels["app_profile"] = app_profile_id


def on_operation_complete(self, op: CompletedOperationMetric) -> None:
"""
Update the metrics associated with a completed operation:
Expand Down

0 comments on commit ea7ad81

Please sign in to comment.