Package-Level Type Names (total 23, in which 17 are exported)
/* sort exporteds by: | */
Channel represents a channel within channelz, which includes metrics and
internal channelz data, such as channelz id, child list, etc. ChannelMetrics holds connectivity state, target and call metrics for the
channel within channelz.EntityEntity ID is the channelz id of this channel.Parent*Channel RefName is the human readable reference string of this channel.closeCalledboolnestedChansmap[int64]stringsubChansmap[int64]stringtrace*ChannelTrace traceRefCount is the number of trace events that reference this channel.
Non-zero traceRefCount means the trace of this channel cannot be deleted. NestedChans returns a copy of the map of nested channels associated with the
Channel. String returns a string representation of the Channel, including its parent
entity and ID. SubChans returns a copy of the map of sub-channels associated with the
Channel. Trace returns a copy of the Channel's trace data.(*Channel) addChild(id int64, e entry) Implemented to make Channel implement the Identifier interface used for
nesting.(*Channel) decrTraceRefCount()(*Channel) deleteChild(id int64) deleteSelfFromMap checks whether it is valid to delete the channel from the map, which means
deleting the channel from channelz's tracking entirely. Users can no longer use id to query the
channel, and its memory will be garbage collected.
The trace reference count of the channel must be 0 in order to be deleted from the map. This is
specified in the channel tracing gRFC that as long as some other trace has reference to an entity,
the trace of the referenced entity must not be deleted. In order to release the resource allocated
by grpc, the reference to the grpc object is reset to a dummy object.
deleteSelfFromMap must be called after deleteSelfFromTree returns true.
It returns a bool to indicate whether the channel can be safely deleted from map. deleteSelfFromTree tries to delete the channel from the channelz entry relation tree, which means
deleting the channel reference from its parent's child list.
In order for a channel to be deleted from the tree, it must meet the criteria that, removal of the
corresponding grpc object has been invoked, and the channel does not have any children left.
The returned boolean value indicates whether the channel has been successfully deleted from tree. deleteSelfIfReady tries to delete the channel itself from the channelz database.
The delete process includes two steps:
1. delete the channel from the entry relation tree, i.e. delete the channel reference from its
parent's child list.
2. delete the channel from the map, i.e. delete the channel entirely from channelz. Lookup by id
will return entry not found error.(*Channel) getChannelTrace() *ChannelTrace(*Channel) getParentID() int64(*Channel) getRefName() string(*Channel) getTraceRefCount() int(*Channel) id() int64(*Channel) incrTraceRefCount()( Channel) isEntity()(*Channel) triggerDelete()
*Channel : Entity
*Channel : Identifier
*Channel : expvar.Var
*Channel : fmt.Stringer
*Channel : entry
*Channel : tracedChannel
*Channel : context.stringer
*Channel : runtime.stringer
func GetChannel(id int64) *Channel
func GetTopChannels(id int64, maxResults int) ([]*Channel, bool)
func RegisterChannel(parent *Channel, target string) *Channel
func RegisterChannel(parent *Channel, target string) *Channel
func RegisterSubChannel(parent *Channel, ref string) *SubChannel
func google.golang.org/grpc.newConnectivityStateManager(ctx context.Context, channel *Channel) *grpc.connectivityStateManager
ChannelMetrics holds connectivity state, target and call metrics for the
channel within channelz. The number of calls that have a completed with a non-OK status. The number of calls started on the channel. The number of calls that have completed with an OK status. The last time a call was started on the channel. The current connectivity state of the channel. The target this channel originally tried to connect to. May be absent CopyFrom copies the metrics in o to c. For testing only. Equal returns true iff the metrics of c are the same as the metrics of o.
For testing only. String returns a string representation of the ChannelMetrics, including its
state, target, and call metrics.
*ChannelMetrics : expvar.Var
*ChannelMetrics : fmt.Stringer
*ChannelMetrics : context.stringer
*ChannelMetrics : runtime.stringer
func NewChannelMetricForTesting(state connectivity.State, target string, started, succeeded, failed, timestamp int64) *ChannelMetrics
func (*ChannelMetrics).CopyFrom(o *ChannelMetrics)
ChannelTrace provides tracing information for a channel.
It tracks various events and metadata related to the channel's lifecycle
and operations. The time when the trace was created. A counter for the number of events recorded in the
trace. A slice of traceEvent pointers representing the events recorded for
this channel.clearCalledboolcm*channelMapmusync.Mutex(*ChannelTrace) append(e *traceEvent)(*ChannelTrace) clear()(*ChannelTrace) copy() *ChannelTrace
func (*Channel).Trace() *ChannelTrace
func (*SubChannel).Trace() *ChannelTrace
func (*Channel).getChannelTrace() *ChannelTrace
func (*ChannelTrace).copy() *ChannelTrace
func (*SubChannel).getChannelTrace() *ChannelTrace
EphemeralSocketMetrics are metrics that change rapidly and are tracked
outside of channelz. The amount of window, granted to the local endpoint by the remote endpoint.
This may be slightly out of date due to network latency. This does NOT
include stream level or TCP level flow control info. The amount of window, granted to the remote endpoint by the local endpoint.
This may be slightly out of date due to network latency. This does NOT
include stream level or TCP level flow control info.
IDGenerator is an incrementing atomic that tracks IDs for channelz entities.idint64 Reset resets the generated ID back to zero. Should only be used at
initialization or by tests sensitive to the ID number.(*IDGenerator) genID() int64
var IDGen
ServerMetrics defines a struct containing metrics for servers. The number of incoming calls that have a completed with a non-OK status. The number of incoming calls started on the server. The number of incoming calls that have completed with an OK status. The last time a call was started on the server. CopyFrom copies the metrics data from the provided ServerMetrics
instance into the current instance.
func NewServerMetricsForTesting(started, succeeded, failed, timestamp int64) *ServerMetrics
func (*ServerMetrics).CopyFrom(o *ServerMetrics)
Severity is the severity level of a trace event.
The canonical enumeration of all valid values is here:
https://github.com/grpc/grpc-proto/blob/9b13d199cc0d4703c7ea26c9c330ba695866eb23/grpc/channelz/v1/channelz.proto#L126.
const CtError
const CtInfo
const CtUnknown
const CtWarning
SocketMetrics defines the struct that the implementor of Socket interface
should return from ChannelzMetric(). The number of keep alives sent. This is typically implemented with HTTP/2
ping messages. The last time a stream was created by this endpoint. Usually unset for
servers. The last time a message was received by this endpoint. The last time a message was sent by this endpoint. The last time a stream was created by the remote endpoint. Usually unset
for clients.MessagesReceivedatomic.Int64 The number of messages successfully sent on this socket. The number of streams that have ended unsuccessfully:
On client side, termination without receiving frame with eos bit set.
On server side, termination without sending frame with eos bit set. The number of streams that have been started. The number of streams that have ended successfully:
On client side, receiving frame with eos bit set.
On server side, sending frame with eos bit set.
SubChannel is the channelz representation of a subchannel.ChannelMetricsChannelMetricsEntityEntity ID is the channelz id of this subchannel. RefName is the human readable reference string of this subchannel.closeCalledboolparent*Channelsocketsmap[int64]stringtrace*ChannelTracetraceRefCountint32 Sockets returns a copy of the sockets map associated with the SubChannel.(*SubChannel) String() string Trace returns a copy of the ChannelTrace associated with the SubChannel.(*SubChannel) addChild(id int64, e entry)(*SubChannel) decrTraceRefCount()(*SubChannel) deleteChild(id int64) deleteSelfFromMap checks whether it is valid to delete the subchannel from the map, which means
deleting the subchannel from channelz's tracking entirely. Users can no longer use id to query
the subchannel, and its memory will be garbage collected.
The trace reference count of the subchannel must be 0 in order to be deleted from the map. This is
specified in the channel tracing gRFC that as long as some other trace has reference to an entity,
the trace of the referenced entity must not be deleted. In order to release the resource allocated
by grpc, the reference to the grpc object is reset to a dummy object.
deleteSelfFromMap must be called after deleteSelfFromTree returns true.
It returns a bool to indicate whether the channel can be safely deleted from map. deleteSelfFromTree tries to delete the subchannel from the channelz entry relation tree, which
means deleting the subchannel reference from its parent's child list.
In order for a subchannel to be deleted from the tree, it must meet the criteria that, removal of
the corresponding grpc object has been invoked, and the subchannel does not have any children left.
The returned boolean value indicates whether the channel has been successfully deleted from tree. deleteSelfIfReady tries to delete the subchannel itself from the channelz database.
The delete process includes two steps:
1. delete the subchannel from the entry relation tree, i.e. delete the subchannel reference from
its parent's child list.
2. delete the subchannel from the map, i.e. delete the subchannel entirely from channelz. Lookup
by id will return entry not found error.(*SubChannel) getChannelTrace() *ChannelTrace(*SubChannel) getParentID() int64(*SubChannel) getRefName() string(*SubChannel) getTraceRefCount() int(*SubChannel) id() int64(*SubChannel) incrTraceRefCount()( SubChannel) isEntity()(*SubChannel) triggerDelete()
*SubChannel : Entity
*SubChannel : expvar.Var
*SubChannel : fmt.Stringer
*SubChannel : entry
*SubChannel : tracedChannel
*SubChannel : context.stringer
*SubChannel : runtime.stringer
func GetSubChannel(id int64) *SubChannel
func RegisterSubChannel(parent *Channel, ref string) *SubChannel
TraceEvent is what the caller of AddTraceEvent should provide to describe the
event to be added to the channel trace.
The Parent field is optional. It is used for an event that will be recorded
in the entity's parent trace.DescstringParent*TraceEventSeveritySeverity
func AddTraceEvent(l grpclog.DepthLoggerV2, e Entity, depth int, desc *TraceEvent)
channelMap is the storage data structure for channelz.
Methods of channelMap can be divided into two categories with respect to
locking.
1. Methods acquire the global lock.
2. Methods that can only be called when global lock is held.
A second type of method need always to be called inside a first type of method.channelsmap[int64]*Channelmusync.RWMutexserversmap[int64]*Serversocketsmap[int64]*SocketsubChannelsmap[int64]*SubChanneltopLevelChannelsmap[int64]struct{}(*channelMap) addChannel(id int64, cn *Channel, isTopChannel bool, pid int64)(*channelMap) addServer(id int64, s *Server)(*channelMap) addSocket(s *Socket)(*channelMap) addSubChannel(id int64, sc *SubChannel, pid int64) c.mu must be held by the caller c.mu must be held by the caller
deleteEntry deletes an entry from the channelMap. Before calling this method,
caller must check this entry is ready to be deleted, i.e removeEntry() has
been called on it, and no children still exist. c.mu must be held by the caller.(*channelMap) getChannel(id int64) *Channel(*channelMap) getServer(id int64) *Server(*channelMap) getServerSockets(id int64, startID int64, maxResults int) ([]*Socket, bool)(*channelMap) getServers(id int64, maxResults int) ([]*Server, bool)(*channelMap) getSocket(id int64) *Socket(*channelMap) getSubChannel(id int64) *SubChannel(*channelMap) getTopChannels(id int64, maxResults int) ([]*Channel, bool) removeEntry triggers the removal of an entry, which may not indeed delete the
entry, if it has to wait on the deletion of its children and until no other
entity's channel trace references it. It may lead to a chain of entry
deletion. For example, deleting the last socket of a gracefully shutting down
server will lead to the server being also deleted.(*channelMap) traceEvent(id int64, desc *TraceEvent)
func newChannelMap() *channelMap
var db *channelMap
entry represents a node in the channelz database.( entry) String() string addChild adds a child e, whose channelz id is id to child list deleteChild deletes a child with channelz id to be id from child list deleteSelfIfReady check whether triggerDelete() has been called before,
and whether child list is now empty. If both conditions are met, then
delete self from database. getParentID returns parent ID of the entry. 0 value parent ID means no parent.( entry) id() int64( entry) isEntity() triggerDelete tries to delete self from channelz database. However, if
child list is not empty, then deletion from the database is on hold until
the last child is deleted from database.
*Channel
*Server
*Socket
*SubChannel
*dummyEntry
entry : Entity
entry : expvar.Var
entry : fmt.Stringer
entry : context.stringer
entry : runtime.stringer
func (*Channel).addChild(id int64, e entry)
func (*Server).addChild(id int64, e entry)
func (*Socket).addChild(id int64, e entry)
func (*SubChannel).addChild(id int64, e entry)
traceEvent is an internal representation of a single trace event Desc is a simple description of the trace event. RefID is the id of the entity that gets referenced in the event. RefID is 0 if no other entity is
involved in this event.
e.g. SubChannel (id: 4[]) Created. --> RefID = 4, RefName = "" (inside []) RefName is the reference name for the entity that gets referenced in the event. RefType indicates the referenced entity type, i.e Channel or SubChannel. Severity states the severity of this trace event. Timestamp is the event time.
func (*ChannelTrace).append(e *traceEvent)
Package-Level Functions (total 31, in which 26 are exported)
AddTraceEvent adds trace related to the entity with specified id, using the
provided TraceEventDesc.
If channelz is not turned ON, this will simply log the event descriptions.
Error logs and adds a trace event if channelz is on.
Errorf logs and adds a trace event if channelz is on.
GetChannel returns the Channel for the channel (identified by id).
GetServer returns the ServerMetric for the server (identified by id).
GetServers returns a slice of server's ServerMetric, along with a
boolean indicating whether there's more servers to be queried for.
The arg id specifies that only server with id at or above it will be included
in the result. The returned slice is up to a length of the arg maxResults or
EntriesPerPage if maxResults is zero, and is sorted in ascending id order.
GetServerSockets returns a slice of server's (identified by id) normal socket's
SocketMetrics, along with a boolean indicating whether there's more sockets to
be queried for.
The arg startID specifies that only sockets with id at or above it will be
included in the result. The returned slice is up to a length of the arg maxResults
or EntriesPerPage if maxResults is zero, and is sorted in ascending id order.
GetSocket returns the Socket for the socket (identified by id).
GetSocketOption gets the socket option info of the conn.
GetSubChannel returns the SubChannel for the subchannel (identified by id).
GetTopChannels returns a slice of top channel's ChannelMetric, along with a
boolean indicating whether there's more top channels to be queried for.
The arg id specifies that only top channel with id at or above it will be
included in the result. The returned slice is up to a length of the arg
maxResults or EntriesPerPage if maxResults is zero, and is sorted in ascending
id order.
Info logs and adds a trace event if channelz is on.
Infof logs and adds a trace event if channelz is on.
IsOn returns whether channelz data collection is on.
NewChannelMetricForTesting creates a new instance of ChannelMetrics with
specified initial values for testing purposes.
NewServerMetricsForTesting returns an initialized ServerMetrics.
RegisterChannel registers the given channel c in the channelz database with
target as its target and reference name, and adds it to the child list of its
parent. parent == nil means no parent.
Returns a unique channelz identifier assigned to this channel.
If channelz is not turned ON, the channelz database is not mutated.
RegisterServer registers the given server s in channelz database. It returns
the unique channelz tracking id assigned to this server.
If channelz is not turned ON, the channelz database is not mutated.
RegisterSocket registers the given normal socket s in channelz database
with ref as its reference name, and adds it to the child list of its parent
(identified by skt.Parent, which must be set). It returns the unique channelz
tracking id assigned to this normal socket.
If channelz is not turned ON, the channelz database is not mutated.
RegisterSubChannel registers the given subChannel c in the channelz database
with ref as its reference name, and adds it to the child list of its parent
(identified by pid).
Returns a unique channelz identifier assigned to this subChannel.
If channelz is not turned ON, the channelz database is not mutated.
RemoveEntry removes an entry with unique channelz tracking id to be id from
channelz database.
If channelz is not turned ON, this function is a no-op.
ResetMaxTraceEntryToDefault resets the maximum number of trace entries per
entity to default.
SetMaxTraceEntry sets maximum number of trace entries per entity (i.e.
channel/subchannel). Setting it to 0 will disable channel tracing.
TurnOn turns on channelz data collection.
Warning logs and adds a trace event if channelz is on.
Warningf logs and adds a trace event if channelz is on.