You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
NOTE In my case, Google Cloud Logging no longer recognized the borked logging.googleapis.com/labels as special values and does not merge them with the labels field.
I revised the implementation (improvements welcome):
renderLabels:=func(kvList []interface{}) []interface{} {
// If loggingLabels is present, it will be the first label keyk, _:=kvList[0].(string)
ifk==loggingLabels&&len(kvList) >2 {
// The label values should be a PseudoStructv, _:=kvList[1].(funcr.PseudoStruct)
// Append additional ([2:]) label keys|values to the existing loggingLabels// loggingLabels becomes the only label keyreturn []interface{}{
loggingLabels,
append(v, funcr.PseudoStruct(kvList[2:])...),
}
}
// loggingLabels becomes the only label keyreturn []interface{}{
loggingLabels,
funcr.PseudoStruct(kvList),
}
}
And, replacing NewStdoutLogger with NewStructuredLogger, I get:
This isn't an issue with
go-logr
but it may be worth identifying as a potential trap for the unwary; I will update my blog post.My naive implementation of
RenderValuesHook
was:This worked fine if
WithValues
is only called once per Logger. IfWithValues
is called again, the existing labels are nested within the new set, i.e.:Using
NewStdoutLogger
, the issue does not occur:Outputs:
So, it's an issue with my implementation.
I revised the implementation (improvements welcome):
And, replacing
NewStdoutLogger
withNewStructuredLogger
, I get:The text was updated successfully, but these errors were encountered: