Skip to content

Commit

Permalink
cleaned up labels
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-sanche committed Nov 14, 2023
1 parent 5309d4e commit 6907351
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions google/cloud/bigtable/data/_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,22 +292,20 @@ def __init__(self, *, project_id:str, instance_id:str, app_profile_id:str | None
description="A distribution of additional RPCs sent after the initial attempt, tagged by operation name and final operation status. Under normal circumstances, this will be 1.",
)
self.shared_labels = {
"bigtable_project_id": project_id,
"bigtable_instance_id": instance_id,
"client_name": f"python-bigtable/{bigtable_version}",
"client_uid": client_uid or str(uuid4()),
}
if app_profile_id:
self.shared_labels["bigtable_app_profile_id"] = app_profile_id

def on_operation_complete(self, op: _CompletedOperationMetric) -> None:
labels = {"op_name": op.op_type.value, "status": op.final_status, "streaming": op.is_streaming, **self.shared_labels}
labels = {"method": op.op_type.value, "status": op.final_status, "streaming": op.is_streaming, **self.shared_labels}

self.retry_count.record(len(op.completed_attempts) - 1, labels)
self.op_latency.record(op.duration, labels)

def on_attempt_complete(self, attempt: _CompletedAttemptMetric, op: _ActiveOperationMetric) -> None:
labels = {"op_name": op.op_type.value, "status": attempt.end_status.value, "streaming":op.is_streaming, **self.shared_labels}
labels = {"method": op.op_type.value, "status": attempt.end_status.value, "streaming":op.is_streaming, **self.shared_labels}
self.attempt_latency.record(attempt.duration, labels)
if op.op_type == _OperationType.READ_ROWS and attempt.first_response_latency is not None:
self.first_response_latency.record(attempt.first_response_latency, labels)
Expand Down

0 comments on commit 6907351

Please sign in to comment.