pbrisbin / bugsnag-haskell

Bugsnag error reporter for Haskell
10 stars 7 forks source link

Composable grouping #22

Closed pbrisbin closed 6 years ago

pbrisbin commented 6 years ago

Right now we can set a "Grouping Hash" on an event directly, or based on a central Event -> Maybe Text hook in Settings. This is a very low-level (i.e. error-prone) way to do it.

I'm trying to think of a nicer way to make different grouping "strategies" declarable and composable, such that applying grouping logic from two different places won't just overwrite them depending on order.

A concrete example:

The requirements are that if we apply both (attempted) groupings to some event are:

Same code? (g1 e1 == g1 e2) Same route? (g2 e1 == g2 e2) Same hash? ((g1 • g2) e1 == (g1 • g2) e2)
y n ?
n y ?
y unknown y
unknown y y

(Obvious cases omitted)

I feel like there's some kind of generic combinator we can use to get here, possibly depending on our choices for cases (1) and (2), on which I'm flexible.

pbrisbin commented 6 years ago

I think there's no reasonable use-case for this being library-provided. For better or worse, the Bugsnag API considers a single, event-wide groupingHash. This means we're unlikely to do any kind of Exception-specific grouping and Event-wide grouping, that would need to compose.

We expose setGroupingHash and setGroupingHashWith to determine the (single) hash based on the (single) Event. This is limiting, but also means that you have full control over composing different strategies based on static context or Event details (which implicitly includes the Exception(s) therein).