channelz: remove redundant case from AddTraceEvent and remove caps from severities (#3925)
Rename UNKNOWN and INFO severities removing caps to match that of Warning and Error severities.
Remove redundant case from AddTraceEvent switch-case.
diff --git a/channelz/service/service_test.go b/channelz/service/service_test.go
index 41f4f31..467ceb4 100644
--- a/channelz/service/service_test.go
+++ b/channelz/service/service_test.go
@@ -470,39 +470,39 @@
ids[0] = channelz.RegisterChannel(&dummyChannel{}, 0, refNames[0])
channelz.AddTraceEvent(logger, ids[0], 0, &channelz.TraceEventDesc{
Desc: "Channel Created",
- Severity: channelz.CtINFO,
+ Severity: channelz.CtInfo,
})
ids[1] = channelz.RegisterChannel(&dummyChannel{}, ids[0], refNames[1])
channelz.AddTraceEvent(logger, ids[1], 0, &channelz.TraceEventDesc{
Desc: "Channel Created",
- Severity: channelz.CtINFO,
+ Severity: channelz.CtInfo,
Parent: &channelz.TraceEventDesc{
Desc: fmt.Sprintf("Nested Channel(id:%d) created", ids[1]),
- Severity: channelz.CtINFO,
+ Severity: channelz.CtInfo,
},
})
ids[2] = channelz.RegisterSubChannel(&dummyChannel{}, ids[0], refNames[2])
channelz.AddTraceEvent(logger, ids[2], 0, &channelz.TraceEventDesc{
Desc: "SubChannel Created",
- Severity: channelz.CtINFO,
+ Severity: channelz.CtInfo,
Parent: &channelz.TraceEventDesc{
Desc: fmt.Sprintf("SubChannel(id:%d) created", ids[2]),
- Severity: channelz.CtINFO,
+ Severity: channelz.CtInfo,
},
})
ids[3] = channelz.RegisterChannel(&dummyChannel{}, ids[1], refNames[3])
channelz.AddTraceEvent(logger, ids[3], 0, &channelz.TraceEventDesc{
Desc: "Channel Created",
- Severity: channelz.CtINFO,
+ Severity: channelz.CtInfo,
Parent: &channelz.TraceEventDesc{
Desc: fmt.Sprintf("Nested Channel(id:%d) created", ids[3]),
- Severity: channelz.CtINFO,
+ Severity: channelz.CtInfo,
},
})
channelz.AddTraceEvent(logger, ids[0], 0, &channelz.TraceEventDesc{
Desc: fmt.Sprintf("Channel Connectivity change to %v", connectivity.Ready),
- Severity: channelz.CtINFO,
+ Severity: channelz.CtInfo,
})
channelz.AddTraceEvent(logger, ids[0], 0, &channelz.TraceEventDesc{
Desc: "Resolver returns an empty address list",
@@ -573,26 +573,26 @@
ids[0] = channelz.RegisterChannel(&dummyChannel{}, 0, refNames[0])
channelz.AddTraceEvent(logger, ids[0], 0, &channelz.TraceEventDesc{
Desc: "Channel Created",
- Severity: channelz.CtINFO,
+ Severity: channelz.CtInfo,
})
ids[1] = channelz.RegisterSubChannel(&dummyChannel{}, ids[0], refNames[1])
channelz.AddTraceEvent(logger, ids[1], 0, &channelz.TraceEventDesc{
Desc: subchanCreated,
- Severity: channelz.CtINFO,
+ Severity: channelz.CtInfo,
Parent: &channelz.TraceEventDesc{
Desc: fmt.Sprintf("Nested Channel(id:%d) created", ids[0]),
- Severity: channelz.CtINFO,
+ Severity: channelz.CtInfo,
},
})
ids[2] = channelz.RegisterNormalSocket(&dummySocket{}, ids[1], refNames[2])
ids[3] = channelz.RegisterNormalSocket(&dummySocket{}, ids[1], refNames[3])
channelz.AddTraceEvent(logger, ids[1], 0, &channelz.TraceEventDesc{
Desc: subchanConnectivityChange,
- Severity: channelz.CtINFO,
+ Severity: channelz.CtInfo,
})
channelz.AddTraceEvent(logger, ids[1], 0, &channelz.TraceEventDesc{
Desc: subChanPickNewAddress,
- Severity: channelz.CtINFO,
+ Severity: channelz.CtInfo,
})
for _, id := range ids {
defer channelz.RemoveEntry(id)
diff --git a/clientconn.go b/clientconn.go
index 6097c87..cbd671a 100644
--- a/clientconn.go
+++ b/clientconn.go
@@ -151,10 +151,10 @@
cc.channelzID = channelz.RegisterChannel(&channelzChannel{cc}, cc.dopts.channelzParentID, target)
channelz.AddTraceEvent(logger, cc.channelzID, 0, &channelz.TraceEventDesc{
Desc: "Channel Created",
- Severity: channelz.CtINFO,
+ Severity: channelz.CtInfo,
Parent: &channelz.TraceEventDesc{
Desc: fmt.Sprintf("Nested Channel(id:%d) created", cc.channelzID),
- Severity: channelz.CtINFO,
+ Severity: channelz.CtInfo,
},
})
} else {
@@ -744,10 +744,10 @@
ac.channelzID = channelz.RegisterSubChannel(ac, cc.channelzID, "")
channelz.AddTraceEvent(logger, ac.channelzID, 0, &channelz.TraceEventDesc{
Desc: "Subchannel Created",
- Severity: channelz.CtINFO,
+ Severity: channelz.CtInfo,
Parent: &channelz.TraceEventDesc{
Desc: fmt.Sprintf("Subchannel(id:%d) created", ac.channelzID),
- Severity: channelz.CtINFO,
+ Severity: channelz.CtInfo,
},
})
}
@@ -1033,12 +1033,12 @@
if channelz.IsOn() {
ted := &channelz.TraceEventDesc{
Desc: "Channel Deleted",
- Severity: channelz.CtINFO,
+ Severity: channelz.CtInfo,
}
if cc.dopts.channelzParentID != 0 {
ted.Parent = &channelz.TraceEventDesc{
Desc: fmt.Sprintf("Nested channel(id:%d) deleted", cc.channelzID),
- Severity: channelz.CtINFO,
+ Severity: channelz.CtInfo,
}
}
channelz.AddTraceEvent(logger, cc.channelzID, 0, ted)
@@ -1451,10 +1451,10 @@
if channelz.IsOn() {
channelz.AddTraceEvent(logger, ac.channelzID, 0, &channelz.TraceEventDesc{
Desc: "Subchannel Deleted",
- Severity: channelz.CtINFO,
+ Severity: channelz.CtInfo,
Parent: &channelz.TraceEventDesc{
Desc: fmt.Sprintf("Subchanel(id:%d) deleted", ac.channelzID),
- Severity: channelz.CtINFO,
+ Severity: channelz.CtInfo,
},
})
// TraceEvent needs to be called before RemoveEntry, as TraceEvent may add trace reference to
diff --git a/internal/channelz/funcs.go b/internal/channelz/funcs.go
index 81d3dd3..f731413 100644
--- a/internal/channelz/funcs.go
+++ b/internal/channelz/funcs.go
@@ -297,9 +297,7 @@
func AddTraceEvent(l grpclog.DepthLoggerV2, id int64, depth int, desc *TraceEventDesc) {
for d := desc; d != nil; d = d.Parent {
switch d.Severity {
- case CtUNKNOWN:
- l.InfoDepth(depth+1, d.Desc)
- case CtINFO:
+ case CtUnknown, CtInfo:
l.InfoDepth(depth+1, d.Desc)
case CtWarning:
l.WarningDepth(depth+1, d.Desc)
diff --git a/internal/channelz/logging.go b/internal/channelz/logging.go
index e94039e..b0013f9 100644
--- a/internal/channelz/logging.go
+++ b/internal/channelz/logging.go
@@ -31,7 +31,7 @@
if IsOn() {
AddTraceEvent(l, id, 1, &TraceEventDesc{
Desc: fmt.Sprint(args...),
- Severity: CtINFO,
+ Severity: CtInfo,
})
} else {
l.InfoDepth(1, args...)
@@ -44,7 +44,7 @@
if IsOn() {
AddTraceEvent(l, id, 1, &TraceEventDesc{
Desc: msg,
- Severity: CtINFO,
+ Severity: CtInfo,
})
} else {
l.InfoDepth(1, msg)
diff --git a/internal/channelz/types.go b/internal/channelz/types.go
index 075dc7d..3c595d1 100644
--- a/internal/channelz/types.go
+++ b/internal/channelz/types.go
@@ -672,10 +672,10 @@
type Severity int
const (
- // CtUNKNOWN indicates unknown severity of a trace event.
- CtUNKNOWN Severity = iota
- // CtINFO indicates info level severity of a trace event.
- CtINFO
+ // CtUnknown indicates unknown severity of a trace event.
+ CtUnknown Severity = iota
+ // CtInfo indicates info level severity of a trace event.
+ CtInfo
// CtWarning indicates warning level severity of a trace event.
CtWarning
// CtError indicates error level severity of a trace event.
diff --git a/resolver_conn_wrapper.go b/resolver_conn_wrapper.go
index 265002a..f2d8196 100644
--- a/resolver_conn_wrapper.go
+++ b/resolver_conn_wrapper.go
@@ -217,6 +217,6 @@
}
channelz.AddTraceEvent(logger, ccr.cc.channelzID, 0, &channelz.TraceEventDesc{
Desc: fmt.Sprintf("Resolver state updated: %+v (%v)", s, strings.Join(updates, "; ")),
- Severity: channelz.CtINFO,
+ Severity: channelz.CtInfo,
})
}