tomer-yechiel / pino-sentry-transport

MIT License
28 stars 8 forks source link

Feature request: Allow capturing the whole event as context #225

Closed TimShilov closed 3 months ago

TimShilov commented 3 months ago

Is your feature request related to a problem? Please describe. Currently, there seems to be no way to pass the whole log event payload to Sentry as context. I can only specify concrete paths that will be attached using lodash.get(). If I pass something to the error log then I think it is important to capture and want to have it in Sentry. I don't see any purpose to have a hard-coded list of things that would be attached.

Describe the solution you'd like I want to have an option to pass the whole event (maybe with the exception of a message) as a Sentry issue context. Something like this:

transport: {
            options: {
                captureFullContext: true,
                // or
                context: "full",
                minLevel: 40, // warn
                sentry: sentryOptions
            },
            target: "pino-sentry-transport",
        }

Describe alternatives you've considered I have checked lodash docs and checked the library source code to see if there's a way to pass everything and I don't think there's a way. Due to that I have just patched my package locally with pnpm patch and it works great. I'm happy to submit PR if I get a greenlight and we agree on the implementation details.

Additional context Add any other context or screenshots about the feature request here.

TimShilov commented 3 months ago

Sorry, I just realized there's withLogRecord option. 🤦‍♂️