Skip to content

Commit

Permalink
dont slice zsl.With
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanfkeepers committed Dec 18, 2024
1 parent f05a5f8 commit 9bfc27b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions clog/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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())
Expand Down

0 comments on commit 9bfc27b

Please sign in to comment.