Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support to ZeroLog #150

Closed
matheus-meneses opened this issue May 23, 2020 · 4 comments
Closed

Add Support to ZeroLog #150

matheus-meneses opened this issue May 23, 2020 · 4 comments

Comments

@matheus-meneses
Copy link

Hi guys,
Is there a roadmap to introduce support to https://github.com/rs/zerolog ?

Regards

@jodeev
Copy link
Contributor

jodeev commented May 29, 2020

@matheus-meneses - thanks for this input. Can you confirm that you mean that we add support for the go-agent to send its log messages to zerolog?

@jodeev jodeev added this to Triage in Roadmap Jul 8, 2020
@jodeev jodeev self-assigned this Jul 9, 2020
@jodeev jodeev added this to Possible Future in Go Instrumentation Roadmap Aug 26, 2020
@jodeev jodeev added this to To Do in Go Engineering Board Feb 5, 2021
@jodeev jodeev moved this from To Do to Backlog in Go Engineering Board Mar 11, 2021
@jodeev jodeev moved this from Backlog to PM to triage in Go Engineering Board Mar 11, 2021
@belimawr
Copy link

I'm curious about is as well as we heavily use zerolog at OneFootball. For the go-agent to log using zerolog I did a very simple wrapper:

import "github.com/rs/zerolog"

const prefix = "_newrelic_agent_"

type nrLogger struct {
	l zerolog.Logger
}

func (l nrLogger) Error(msg string, context map[string]interface{}) {
	l.l.Error().Fields(sanitiseLogKeys(context)).Msg(msg)
}

func (l nrLogger) Warn(msg string, context map[string]interface{}) {
	l.l.Warn().Fields(sanitiseLogKeys(context)).Msg(msg)
}

func (l nrLogger) Info(msg string, context map[string]interface{}) {
	l.l.Info().Fields(sanitiseLogKeys(context)).Msg(msg)
}

func (l nrLogger) Debug(msg string, context map[string]interface{}) {
	l.l.Debug().Fields(sanitiseLogKeys(context)).Msg(msg)
}

func (l nrLogger) DebugEnabled() bool {
	return l.l.Debug().Enabled()
}

func sanitiseLogKeys(m map[string]interface{}) map[string]interface{} {
	final := make(map[string]interface{}, len(m))

	for k, v := range m {
		final[prefix+k] = v
	}

	return final
}

It also prefixes all keys from the go-agent to avoid collision with our own log keys.

Is that what you're looking for @matheus-meneses ?

It would be awesome to have it as part of the go-agent.

@RichVanderwal
Copy link
Contributor

We're taking a look at the input above, as well as the plugin to support it with a view to putting it into the next release of the Go Agent. Let us know if you have any other comments or suggestions!

@iamemilio
Copy link
Contributor

iamemilio commented Apr 20, 2022

I am closing this issue to consolidate tickets about zerolog logs in context. We are still planning this work, but will now track it from the ticket that is already on our roadmap: #178

Go Instrumentation Roadmap automation moved this from Future: features that anyone can implement. No commitment on if or when these features will be completed. to Done Apr 20, 2022
Go Engineering Board automation moved this from To Do to Done Apr 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

7 participants