call_tracer.h
Go to the documentation of this file.
1 //
2 //
3 // Copyright 2021 gRPC authors.
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 //
18 
19 #ifndef GRPC_CORE_LIB_CHANNEL_CALL_TRACER_H
20 #define GRPC_CORE_LIB_CHANNEL_CALL_TRACER_H
21 
23 
24 #include <stdint.h>
25 
26 #include "absl/status/status.h"
27 
29 #include <grpc/support/atm.h>
30 
35 
36 namespace grpc_core {
37 
38 // Interface for a tracer that records activities on a call. Actual attempts for
39 // this call are traced with CallAttemptTracer after invoking RecordNewAttempt()
40 // on the CallTracer object.
41 class CallTracer {
42  public:
43  // Interface for a tracer that records activities on a particular call
44  // attempt.
45  // (A single RPC can have multiple attempts due to retry/hedging policies or
46  // as transparent retry attempts.)
48  public:
49  virtual ~CallAttemptTracer() {}
50  // Please refer to `grpc_transport_stream_op_batch_payload` for details on
51  // arguments.
52  virtual void RecordSendInitialMetadata(
54  // TODO(yashkt): We are using gpr_atm here instead of absl::string_view
55  // since that's what the transport API uses, and performing an atomic load
56  // is unnecessary if the census tracer does not need it at present. Fix this
57  // when the transport API changes.
58  virtual void RecordOnDoneSendInitialMetadata(gpr_atm* peer_string) = 0;
59  virtual void RecordSendTrailingMetadata(
60  grpc_metadata_batch* send_trailing_metadata) = 0;
61  virtual void RecordSendMessage(const SliceBuffer& send_message) = 0;
62  // The `RecordReceivedInitialMetadata()` and `RecordReceivedMessage()`
63  // methods should only be invoked when the metadata/message was
64  // successfully received, i.e., without any error.
65  virtual void RecordReceivedInitialMetadata(
66  grpc_metadata_batch* recv_initial_metadata, uint32_t flags) = 0;
67  virtual void RecordReceivedMessage(const SliceBuffer& recv_message) = 0;
68  // If the call was cancelled before the recv_trailing_metadata op
69  // was started, recv_trailing_metadata and transport_stream_stats
70  // will be null.
71  virtual void RecordReceivedTrailingMetadata(
72  absl::Status status, grpc_metadata_batch* recv_trailing_metadata,
73  const grpc_transport_stream_stats* transport_stream_stats) = 0;
74  virtual void RecordCancel(grpc_error_handle cancel_error) = 0;
75  // Should be the last API call to the object. Once invoked, the tracer
76  // library is free to destroy the object.
77  virtual void RecordEnd(const gpr_timespec& latency) = 0;
78  };
79 
80  virtual ~CallTracer() {}
81 
82  // Records a new attempt for the associated call. \a transparent denotes
83  // whether the attempt is being made as a transparent retry or as a
84  // non-transparent retry/heding attempt. (There will be at least one attempt
85  // even if the call is not being retried.) The `CallTracer` object retains
86  // ownership to the newly created `CallAttemptTracer` object. RecordEnd()
87  // serves as an indication that the call stack is done with all API calls, and
88  // the tracer library is free to destroy it after that.
89  virtual CallAttemptTracer* StartNewAttempt(bool is_transparent_retry) = 0;
90 };
91 
92 } // namespace grpc_core
93 
94 #endif // GRPC_CORE_LIB_CHANNEL_CALL_TRACER_H
metadata_batch.h
grpc_core::CallTracer::CallAttemptTracer::~CallAttemptTracer
virtual ~CallAttemptTracer()
Definition: call_tracer.h:49
grpc_core
Definition: call_metric_recorder.h:31
status
absl::Status status
Definition: rls.cc:251
grpc_core::CallTracer
Definition: call_tracer.h:41
grpc_core::CallTracer::CallAttemptTracer::RecordOnDoneSendInitialMetadata
virtual void RecordOnDoneSendInitialMetadata(gpr_atm *peer_string)=0
grpc_core::CallTracer::CallAttemptTracer::RecordReceivedMessage
virtual void RecordReceivedMessage(const SliceBuffer &recv_message)=0
grpc_core::CallTracer::CallAttemptTracer
Definition: call_tracer.h:47
uint32_t
unsigned int uint32_t
Definition: stdint-msvc2008.h:80
send_message
Definition: send_message.py:1
grpc_core::CallTracer::CallAttemptTracer::RecordSendTrailingMetadata
virtual void RecordSendTrailingMetadata(grpc_metadata_batch *send_trailing_metadata)=0
grpc_core::CallTracer::CallAttemptTracer::RecordEnd
virtual void RecordEnd(const gpr_timespec &latency)=0
error.h
grpc_core::CallTracer::~CallTracer
virtual ~CallTracer()
Definition: call_tracer.h:80
stdint.h
grpc_core::CallTracer::CallAttemptTracer::RecordSendMessage
virtual void RecordSendMessage(const SliceBuffer &send_message)=0
gpr_types.h
grpc_core::CallTracer::StartNewAttempt
virtual CallAttemptTracer * StartNewAttempt(bool is_transparent_retry)=0
gpr_atm
intptr_t gpr_atm
Definition: impl/codegen/atm_gcc_atomic.h:32
grpc_core::SliceBuffer
Definition: src/core/lib/slice/slice_buffer.h:44
absl::flags_internal
Definition: abseil-cpp/absl/flags/commandlineflag.h:40
grpc_transport_stream_stats
Definition: transport.h:249
absl::Status
Definition: third_party/abseil-cpp/absl/status/status.h:424
grpc_core::CallTracer::CallAttemptTracer::RecordCancel
virtual void RecordCancel(grpc_error_handle cancel_error)=0
grpc_core::CallTracer::CallAttemptTracer::RecordReceivedInitialMetadata
virtual void RecordReceivedInitialMetadata(grpc_metadata_batch *recv_initial_metadata, uint32_t flags)=0
transport.h
atm.h
gpr_timespec
Definition: gpr_types.h:50
grpc_error
Definition: error_internal.h:42
grpc_metadata_batch
Definition: metadata_batch.h:1259
grpc_core::CallTracer::CallAttemptTracer::RecordSendInitialMetadata
virtual void RecordSendInitialMetadata(grpc_metadata_batch *send_initial_metadata, uint32_t flags)=0
slice_buffer.h
send_initial_metadata
static void send_initial_metadata(void)
Definition: test/core/fling/server.cc:121
grpc_core::CallTracer::CallAttemptTracer::RecordReceivedTrailingMetadata
virtual void RecordReceivedTrailingMetadata(absl::Status status, grpc_metadata_batch *recv_trailing_metadata, const grpc_transport_stream_stats *transport_stream_stats)=0
port_platform.h


grpc
Author(s):
autogenerated on Thu Mar 13 2025 02:58:42