[tracing] Add target_write_size to HttpAnnotation (#35921)

<!--

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 #35921

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/35921 from yousukseung:wire-size-target 6c01052721
PiperOrigin-RevId: 607822267
pull/34384/head
Yousuk Seung 11 months ago committed by Copybara-Service
parent e3b5ec6e17
commit 8d094cdba9
  1. 17
      src/core/ext/transport/chttp2/transport/chttp2_transport.cc
  2. 26
      src/core/ext/transport/chttp2/transport/chttp2_transport.h
  3. 21
      src/core/ext/transport/chttp2/transport/writing.cc

@ -338,16 +338,11 @@ void ForEachContextListEntryExecute(void* arg, Timestamps* ts,
delete context_list;
}
HttpAnnotation::HttpAnnotation(
Type type, gpr_timespec time,
absl::optional<chttp2::TransportFlowControl::Stats> transport_stats,
absl::optional<chttp2::StreamFlowControl::Stats> stream_stats)
HttpAnnotation::HttpAnnotation(Type type, gpr_timespec time)
: CallTracerAnnotationInterface::Annotation(
CallTracerAnnotationInterface::AnnotationType::kHttpTransport),
type_(type),
time_(time),
transport_stats_(transport_stats),
stream_stats_(stream_stats) {}
time_(time) {}
std::string HttpAnnotation::ToString() const {
std::string s = "HttpAnnotation type: ";
@ -1433,9 +1428,11 @@ static void perform_stream_op_locked(void* stream_op,
if (op->send_initial_metadata) {
if (s->call_tracer) {
s->call_tracer->RecordAnnotation(grpc_core::HttpAnnotation(
grpc_core::HttpAnnotation::Type::kStart, gpr_now(GPR_CLOCK_REALTIME),
s->t->flow_control.stats(), s->flow_control.stats()));
s->call_tracer->RecordAnnotation(
grpc_core::HttpAnnotation(grpc_core::HttpAnnotation::Type::kStart,
gpr_now(GPR_CLOCK_REALTIME))
.Add(s->t->flow_control.stats())
.Add(s->flow_control.stats()));
}
if (t->is_client && t->channelz_socket != nullptr) {
t->channelz_socket->RecordStreamStartedFromLocal();

@ -112,10 +112,27 @@ class HttpAnnotation : public CallTracerAnnotationInterface::Annotation {
kEnd,
};
HttpAnnotation(
Type type, gpr_timespec time,
absl::optional<chttp2::TransportFlowControl::Stats> transport_stats,
absl::optional<chttp2::StreamFlowControl::Stats> stream_stats);
// A snapshot of write stats to export.
struct WriteStats {
size_t target_write_size;
};
HttpAnnotation(Type type, gpr_timespec time);
HttpAnnotation& Add(const chttp2::TransportFlowControl::Stats& stats) {
transport_stats_ = stats;
return *this;
}
HttpAnnotation& Add(const chttp2::StreamFlowControl::Stats& stats) {
stream_stats_ = stats;
return *this;
}
HttpAnnotation& Add(const WriteStats& stats) {
write_stats_ = stats;
return *this;
}
std::string ToString() const override;
@ -133,6 +150,7 @@ class HttpAnnotation : public CallTracerAnnotationInterface::Annotation {
const gpr_timespec time_;
absl::optional<chttp2::TransportFlowControl::Stats> transport_stats_;
absl::optional<chttp2::StreamFlowControl::Stats> stream_stats_;
absl::optional<WriteStats> write_stats_;
};
} // namespace grpc_core

@ -492,10 +492,15 @@ class StreamWriteContext {
t_, s_, &s_->send_initial_metadata_finished, absl::OkStatus(),
"send_initial_metadata_finished");
if (s_->call_tracer) {
s_->call_tracer->RecordAnnotation(grpc_core::HttpAnnotation(
grpc_core::HttpAnnotation::Type::kHeadWritten,
gpr_now(GPR_CLOCK_REALTIME), s_->t->flow_control.stats(),
s_->flow_control.stats()));
grpc_core::HttpAnnotation::WriteStats write_stats;
write_stats.target_write_size = write_context_->target_write_size();
s_->call_tracer->RecordAnnotation(
grpc_core::HttpAnnotation(
grpc_core::HttpAnnotation::Type::kHeadWritten,
gpr_now(GPR_CLOCK_REALTIME))
.Add(s_->t->flow_control.stats())
.Add(s_->flow_control.stats())
.Add(write_stats));
}
}
@ -619,9 +624,11 @@ class StreamWriteContext {
grpc_chttp2_mark_stream_closed(t_, s_, !t_->is_client, true,
absl::OkStatus());
if (s_->call_tracer) {
s_->call_tracer->RecordAnnotation(grpc_core::HttpAnnotation(
grpc_core::HttpAnnotation::Type::kEnd, gpr_now(GPR_CLOCK_REALTIME),
s_->t->flow_control.stats(), s_->flow_control.stats()));
s_->call_tracer->RecordAnnotation(
grpc_core::HttpAnnotation(grpc_core::HttpAnnotation::Type::kEnd,
gpr_now(GPR_CLOCK_REALTIME))
.Add(s_->t->flow_control.stats())
.Add(s_->flow_control.stats()));
}
}

Loading…
Cancel
Save