airbrake.go 573 B

1234567891011121314151617181920212223242526272829303132
  1. package airbrake
  2. import (
  3. "net/http"
  4. "github.com/airbrake/gobrake/v5"
  5. "github.com/imgproxy/imgproxy/v3/config"
  6. )
  7. var notifier *gobrake.Notifier
  8. func Init() {
  9. if len(config.AirbrakeProjecKey) > 0 {
  10. notifier = gobrake.NewNotifierWithOptions(&gobrake.NotifierOptions{
  11. ProjectId: int64(config.AirbrakeProjecID),
  12. ProjectKey: config.AirbrakeProjecKey,
  13. Environment: config.AirbrakeEnv,
  14. })
  15. }
  16. }
  17. func Report(err error, req *http.Request) {
  18. if notifier != nil {
  19. notifier.Notify(err, req)
  20. }
  21. }
  22. func Close() {
  23. if notifier != nil {
  24. notifier.Close()
  25. }
  26. }