getsentry / sentry

Developer-first error tracking and performance monitoring
https://sentry.io
Other
37.51k stars 4.04k forks source link

Showing key-value pairs when `null` value is provided to context #72890

Open bml1g12 opened 2 weeks ago

bml1g12 commented 2 weeks ago

Problem Statement

When I log the following context: {"myContext": null} but the context then gets omitted entirely. This makes senss to me for undefined values, but doesn't make sense to me for values explicity defined as null. I get the expected behaviour when I nest it in an object like {"myContext": {"nestedContext": null}} - this context does not get omitted.

Talking to Sentry support they said:

The behavior you're observing, where null values in the top-level context are omitted while nested null values are preserved (and undefined values are omitted), is indeed the intended behavior. Essentially, the choice for this was to help reduce noise in the issue details by omitting values that might not be meaningful in all contexts.

This does not appear to be documented in the Contexts Interface, but I see your point with the use of seeing all null values in the logs. I would recommend if you would like to see this improved in the future, you can submit a request via our repository.

Solution Brainstorm

Either add clear documentation that parents with null values are omitted, or even better, do not omit these

Product Area

Issues

getsantry[bot] commented 2 weeks ago

Assigning to @getsentry/support for routing ⏲️

getsantry[bot] commented 2 weeks ago

Routing to @getsentry/product-owners-issues for triage ⏲️

malwilley commented 2 weeks ago

@bml1g12 your request makes sense to me! I can see why you would want to see null values that you've explicitly set in the context. I'll see what the team thinks since this should be a simple change.