From 9bfc27bb0f6327d65184f5bfc99f5e32f05c423c Mon Sep 17 00:00:00 2001 From: keepers Date: Wed, 18 Dec 2024 13:08:28 -0700 Subject: [PATCH] dont slice zsl.With --- clog/builder.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/clog/builder.go b/clog/builder.go index 6e10246..c191eac 100644 --- a/clog/builder.go +++ b/clog/builder.go @@ -67,16 +67,20 @@ func (b builder) log(l logLevel, msg string) { record.SetBody(otellog.StringValue(msg)) record.SetSeverity(convertLevel(l)) + // attach the error and its labels if b.err != nil { // error values should override context values. maps.Copy(cv, cluerr.CluesIn(b.err).Map()) - // attach the error and its labels cv["error"] = b.err - cv["error_labels"] = cluerr.Labels(b.err) + + labels := cluerr.Labels(b.err) + if len(labels) > 0 { + cv["error_labels"] = cluerr.Labels(b.err) + } } - // attach the labels and comments, if populated + // attach the clog labels and comments if len(b.labels) > 0 { cv["clog_labels"] = maps.Keys(b.labels) } @@ -99,7 +103,7 @@ func (b builder) log(l logLevel, msg string) { // plus any values added using builder.With() for k, v := range b.with { - zsl.With(k, v) + zsl = zsl.With(k, v) attr := node.NewAttribute(stringify.Fmt(k)[0], v) record.AddAttributes(attr.KV())