newrelic / go-agent

New Relic Go Agent
Apache License 2.0
762 stars 294 forks source link

Use error.Error() string for log attributes #947

Closed ejsolberg closed 6 days ago

ejsolberg commented 3 weeks ago

Links

Running against the latest agent version v3.34.0

w/ Logrus LogsInContext configured (doc)

Related to new functionality added in Capture Log Attributes in the Agent https://github.com/newrelic/go-agent/pull/900 Using Logrus attributes https://github.com/newrelic/go-agent/pull/937

Details

Currently, when errors are logged with the Logs in Context integration, the type is emitted instead of the error string.

log.WithError(fmt.Errorf("this is the error message")).Error("Something went wrong")

Console output:

{"error":"this is the error message","level":"error","msg":"Something went wrong"}

NewRelic Log:

{"error":"*errors.errorString","level":"error","msg":"Something went wrong"}

This change aligns the NewRelic log attribute with the console output

CLAassistant commented 3 weeks ago

CLA assistant check
All committers have signed the CLA.

iamemilio commented 2 weeks ago

Hi, thanks for this contribution! Can you rebase it against develop? That is where we stage all of our commits. Otherwise, it looks good!

ejsolberg commented 2 weeks ago

Hi @iamemilio, thanks for the initial review! I've rebased to develop