aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/lib/channel/channel_trace.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/lib/channel/channel_trace.h')
-rw-r--r--src/core/lib/channel/channel_trace.h27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/core/lib/channel/channel_trace.h b/src/core/lib/channel/channel_trace.h
index 94fea20b45..8ff91ee8c8 100644
--- a/src/core/lib/channel/channel_trace.h
+++ b/src/core/lib/channel/channel_trace.h
@@ -30,6 +30,10 @@
namespace grpc_core {
namespace channelz {
+namespace testing {
+size_t GetSizeofTraceEvent(void);
+}
+
class BaseNode;
// Object used to hold live data for a channel. This data is exposed via the
@@ -37,7 +41,7 @@ class BaseNode;
// https://github.com/grpc/proposal/blob/master/A14-channelz.md
class ChannelTrace {
public:
- ChannelTrace(size_t max_events);
+ ChannelTrace(size_t max_event_memory);
~ChannelTrace();
enum Severity {
@@ -49,6 +53,12 @@ class ChannelTrace {
// Adds a new trace event to the tracing object
//
+ // NOTE: each ChannelTrace tracks the memory used by its list of trace
+ // events, so adding an event with a large amount of data could cause other
+ // trace event to be evicted. If a single trace is larger than the limit, it
+ // will cause all events to be evicted. The limit is set with the arg:
+ // GRPC_ARG_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE.
+ //
// TODO(ncteisen): as this call is used more and more throughout the gRPC
// stack, determine if it makes more sense to accept a char* instead of a
// slice.
@@ -59,9 +69,9 @@ class ChannelTrace {
// channel has created a new subchannel, then it would record that with
// a TraceEvent referencing the new subchannel.
//
- // TODO(ncteisen): as this call is used more and more throughout the gRPC
- // stack, determine if it makes more sense to accept a char* instead of a
- // slice.
+ // NOTE: see the note in the method above.
+ //
+ // TODO(ncteisen): see the todo in the method above.
void AddTraceEventWithReference(Severity severity, grpc_slice data,
RefCountedPtr<BaseNode> referenced_entity);
@@ -70,6 +80,8 @@ class ChannelTrace {
grpc_json* RenderJson() const;
private:
+ friend size_t testing::GetSizeofTraceEvent(void);
+
// Private class to encapsulate all the data and bookkeeping needed for a
// a trace event.
class TraceEvent {
@@ -92,6 +104,8 @@ class ChannelTrace {
TraceEvent* next() const { return next_; }
void set_next(TraceEvent* next) { next_ = next; }
+ size_t memory_usage() const { return memory_usage_; }
+
private:
Severity severity_;
grpc_slice data_;
@@ -99,6 +113,7 @@ class ChannelTrace {
TraceEvent* next_;
// the tracer object for the (sub)channel that this trace event refers to.
RefCountedPtr<BaseNode> referenced_entity_;
+ size_t memory_usage_;
}; // TraceEvent
// Internal helper to add and link in a trace event
@@ -106,8 +121,8 @@ class ChannelTrace {
gpr_mu tracer_mu_;
uint64_t num_events_logged_;
- size_t list_size_;
- size_t max_list_size_;
+ size_t event_list_memory_usage_;
+ size_t max_event_memory_;
TraceEvent* head_trace_;
TraceEvent* tail_trace_;
gpr_timespec time_created_;