GRPC Core  9.0.0
client_channel_channelz.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2018 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_EXT_FILTERS_CLIENT_CHANNEL_CLIENT_CHANNEL_CHANNELZ_H
20 #define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_CLIENT_CHANNEL_CHANNELZ_H
21 
23 
24 #include <string>
25 
30 
31 namespace grpc_core {
32 
33 class Subchannel;
34 
35 namespace channelz {
36 
37 class SubchannelNode : public BaseNode {
38  public:
39  SubchannelNode(std::string target_address, size_t channel_tracer_max_nodes);
40  ~SubchannelNode() override;
41 
42  // Sets the subchannel's connectivity state without health checking.
44 
45  // Used when the subchannel's child socket changes. This should be set when
46  // the subchannel's transport is created and set to nullptr when the
47  // subchannel unrefs the transport.
49 
50  grpc_json* RenderJson() override;
51 
52  // proxy methods to composed classes.
53  void AddTraceEvent(ChannelTrace::Severity severity, const grpc_slice& data) {
54  trace_.AddTraceEvent(severity, data);
55  }
57  const grpc_slice& data,
58  RefCountedPtr<BaseNode> referenced_channel) {
59  trace_.AddTraceEventWithReference(severity, data,
60  std::move(referenced_channel));
61  }
62  void RecordCallStarted() { call_counter_.RecordCallStarted(); }
63  void RecordCallFailed() { call_counter_.RecordCallFailed(); }
64  void RecordCallSucceeded() { call_counter_.RecordCallSucceeded(); }
65 
66  private:
67  void PopulateConnectivityState(grpc_json* json);
68 
70  Mutex socket_mu_;
71  RefCountedPtr<SocketNode> child_socket_;
72  std::string target_;
73  CallCountingHelper call_counter_;
74  ChannelTrace trace_;
75 };
76 
77 } // namespace channelz
78 } // namespace grpc_core
79 
80 #endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_CLIENT_CHANNEL_CHANNELZ_H */
grpc_core::channelz::SubchannelNode::SubchannelNode
SubchannelNode(std::string target_address, size_t channel_tracer_max_nodes)
Definition: client_channel_channelz.cc:33
grpc_core::channelz::CallCountingHelper::RecordCallStarted
void RecordCallStarted()
Definition: channelz.cc:117
grpc_core::Atomic< grpc_connectivity_state >
grpc_core
Round Robin Policy.
Definition: backend_metric.cc:24
grpc_core::channelz::SubchannelNode::~SubchannelNode
~SubchannelNode() override
Definition: client_channel_channelz.cc:39
grpc_json
Definition: json.h:32
grpc_core::channelz::SubchannelNode::RecordCallStarted
void RecordCallStarted()
Definition: client_channel_channelz.h:62
grpc_core::channelz::SubchannelNode::AddTraceEvent
void AddTraceEvent(ChannelTrace::Severity severity, const grpc_slice &data)
Definition: client_channel_channelz.h:53
grpc_core::channelz::CallCountingHelper::RecordCallSucceeded
void RecordCallSucceeded()
Definition: channelz.cc:130
channelz.h
grpc_connectivity_state
grpc_connectivity_state
Connectivity state of a channel.
Definition: connectivity_state.h:27
grpc_core::RefCountedPtr
Definition: ref_counted_ptr.h:35
grpc_core::channelz::CallCountingHelper::RecordCallFailed
void RecordCallFailed()
Definition: channelz.cc:125
channel_stack.h
grpc_core::channelz::SubchannelNode::RenderJson
grpc_json * RenderJson() override
Definition: client_channel_channelz.cc:59
grpc_core::channelz::ChannelTrace::Severity
Severity
Definition: channel_trace.h:47
grpc_core::channelz::SubchannelNode::RecordCallSucceeded
void RecordCallSucceeded()
Definition: client_channel_channelz.h:64
grpc_core::Mutex
Definition: sync.h:40
GRPC_CHANNEL_IDLE
@ GRPC_CHANNEL_IDLE
channel is idle
Definition: connectivity_state.h:29
grpc_core::channelz::ChannelTrace::AddTraceEventWithReference
void AddTraceEventWithReference(Severity severity, const grpc_slice &data, RefCountedPtr< BaseNode > referenced_entity)
Definition: channel_trace.cc:118
grpc_slice
A grpc_slice s, if initialized, represents the byte range s.bytes[0..s.length-1].
Definition: slice.h:60
grpc_core::channelz::SubchannelNode::AddTraceEventWithReference
void AddTraceEventWithReference(ChannelTrace::Severity severity, const grpc_slice &data, RefCountedPtr< BaseNode > referenced_channel)
Definition: client_channel_channelz.h:56
grpc_core::channelz::ChannelTrace::AddTraceEvent
void AddTraceEvent(Severity severity, const grpc_slice &data)
Definition: channel_trace.cc:110
grpc_core::channelz::SubchannelNode::SetChildSocket
void SetChildSocket(RefCountedPtr< SocketNode > socket)
Definition: client_channel_channelz.cc:45
grpc_core::channelz::SubchannelNode::RecordCallFailed
void RecordCallFailed()
Definition: client_channel_channelz.h:63
grpc_core::channelz::SubchannelNode
Definition: client_channel_channelz.h:37
channel_args.h
grpc_core::channelz::BaseNode
Definition: channelz.h:74
channel_trace.h
grpc_core::channelz::SubchannelNode::UpdateConnectivityState
void UpdateConnectivityState(grpc_connectivity_state state)
Definition: client_channel_channelz.cc:41
port_platform.h