Skip to content

Commit 5dffde9

Browse files
Merge branch 'main' into add-clear-rowkey-function
2 parents 30dd595 + 9327596 commit 5dffde9

File tree

11 files changed

+366
-150
lines changed

11 files changed

+366
-150
lines changed

MODULE.bazel

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ python.toolchain(
5555
bazel_dep(name = "googleapis", version = "0.0.0", repo_name = "com_google_googleapis")
5656
archive_override(
5757
module_name = "googleapis",
58-
integrity = "sha256-JLDsEVCdmGOdD0NcdYyYdYvwXlaFeGT6lSp9jkYjCaY=",
58+
integrity = "sha256-ZtwaUUok0Q1AQ5O/m8W9YsvfIb2yJ+Roi7uoXKwS3Gg=",
5959
patch_strip = 1,
6060
patches = ["//bazel:googleapis.modules.patch"],
61-
strip_prefix = "googleapis-6e5b74e4f8194149542348a40881a5d792a59a0e",
61+
strip_prefix = "googleapis-fecd7d35f46753b45bf4519f6342495a181740c9",
6262
urls = [
63-
"https://github.com/googleapis/googleapis/archive/6e5b74e4f8194149542348a40881a5d792a59a0e.tar.gz",
63+
"https://github.com/googleapis/googleapis/archive/fecd7d35f46753b45bf4519f6342495a181740c9.tar.gz",
6464
],
6565
)
6666

bazel/workspace0.bzl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,10 @@ def gl_cpp_workspace0(name = None):
126126
http_archive,
127127
name = "com_google_googleapis",
128128
urls = [
129-
"https://github.com/googleapis/googleapis/archive/6e5b74e4f8194149542348a40881a5d792a59a0e.tar.gz",
129+
"https://github.com/googleapis/googleapis/archive/fecd7d35f46753b45bf4519f6342495a181740c9.tar.gz",
130130
],
131-
sha256 = "24b0ec11509d98639d0f435c758c98758bf05e56857864fa952a7d8e462309a6",
132-
strip_prefix = "googleapis-6e5b74e4f8194149542348a40881a5d792a59a0e",
131+
sha256 = "66dc1a514a24d10d404393bf9bc5bd62cbdf21bdb227e4688bbba85cac12dc68",
132+
strip_prefix = "googleapis-fecd7d35f46753b45bf4519f6342495a181740c9",
133133
build_file = Label("//bazel:googleapis.BUILD"),
134134
# Scaffolding for patching googleapis after download. For example:
135135
# patches = ["googleapis.patch"]

cmake/GoogleapisConfig.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ set(GOOGLE_CLOUD_CPP_GOOGLEAPIS_SHA256
2727
mark_as_advanced(GOOGLE_CLOUD_CPP_GOOGLEAPIS_SHA256)
2828

2929
set(_GOOGLE_CLOUD_CPP_GOOGLEAPIS_COMMIT_SHA
30-
"6e5b74e4f8194149542348a40881a5d792a59a0e")
30+
"fecd7d35f46753b45bf4519f6342495a181740c9")
3131
set(_GOOGLE_CLOUD_CPP_GOOGLEAPIS_SHA256
32-
"24b0ec11509d98639d0f435c758c98758bf05e56857864fa952a7d8e462309a6")
32+
"66dc1a514a24d10d404393bf9bc5bd62cbdf21bdb227e4688bbba85cac12dc68")
3333

