Skip to content

Commit e31434c

Browse files
ctillercopybara-github
authored andcommitted
[channelz] HTTP/2 ztrace facility (grpc#39189)
<!-- If you know who should review your pull request, please assign it to that person, otherwise the pull request would get assigned randomly. If your pull request is for a specific language, please add the appropriate lang label. --> Closes grpc#39189 COPYBARA_INTEGRATE_REVIEW=grpc#39189 from ctiller:http2-trace 547f786 PiperOrigin-RevId: 746174350
1 parent 01fa65c commit e31434c

39 files changed

+684
-76
lines changed

BUILD

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,6 +1243,7 @@ grpc_cc_library(
12431243
"//src/core:channel_args",
12441244
"//src/core:connectivity_state",
12451245
"//src/core:json",
1246+
"//src/core:json_reader",
12461247
"//src/core:json_writer",
12471248
"//src/core:per_cpu",
12481249
"//src/core:ref_counted",
@@ -2603,6 +2604,7 @@ grpc_cc_library(
26032604
],
26042605
external_deps = [
26052606
"protobuf_headers",
2607+
"absl/log",
26062608
],
26072609
public_hdrs = [
26082610
"include/grpcpp/ext/channelz_service_plugin.h",
@@ -4532,6 +4534,7 @@ grpc_cc_library(
45324534
"grpc_trace",
45334535
"//src/core:hpack_constants",
45344536
"//src/core:hpack_encoder_table",
4537+
"//src/core:http2_ztrace_collector",
45354538
"//src/core:metadata_batch",
45364539
"//src/core:metadata_compression_traits",
45374540
"//src/core:slice",
@@ -4685,13 +4688,16 @@ grpc_cc_library(
46854688
"//src/core:gpr_manual_constructor",
46864689
"//src/core:http2_settings",
46874690
"//src/core:http2_status",
4691+
"//src/core:http2_ztrace_collector",
46884692
"//src/core:init_internally",
46894693
"//src/core:iomgr_fwd",
46904694
"//src/core:iomgr_port",
4695+
"//src/core:json",
46914696
"//src/core:match",
46924697
"//src/core:memory_quota",
46934698
"//src/core:metadata_batch",
46944699
"//src/core:metadata_info",
4700+
"//src/core:notification",
46954701
"//src/core:ping_abuse_policy",
46964702
"//src/core:ping_callbacks",
46974703
"//src/core:ping_rate_policy",

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build_autogenerated.yaml

Lines changed: 10 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gRPC-C++.podspec

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gRPC-Core.podspec

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

grpc.gemspec

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.xml

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/core/BUILD

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7566,6 +7566,7 @@ grpc_cc_library(
75667566
],
75677567
deps = [
75687568
"http2_status",
7569+
"json",
75697570
"useful",
75707571
"//:chttp2_frame",
75717572
"//:gpr_platform",
@@ -9390,6 +9391,18 @@ grpc_cc_library(
93909391
],
93919392
)
93929393

9394+
grpc_cc_library(
9395+
name = "http2_ztrace_collector",
9396+
hdrs = ["ext/transport/chttp2/transport/http2_ztrace_collector.h"],
9397+
external_deps = [
9398+
"absl/container:flat_hash_set",
9399+
],
9400+
deps = [
9401+
"ztrace_collector",
9402+
"//:chttp2_frame",
9403+
],
9404+
)
9405+
93939406
### UPB Targets
93949407

93959408
grpc_upb_proto_library(

src/core/channelz/channelz.cc

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <atomic>
2727
#include <cstdint>
2828
#include <string>
29+
#include <tuple>
2930

3031
#include "absl/log/check.h"
3132
#include "absl/status/statusor.h"
@@ -65,9 +66,10 @@ std::string BaseNode::RenderJsonString() {
6566
}
6667

6768
void BaseNode::PopulateJsonFromDataSources(Json::Object& json) {
69+
DataSink sink(json);
6870
MutexLock lock(&data_sources_mu_);
6971
for (DataSource* data_source : data_sources_) {
70-
data_source->AddJson(json);
72+
data_source->AddData(sink);
7173
}
7274
}
7375

@@ -107,6 +109,24 @@ void BaseNode::RunZTrace(
107109
ztrace->Run(deadline, std::move(args), event_engine, std::move(callback));
108110
}
109111

112+
//
113+
// DataSink
114+
//
115+
116+
DataSink::~DataSink() {
117+
if (additional_info_ != nullptr) {
118+
output_["additionalInfo"] = Json::FromObject(std::move(*additional_info_));
119+
}
120+
}
121+
122+
void DataSink::AddAdditionalInfo(absl::string_view name,
123+
Json::Object additional_info) {
124+
if (additional_info_ == nullptr) {
125+
additional_info_ = std::make_unique<Json::Object>();
126+
}
127+
additional_info_->emplace(name, Json::FromObject(std::move(additional_info)));
128+
}
129+
110130
//
111131
// DataSource
112132
//

0 commit comments

Comments
 (0)