Skip to content

Error handling within Hapi Sentry integration #11069

@joshkel

Description

@joshkel
Contributor

Problem Statement

We're looking into switching from the third-party hapi-sentry package to Sentry's built-in Hapi support, mainly to benefit from the added tracing support. However, the built-in Hapi support has what seems to be a potentially unwanted feature: every Hapi Boom response (i.e., every HTTP 4xx or 5xx response) is captured as a Sentry exception.

Is this intended? I would expect that Sentry exceptions are for things that are very likely programming errors, not conditions like bad or unauthorized requests (HTTP 4xx) that are often outside of the application's control.

Solution Brainstorm

  1. Add an option to Integrations.Hapi to configure the error plugin and tracing plugin separately (so we could continue to use the third-party hapi-sentry).
  2. More directly expose / export hapiErrorPlugin and hapiTracingPlugin so that I can add one or the other or both to my Hapi server myself (and can then pick hapi-sentry over hapiErrorPlugin).
  3. Add an option to Integrations.Hapi to control whether the error plugin captures Boom replies as exceptions.
  4. Don't capture Boom replies by default.
  5. Some combination of the above.

Activity

moved this to Waiting for: Product Owner in GitHub Issues with 👀 2on Mar 12, 2024
changed the title [-]Hapi Sentry integration[/-] [+]Error handling within Hapi Sentry integration[/+] on Mar 12, 2024
Lms24

Lms24 commented on Mar 13, 2024

@Lms24
Member

Hey @joshkel thanks for writing in! full disclosure, I don't have much context around Hapi and Boom but generally I agree, our integration probably shouldn't capture 400/500 responses by default.

@onurtemizkan would you mind taking a look at this? Maybe we can go with only optionally recording errors with a 4xx/5xx Http response?

moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 2on Mar 13, 2024
mydea

mydea commented on Mar 13, 2024

@mydea
Member

Sounds reasonable to me as well.

I wonder, should we ever send on boom responses, then? Maybe the way to go is to have a config of status codes that you want to send for, and we default it to []?

joshkel

joshkel commented on Mar 13, 2024

@joshkel
ContributorAuthor

@mydea I'm not sure about the best configuration for Sentry users as a whole. For me personally, I'm unlikely to want any Boom responses sent. If I did want to send on Boom responses, I could see wanting to choose between 4xx and 5xx, without having to enumerate every 5xx status code. That could mean a few options:

interface HapiSentryOptions {
  captureBoom4xx?: boolean;
  captureBoom5xx?: boolean;
  captureBoomStatusCodes?: number[];
}

Although I'm not sure there's enough user interest to justify the complexity.

Maybe the provided integration could stop sending on Boom and could add an example in the docs on how to implement your own capturing of Boom responses from a Hapi event handler, until there's more concrete user interest?

(Just brainstorming - you all know much better what kinds of APIs are suitable for Sentry SDKs than I do.)

moved this to Waiting for: Product Owner in GitHub Issues with 👀 2on Mar 13, 2024

7 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @joshkel@mydea@onurtemizkan@Lms24

    Issue actions

      Error handling within Hapi Sentry integration · Issue #11069 · getsentry/sentry-javascript