GRPC Core  18.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 namespace channelz {
33 
34 class SubchannelNode : public BaseNode {
35  public:
36  SubchannelNode(std::string target_address, size_t channel_tracer_max_nodes);
37  ~SubchannelNode() override;
38 
39  // Sets the subchannel's connectivity state without health checking.
41 
42  // Used when the subchannel's child socket changes. This should be set when
43  // the subchannel's transport is created and set to nullptr when the
44  // subchannel unrefs the transport.
46 
47  Json RenderJson() override;
48 
49  // proxy methods to composed classes.
50  void AddTraceEvent(ChannelTrace::Severity severity, const grpc_slice& data) {
51  trace_.AddTraceEvent(severity, data);
52  }
54  const grpc_slice& data,
55  RefCountedPtr<BaseNode> referenced_channel) {
56  trace_.AddTraceEventWithReference(severity, data,
57  std::move(referenced_channel));
58  }
59  void RecordCallStarted() { call_counter_.RecordCallStarted(); }
60  void RecordCallFailed() { call_counter_.RecordCallFailed(); }
61  void RecordCallSucceeded() { call_counter_.RecordCallSucceeded(); }
62 
63  private:
65  Mutex socket_mu_;
66  RefCountedPtr<SocketNode> child_socket_ ABSL_GUARDED_BY(socket_mu_);
67  std::string target_;
68  CallCountingHelper call_counter_;
69  ChannelTrace trace_;
70 };
71 
72 } // namespace channelz
73 } // namespace grpc_core
74 
75 #endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_CLIENT_CHANNEL_CHANNELZ_H */
Definition: json.h:38
Definition: sync.h:59
Definition: ref_counted_ptr.h:35
Definition: channelz.h:73
void RecordCallSucceeded()
Definition: channelz.cc:99
void RecordCallFailed()
Definition: channelz.cc:94
void RecordCallStarted()
Definition: channelz.cc:86
Severity
Definition: channel_trace.h:47
void AddTraceEventWithReference(Severity severity, const grpc_slice &data, RefCountedPtr< BaseNode > referenced_entity)
Definition: channel_trace.cc:120
void AddTraceEvent(Severity severity, const grpc_slice &data)
Definition: channel_trace.cc:112
Definition: client_channel_channelz.h:34
~SubchannelNode() override
Definition: client_channel_channelz.cc:39
void RecordCallStarted()
Definition: client_channel_channelz.h:59
void AddTraceEventWithReference(ChannelTrace::Severity severity, const grpc_slice &data, RefCountedPtr< BaseNode > referenced_channel)
Definition: client_channel_channelz.h:53
void RecordCallSucceeded()
Definition: client_channel_channelz.h:61
void RecordCallFailed()
Definition: client_channel_channelz.h:60
void UpdateConnectivityState(grpc_connectivity_state state)
Definition: client_channel_channelz.cc:41
Json RenderJson() override
Definition: client_channel_channelz.cc:50
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:50
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:26
A grpc_slice s, if initialized, represents the byte range s.bytes[0..s.length-1].
Definition: slice.h:60