MCPcopy
hub / github.com/grpc/grpc-go / addChannelzTraceEvent

Method addChannelzTraceEvent

resolver_wrapper.go:190–212  ·  view source on GitHub ↗

addChannelzTraceEvent adds a channelz trace event containing the new state received from resolver implementations.

(s resolver.State)

Source from the content-addressed store, hash-verified

188// addChannelzTraceEvent adds a channelz trace event containing the new
189// state received from resolver implementations.
190func (ccr *ccResolverWrapper) addChannelzTraceEvent(s resolver.State) {
191 if !logger.V(0) && !channelz.IsOn() {
192 return
193 }
194 var updates []string
195 var oldSC, newSC *ServiceConfig
196 var oldOK, newOK bool
197 if ccr.curState.ServiceConfig != nil {
198 oldSC, oldOK = ccr.curState.ServiceConfig.Config.(*ServiceConfig)
199 }
200 if s.ServiceConfig != nil {
201 newSC, newOK = s.ServiceConfig.Config.(*ServiceConfig)
202 }
203 if oldOK != newOK || (oldOK && newOK && oldSC.rawJSONString != newSC.rawJSONString) {
204 updates = append(updates, "service config updated")
205 }
206 if len(ccr.curState.Addresses) > 0 && len(s.Addresses) == 0 {
207 updates = append(updates, "resolver returned an empty address list")
208 } else if len(ccr.curState.Addresses) == 0 && len(s.Addresses) > 0 {
209 updates = append(updates, "resolver returned new addresses")
210 }
211 channelz.Infof(logger, ccr.cc.channelz, "Resolver state updated: %s (%v)", pretty.ToJSON(s), strings.Join(updates, "; "))
212}
213
214func addressesToEndpoints(addrs []resolver.Address) []resolver.Endpoint {
215 endpoints := make([]resolver.Endpoint, 0, len(addrs))

Callers 2

UpdateStateMethod · 0.95
NewAddressMethod · 0.95

Calls 5

IsOnFunction · 0.92
InfofFunction · 0.92
ToJSONFunction · 0.92
JoinMethod · 0.80
VMethod · 0.65

Tested by

no test coverage detected