3434
set(DOXYGEN_ALIASES
3535
"googleapis_link{2}=\"[\\1](https://github.com/googleapis/googleapis/blob/${_GOOGLE_CLOUD_CPP_GOOGLEAPIS_COMMIT_SHA}/\\2)\""

google/cloud/bigtable/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,8 @@ add_library(
193193
internal/legacy_row_reader.h
194194
internal/logging_data_client.cc
195195
internal/logging_data_client.h
196+
internal/metrics.cc
197+
internal/metrics.h
196198
internal/mutate_rows_limiter.cc
197199
internal/mutate_rows_limiter.h
198200
internal/operation_context.cc

google/cloud/bigtable/google_cloud_cpp_bigtable.bzl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ google_cloud_cpp_bigtable_hdrs = [
9696
"internal/legacy_async_row_sampler.h",
9797
"internal/legacy_row_reader.h",
9898
"internal/logging_data_client.h",
99+
"internal/metrics.h",
99100
"internal/mutate_rows_limiter.h",
100101
"internal/operation_context.h",
101102
"internal/prefix_range_end.h",
@@ -198,6 +199,7 @@ google_cloud_cpp_bigtable_srcs = [
198199
"internal/legacy_async_row_sampler.cc",
199200
"internal/legacy_row_reader.cc",
200201
"internal/logging_data_client.cc",
202+
"internal/metrics.cc",
201203
"internal/mutate_rows_limiter.cc",
202204
"internal/operation_context.cc",
203205
"internal/prefix_range_end.cc",
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Copyright 2025 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// https://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#ifdef GOOGLE_CLOUD_CPP_BIGTABLE_WITH_OTEL_METRICS
16+
17+
#include "google/cloud/bigtable/internal/metrics.h"
18+
#include "google/cloud/bigtable/version.h"
19+
20+
namespace google {
21+
namespace cloud {
22+
namespace bigtable_internal {
23+
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
24+
25+
LabelMap IntoMap(ResourceLabels const& r, DataLabels const& d) {
26+
return {
27+
{"project_id", r.project_id},
28+
{"instance", r.instance},
29+
{"table", r.table},
30+
{"cluster", r.cluster},
31+
{"zone", r.zone},
32+
{"method", d.method},
33+
{"streaming", d.streaming},
34+
{"client_name", d.client_name},
35+
{"client_uid", d.client_uid},
36+
{"app_profile", d.app_profile},
37+
{"status", d.status},
38+
};
39+
}
40+
41+
Metric::~Metric() = default;
42+
43+
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
44+
} // namespace bigtable_internal
45+
} // namespace cloud
46+
} // namespace google
47+
48+
#endif // GOOGLE_CLOUD_CPP_BIGTABLE_WITH_OTEL_METRICS
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
// Copyright 2025 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// https://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_INTERNAL_METRICS_H
16+
#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_INTERNAL_METRICS_H
17+
18+
#ifdef GOOGLE_CLOUD_CPP_BIGTABLE_WITH_OTEL_METRICS
19+
20+
#include "google/cloud/bigtable/internal/operation_context.h"
21+
#include "google/cloud/bigtable/version.h"
22+
#include "google/cloud/status.h"
23+
#include <grpcpp/grpcpp.h>
24+
#include <opentelemetry/context/context.h>
25+
#include <memory>
26+
#include <string>
27+
#include <unordered_map>
28+
29+
namespace google {
30+
namespace cloud {
31+
namespace bigtable_internal {
32+
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
33+
34+
struct ResourceLabels {
35+
std::string project_id;
36+
std::string instance;
37+
std::string table;
38+
std::string cluster;
39+
std::string zone;
40+
};
41+
42+
struct DataLabels {
43+
std::string method;
44+
std::string streaming;
45+
std::string client_name;
46+
std::string client_uid;
47+
std::string app_profile;
48+
std::string status;
49+
};
50+
51+
using LabelMap = std::unordered_map<std::string, std::string>;
52+
LabelMap IntoMap(ResourceLabels const& r, DataLabels const& d);
53+
54+
struct PreCallParams {
55+
OperationContext::Clock::time_point attempt_start;
56+
bool first_attempt;
57+
};
58+
59+
struct PostCallParams {
60+
OperationContext::Clock::time_point attempt_end;
61+
google::cloud::Status attempt_status;
62+
};
63+
64+
struct OnDoneParams {
65+
OperationContext::Clock::time_point operation_end;
66+
google::cloud::Status operation_status;
67+
};
68+
69+
struct ElementRequestParams {
70+
OperationContext::Clock::time_point element_request;
71+
};
72+
73+
struct ElementDeliveryParams {
74+
OperationContext::Clock::time_point element_delivery;
75+
bool first_response;
76+
};
77+
78+
class Metric {
79+
public:
80+
using LatencyDuration = std::chrono::duration<double, std::milli>;
81+
82+
virtual ~Metric() = 0;
83+
virtual void PreCall(opentelemetry::context::Context const&,
84+
PreCallParams const&) {}
85+
virtual void PostCall(opentelemetry::context::Context const&,
86+
grpc::ClientContext const&, PostCallParams const&) {}
87+
virtual void OnDone(opentelemetry::context::Context const&,
88+
OnDoneParams const&) {}
89+
virtual void ElementRequest(opentelemetry::context::Context const&,
90+
ElementRequestParams const&) {}
91+
virtual void ElementDelivery(opentelemetry::context::Context const&,
92+
ElementDeliveryParams const&) {}
93+
virtual std::unique_ptr<Metric> clone(ResourceLabels resource_labels,
94+
DataLabels data_labels) const = 0;
95+
};
96+
97+
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
98+
} // namespace bigtable_internal
99+
} // namespace cloud
100+
} // namespace google
101+
102+
#endif // GOOGLE_CLOUD_CPP_BIGTABLE_WITH_OTEL_METRICS
103+
104+
#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_INTERNAL_METRICS_H

google/cloud/bigtable/internal/operation_context.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_INTERNAL_OPERATION_CONTEXT_H
1717

1818
#include "google/cloud/bigtable/version.h"
19+
#include "google/cloud/internal/clock.h"
1920
#include <grpcpp/grpcpp.h>
2021
#include <map>
2122
#include <string>
@@ -51,6 +52,8 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
5152
*/
5253
class OperationContext {
5354
public:
55+
using Clock = ::google::cloud::internal::SteadyClock;
56+
5457
// Adds stored bigtable cookies as client metadata.
5558
void PreCall(grpc::ClientContext& context);
5659
// Stores bigtable cookies returned as server metadata.

0 commit comments

Comments
 (0)