Comments (16)
Thank you! I fought with this for hours before I realized it was expected behavior. Looking forward to a fix.
from go-agent.
Hi all, thank you for your advocacy and your patience. I hear your concerns and have gotten the go ahead to prioritize this ASAP. Supporting attribute collection for all v2 logs in context packages is my top priority. I will communicate expectations and upcoming changes as they come. I will communicate about this primarily in #768 since that is where most people seem to be tracking this issue.
from go-agent.
https://github.com/newrelic/go-agent/releases/tag/v3.33.0 - Adds this feature to Zap.
Upcoming releases will add this to zerolog and slog too
from go-agent.
@mariusgrigaitis I managed to add a simple middleware to add all the attributes to the message and this way you can at least see meaningful logs in NewRelic's console, here's the part of the code using https://github.com/samber/slog-multi/
....
logger := slog.New(
slogmulti.
Pipe(slogmulti.NewHandleInlineMiddleware(concatAttrsMiddleware)).
Handler(nrslog.JSONHandler(app, os.Stdout, opts)),
)
....
func concatAttrsMiddleware(ctx context.Context, record slog.Record, next func(context.Context, slog.Record) error) error {
flat := strings.Builder{}
record.Attrs(func(attr slog.Attr) bool {
flat.WriteString("key: " + attr.Key + " value: " + fmt.Sprintf("%v", attr.Value))
return true
})
message := record.Message
if flat.Len() > 0 {
message += ", " + flat.String()
}
return next(ctx, slog.NewRecord(record.Time, record.Level, message, record.PC))
}
from go-agent.
Same as @clarkmcc , spent hours troubleshooting this until I found this issue.
Using logrus with .WithField()
and .WithFields()
.
from go-agent.
This functionality is quite critical. Good slog practice requires adding attributes with additional metadatada, right now all is lost, only message is displayed in NewRelic's console.
from go-agent.
I am also developing on a library as a hobby to include attributes in the Logs in Context
while also logging to stdout in JSON format.
I hope you can use this as a temporary solution.
https://github.com/miyamo2/altnrslog
from go-agent.
Capturing attributes should already work for decorated logs captured by log forwarders, but the agent is not yet able to handle and emit log attributes. We will have that code settled and shipped soon, and then we can start plugging it into our logging tools: #900
from go-agent.
from go-agent.
#911 PR for slog attribute support.
from go-agent.
#911 PR for slog attribute support.
I saw it was approved a month ago. Any updates on when this is going to get released?
from go-agent.
@conamu They added support for attributes for uber/zap
in 3.33.0 - it works well but it doesn't include initial fields or fields added via WithField() :(
As a tmp bandaid, I added my own log wrapper that keeps track of the fields and just re-adds them every time a log.Debug/Info/Warn/etc is called (with or without extra attributes). Could do the same for logrus/whatever other logger you're using.
Gist: https://gist.github.com/dselans/b318d89158ad83b930221650db15c6ec
from go-agent.
we are already using logrus in most of the codebase. Im more interested in a solution to work with slog, a native package, instead of having to fix another library.
from go-agent.
The Slog package is out :)
https://github.com/newrelic/go-agent/tree/master/v3/integrations/logcontext-v2/nrslog
from go-agent.
Working on a fix for #915
from go-agent.
See: #919
from go-agent.
Related Issues (20)
- Remove fasthttp dependency from main module HOT 2
- Update google.golang.org/grpc from 1.54.0 to 1.56.3 HOT 2
- transaction.go reqBody(req *http.Request) turn nil body into non Nil body for request.Body == http.NoBody HOT 1
- Add support to CopyFrom method in pgx integration HOT 1
- fmt.Stringer support for user attributes (especially for SQL query parameters)
- UNKNOWN log levels when using the native log package HOT 2
- `.Ignore()` not ignoring transaction (go-agent + nrgin) HOT 6
- Integration for gqlgen HOT 2
- nrpgx5 data-race HOT 5
- Changelog Go agent EOL Policy link is broken HOT 1
- agent with nrzap is not forwarding logs to newrelic HOT 3
- WrapBackgroundCore background logger is not sending logs to new relic but transaction logger is HOT 12
- zap logger.With log message properties are not sent to new relic HOT 4
- go agent , but not see span, please help me ,thanks HOT 3
- Specify service version during initial newrelic configuration HOT 6
- Possible memory leak in Go agent HOT 11
- How to use AWS Lambda Web Adapter in golang app
- uber/zap WithField(...) not showing up in NR APM logs HOT 2
- potential bug in newAppRun HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-agent.