diff --git a/google/cloud/bigtable/data/_metrics/handlers/opentelemetry.py b/google/cloud/bigtable/data/_metrics/handlers/opentelemetry.py index 1fb9b2e55..8591d7598 100644 --- a/google/cloud/bigtable/data/_metrics/handlers/opentelemetry.py +++ b/google/cloud/bigtable/data/_metrics/handlers/opentelemetry.py @@ -190,7 +190,7 @@ def on_attempt_complete( attempt.gfe_latency, {"streaming": is_streaming, "status": status, **labels}, ) - else: - # gfe headers not attached. Record a connectivity error. - # TODO: this should not be recorded as an error when direct path is enabled - self.otel.connectivity_error_count.add(1, {"status": status, **labels}) + # gfe headers not attached. Record a connectivity error. + # TODO: this should not be recorded as an error when direct path is enabled + is_error = attempt.gfe_latency is None + self.otel.connectivity_error_count.add(int(is_error), {"status": status, **labels})