Skip to content

Figure out how to implement hints #5036

Closed
@adinauer

Description

@adinauer

Problem Statement

Ideally, hints are aligned across SDKs.

A big part of the discussion is probably how to deal with attachments.

Use cases for hints:

  • Add attachments in case of a certain type of error where the error contains a path to a file to attach (Add the ability to attach on hard crash only sentry-java#1467).
  • Attach something to a specific event (not every event of a certain type but just a one-off thing) when calling captureEvent, like a one-off attachment
  • Remove an attachment to not be sent alongside the current event (it should be sent alongside future events, so not completely removed from scope)
  • Being able to extend hints without a breaking change.
  • ... Please add your use case here

The Java SDK has moved from an Object to a Map<String, Object> for hints here getsentry/sentry-java#1929 . We could build on top of this by adding our custom version of Map that has some helper methods on it, to make it easier to e.g. add attachments. Using some Util would do something similar but developers have to learn about the utils existence whereas they could have their IDE suggest how to do certain things via the helpers on our version of the Map.

A different approach would be to pass in an object with the methods we need and hide the map inside. This way we wouldn't pollute our hint API with things a Map can do but are not important to hints.

Another use case that was mentioned is to allow developers to store their custom data in hints to have access to it later (beforeSend / eventProcessor).

Closely related: #4996

Solution Brainstorm

Possible implementation that comes to mind:

  1. Add attachments from scope (and wherever else they may come frome) to a hint (attachments may already be in the hint as passed in via captureEvent - Add the ability to attach on hard crash only sentry-java#1467
  2. The attachments in the hint may be added to or removed from in beforeSend or eventProcessor
  3. At the end of captureEvent attachments that are in the hint should be sent (in case the event itself wasn't dropped)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions