func (ch *Channel) IntrospectState(opts *IntrospectionOptions) *RuntimeState {
	if opts == nil {
		opts = &IntrospectionOptions{}
	}

	ch.mutable.RLock()
	state := ch.mutable.state
	numConns := len(ch.mutable.conns)
	inactiveConns := make([]*Connection, 0, numConns)
	connIDs := make([]uint32, 0, numConns)
	for id, conn := range ch.mutable.conns {
		connIDs = append(connIDs, id)
		if !conn.IsActive() {
			inactiveConns = append(inactiveConns, conn)
		}
	}

	ch.mutable.RUnlock()

	ch.State()
	return &RuntimeState{
		ID:                  ch.chID,
		ChannelState:        state.String(),
		CreatedStack:        ch.createdStack,
		LocalPeer:           ch.PeerInfo(),
		SubChannels:         ch.subChannels.IntrospectState(opts),
		RootPeers:           ch.RootPeers().IntrospectState(opts),
		Peers:               ch.Peers().IntrospectList(opts),
		NumConnections:      numConns,
		Connections:         connIDs,
		InactiveConnections: getConnectionRuntimeState(inactiveConns, opts),
		OtherChannels:       ch.IntrospectOthers(opts),
		RuntimeVersion:      introspectRuntimeVersion(),
	}
}
func (ch *Channel) IntrospectState(opts *IntrospectionOptions) *RuntimeState {
	if opts == nil {
		opts = &IntrospectionOptions{}
	}

	ch.mutable.RLock()
	state := ch.mutable.state
	numConns := len(ch.mutable.conns)
	inactiveConns := make([]*Connection, 0, numConns)
	connIDs := make([]uint32, 0, numConns)
	for id, conn := range ch.mutable.conns {
		connIDs = append(connIDs, id)
		if !conn.IsActive() {
			inactiveConns = append(inactiveConns, conn)
		}
	}

	ch.mutable.RUnlock()

	ch.State()
	return &RuntimeState{
		ID:                  ch.chID,
		ChannelState:        state.String(),
		CreatedStack:        ch.createdStack,
		LocalPeer:           ch.PeerInfo(),
		SubChannels:         ch.subChannels.IntrospectState(opts),
		RootPeers:           ch.RootPeers().IntrospectState(opts),
		Peers:               ch.Peers().IntrospectList(opts),
		NumConnections:      numConns,
		Connections:         connIDs,
		InactiveConnections: getConnectionRuntimeState(inactiveConns, opts),
		OtherChannels:       ch.IntrospectOthers(opts),
		RuntimeVersion:      introspectRuntimeVersion(),
	}
}
// IntrospectState returns the RuntimeState for this channel.
// Note: this is purely for debugging and monitoring, and may slow down your Channel.