newrelic / newrelic-ruby-agent

New Relic RPM Ruby Agent
https://docs.newrelic.com/docs/apm/agents/ruby-agent/getting-started/introduction-new-relic-ruby/
Apache License 2.0
1.19k stars 597 forks source link

API to add custom attributes to logs based on context #2297

Open kaylareopelle opened 9 months ago

kaylareopelle commented 9 months ago

Is your feature request related to a problem? Please describe.

I was hoping to append metadata to the individual log entries to make it a lot easier for us to track usage, without having to resort to adding data to the log messages themselves or changing formatters, and parse with grok to pull out the data. Some of the log entries also pass the size limits of New Relic, so it makes using the grok approach a little less consistent, depending on what's coming in.

As an example: We're wanting to attach user_id metadata to the log entries, as well as authentication entry points that the user went through. (login, token, oauth) -- That allows is to isolate traffic better to see trends on usage by our customers, by the approach they're using.

  • Comment from @dinsley, on #2291

Feature Description

Create a new API that allows custom log attributes to be attached to log entries based on the current context.

Describe Alternatives

A clear and concise description of any alternative solutions or features you've considered. Are there examples you could link us to? TBD

Priority

Please help us better understand this feature request by choosing a priority from the following options: [Nice to Have, Really Want, Must Have, Blocker]

workato-integration[bot] commented 9 months ago

https://new-relic.atlassian.net/browse/NR-174386

dinsley commented 9 months ago

I'd be happy to take a crack at this one if it's something the team feels would have a chance to be merged. If so, If anyone on the project has knowledge of any high-level gotchas to watch out for when doing this it would be much appreciated!

We were looking at exploring how to solve for this other ways to get the data in there, but I'd much rather spend the time doing it here, where other people could take advantage as well.

kaylareopelle commented 9 months ago

Excellent! I'll bring this up with the team during our planning session on Monday to see if we want to move forward with this FR. I'll get back to you soon!

No gotchas come to mind at this time, but I'll think this over and update the issue if I think of any.

The PR for the global custom log attribute API might be helpful: https://github.com/newrelic/newrelic-ruby-agent/pull/2084

dinsley commented 9 months ago

Thanks! Did you happen to get a chance to discuss with the team in the planning session on this? We're hitting some issues where getting the metadata on there would be incredibly useful to pinpoint where it's originating from, so we can get some time for team member(s) in our org to get this done :)

No worries if not, we can look at alternative approaches in the platform to try and get that visibility.

kaylareopelle commented 9 months ago

Hi @dinsley, sorry for the delay, I was out sick. We talked about it as a team and would love to have this feature implemented, especially by you/your team as the reporters of the FR! 😄

We'll do everything we can to help you and your team get the PR merged. Please let us know if you have any questions or run into any roadblocks.