[tracing] Sub-msec time granularity in HttpAnnotation

Use gpr_timespec instead of Timestamp for better time granularity. Timestamp uses msec which is too coarse-grained.

PiperOrigin-RevId: 595194238
pull/35428/head
Yousuk Seung 11 months ago committed by Copybara-Service
parent d2da19e99e
commit 29740367b0
  1. 7
      src/core/ext/transport/chttp2/transport/chttp2_transport.cc
  2. 6
      src/core/ext/transport/chttp2/transport/chttp2_transport.h
  3. 5
      src/core/ext/transport/chttp2/transport/writing.cc

@ -79,6 +79,7 @@
#include "src/core/lib/debug/stats.h"
#include "src/core/lib/debug/stats_data.h"
#include "src/core/lib/experiments/experiments.h"
#include "src/core/lib/gpr/string.h"
#include "src/core/lib/gpr/useful.h"
#include "src/core/lib/gprpp/bitset.h"
#include "src/core/lib/gprpp/crash.h"
@ -342,7 +343,7 @@ void ForEachContextListEntryExecute(void* arg, Timestamps* ts,
}
HttpAnnotation::HttpAnnotation(
Type type, Timestamp time,
Type type, gpr_timespec time,
absl::optional<chttp2::TransportFlowControl::Stats> transport_stats,
absl::optional<chttp2::StreamFlowControl::Stats> stream_stats)
: CallTracerAnnotationInterface::Annotation(
@ -367,7 +368,7 @@ std::string HttpAnnotation::ToString() const {
default:
absl::StrAppend(&s, "Unknown");
}
absl::StrAppend(&s, " time: ", time_.ToString());
absl::StrAppend(&s, " time: ", gpr_format_timespec(time_));
if (transport_stats_.has_value()) {
absl::StrAppend(&s, " transport:[", transport_stats_->ToString(), "]");
}
@ -1508,7 +1509,7 @@ 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, grpc_core::Timestamp::Now(),
grpc_core::HttpAnnotation::Type::kStart, gpr_now(GPR_CLOCK_REALTIME),
s->t->flow_control.stats(), s->flow_control.stats()));
}
if (t->is_client && t->channelz_socket != nullptr) {

@ -113,14 +113,14 @@ class HttpAnnotation : public CallTracerAnnotationInterface::Annotation {
};
HttpAnnotation(
Type type, Timestamp time,
Type type, gpr_timespec time,
absl::optional<chttp2::TransportFlowControl::Stats> transport_stats,
absl::optional<chttp2::StreamFlowControl::Stats> stream_stats);
std::string ToString() const override;
Type http_type() const { return type_; }
Timestamp time() const { return time_; }
gpr_timespec time() const { return time_; }
absl::optional<chttp2::TransportFlowControl::Stats> transport_stats() const {
return transport_stats_;
}
@ -130,7 +130,7 @@ class HttpAnnotation : public CallTracerAnnotationInterface::Annotation {
private:
const Type type_;
const Timestamp time_;
const gpr_timespec time_;
absl::optional<chttp2::TransportFlowControl::Stats> transport_stats_;
absl::optional<chttp2::StreamFlowControl::Stats> stream_stats_;
};

@ -34,6 +34,7 @@
#include <grpc/event_engine/event_engine.h>
#include <grpc/slice_buffer.h>
#include <grpc/support/log.h>
#include <grpc/support/time.h>
#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h"
#include "src/core/ext/transport/chttp2/transport/context_list_entry.h"
@ -516,7 +517,7 @@ class StreamWriteContext {
if (s_->call_tracer) {
s_->call_tracer->RecordAnnotation(grpc_core::HttpAnnotation(
grpc_core::HttpAnnotation::Type::kHeadWritten,
grpc_core::Timestamp::Now(), s_->t->flow_control.stats(),
gpr_now(GPR_CLOCK_REALTIME), s_->t->flow_control.stats(),
s_->flow_control.stats()));
}
}
@ -648,7 +649,7 @@ class StreamWriteContext {
absl::OkStatus());
if (s_->call_tracer) {
s_->call_tracer->RecordAnnotation(grpc_core::HttpAnnotation(
grpc_core::HttpAnnotation::Type::kEnd, grpc_core::Timestamp::Now(),
grpc_core::HttpAnnotation::Type::kEnd, gpr_now(GPR_CLOCK_REALTIME),
s_->t->flow_control.stats(), s_->flow_control.stats()));
}
}

Loading…
Cancel
Save