Skip to content

Testable errortracking

Mikhail Mazurskiy requested to merge ash2k/testable-errortracking into master

An alternative proposal to !74 (closed) that builds on top of it :)

The idea is to turn package-level API, the Capture() function, into an explicit interface. Then there is a default global instance of that interface that delegates to global Sentry Hub but the user can also instantiate the API implementation, using the methods of the interface instead of package methods. This makes it possible to inject a mock implementation for the interface into the dependant code and test it. This is impossible to do today when code depends on package functions. Well, I suppose such a wrapper could exist separately from LabKit but it'd be great to not have to do that.

I think this ticks all the boxes:

  • Do not break existing clients.
  • Allow to use non-global implementation.
  • Allow to inject a mock instead of the real implementation into client code.
  • Do not leak the underlying implementation.

WDYT?

Relates to #27 (closed).

Edited by Mikhail Mazurskiy

Merge request reports