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
Not sure if I'm doing something wrong but it can't seem to get WithField() to work - fields set either on a core or on a logger, do not show up in NR APM logs. The only attributes that show up are ones that are added via z.Info("foo", zap.String("bar", "baz")) - any existing, initial fields do not show up.
Steps to Reproduce
Create a zap core wrapped with NR zap shim -> set initial fields -> log something -> expect log message in NR to show up with extra attributes.
Example 1
// Setup go-agentapp, err:=newrelic.NewApplication(
newrelic.ConfigAppName(d.Config.NewRelicAppName),
newrelic.ConfigLicense(d.Config.NewRelicLicenseKey),
newrelic.ConfigAppLogForwardingEnabled(true),
newrelic.ConfigZapAttributesEncoder(false), // <- switching this doesn't seem to have any visible effect
)
// Create a new zap corezc:=zap.NewDevelopmentConfig()
zc.EncoderConfig.EncodeLevel=zapcore.CapitalColorLevelEncodercore=zapcore.NewCore(zapcore.NewConsoleEncoder(zc.EncoderConfig),
zapcore.AddSync(os.Stdout),
zap.DebugLevel,
)
// Wrap it with NRcore, _=nrzap.WrapBackgroundCore(core, d.NewRelicApp)
iferr!=nil {
returnerrors.Wrap(err, "unable to wrap zap core with newrelic")
}
// Try to add initial fields to corecore=core.With([]zapcore.Field{
zap.String("foo", "bar"),
})
// Create a logger + log somethingzap.New(core).Info("Logger initialized", zap.String("baz", "qux")
Example 2:
// Setup NR + zap core as before// ...// Create a new logger from an existing loggerlogger:=zap.New(core).With(zap.String("foo", "bar"))
logger.Info("New logger created")
Expected Behavior
In the above example 1, would expect "foo" field to show up in "Logger initialized" log message in NR but only see "baz" attribute.
In example 2, would expect "foo" field to show up in "New logger created" message in NR.
NR Diag results
Logs on STDOUT include the additional fields as expected.
Your Environment
Go 1.22.0 darwin/arm64
github.com/newrelic/go-agent/v3 v3.33.0
github.com/newrelic/go-agent/v3/integrations/logcontext-v2/nrzap v1.2.0
github.com/newrelic/go-agent/v3/integrations/nrhttprouter v1.1.0
Reproduction case
Shown above.
Additional context
Not sure if this is a missing feature, bug or something I'm not doing right.
Passing fields/attributes via direct calls to the log method works as expected (ie. z.Info("foo", zap.Any("bar", "baz")).
Thank you!
The text was updated successfully, but these errors were encountered:
Description
Not sure if I'm doing something wrong but it can't seem to get
WithField()
to work - fields set either on a core or on a logger, do not show up in NR APM logs. The only attributes that show up are ones that are added viaz.Info("foo", zap.String("bar", "baz"))
- any existing, initial fields do not show up.Steps to Reproduce
Create a zap core wrapped with NR zap shim -> set initial fields -> log something -> expect log message in NR to show up with extra attributes.
Example 1
Example 2:
Expected Behavior
In the above example 1, would expect "foo" field to show up in "Logger initialized" log message in NR but only see "baz" attribute.
In example 2, would expect "foo" field to show up in "New logger created" message in NR.
NR Diag results
Logs on STDOUT include the additional fields as expected.
Your Environment
Go 1.22.0 darwin/arm64
github.com/newrelic/go-agent/v3 v3.33.0
github.com/newrelic/go-agent/v3/integrations/logcontext-v2/nrzap v1.2.0
github.com/newrelic/go-agent/v3/integrations/nrhttprouter v1.1.0
Reproduction case
Shown above.
Additional context
Not sure if this is a missing feature, bug or something I'm not doing right.
Passing fields/attributes via direct calls to the log method works as expected (ie.
z.Info("foo", zap.Any("bar", "baz"))
.Thank you!
The text was updated successfully, but these errors were encountered: