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 */
Definition: sync.h:40
Definition: ref_counted_ptr.h:35
Definition: channelz.h:74
void RecordCallSucceeded()
Definition: channelz.cc:130
void RecordCallFailed()
Definition: channelz.cc:125
void RecordCallStarted()
Definition: channelz.cc:117
Severity
Definition: channel_trace.h:47
void AddTraceEventWithReference(Severity severity, const grpc_slice &data, RefCountedPtr< BaseNode > referenced_entity)
Definition: channel_trace.cc:118
void AddTraceEvent(Severity severity, const grpc_slice &data)
Definition: channel_trace.cc:110
Definition: client_channel_channelz.h:37
~SubchannelNode() override
Definition: client_channel_channelz.cc:39
void RecordCallStarted()
Definition: client_channel_channelz.h:62
void AddTraceEventWithReference(ChannelTrace::Severity severity, const grpc_slice &data, RefCountedPtr< BaseNode > referenced_channel)
Definition: client_channel_channelz.h:56
void RecordCallSucceeded()
Definition: client_channel_channelz.h:64
void RecordCallFailed()
Definition: client_channel_channelz.h:63
void UpdateConnectivityState(grpc_connectivity_state state)
Definition: client_channel_channelz.cc:41
void SetChildSocket(RefCountedPtr< SocketNode > socket)
Definition: client_channel_channelz.cc:45
SubchannelNode(std::string target_address, size_t channel_tracer_max_nodes)
Definition: client_channel_channelz.cc:33
void AddTraceEvent(ChannelTrace::Severity severity, const grpc_slice &data)
Definition: client_channel_channelz.h:53
grpc_json * RenderJson() override
Definition: client_channel_channelz.cc:59
grpc_connectivity_state
Connectivity state of a channel.
Definition: connectivity_state.h:27
@ GRPC_CHANNEL_IDLE
channel is idle
Definition: connectivity_state.h:29
Round Robin Policy.
Definition: backend_metric.cc:24
Definition: json.h:32
A grpc_slice s, if initialized, represents the byte range s.bytes[0..s.length-1].
Definition: slice.h:60