airbrake

package module
v0.0.0-...-5f95039 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 28, 2020 License: MIT Imports: 4 Imported by: 0

README

Airbrake / Errbit handler

GitHub Workflow Status Codecov Go Report Card Go Version go.dev reference

Error handler integration for Airbrake / Errbit.

Installation

go get emperror.dev/handler/airbrake

Usage

package main

import (
	"github.com/airbrake/gobrake"

	"emperror.dev/handler/airbrake"
)

func main() {
    projectID := int64(1)
	projectKey := "key"

	handler := airbrake.New(projectID, projectKey)
	defer handler.Close() // Make sure to close the handler to flush all error reporting in progress
}

Development

When all coding and testing is done, please run the test suite:

$ make check
Running integration tests
# Set up the environment
cp docker-compose.override.yml.dist docker-compose.override.yml
cp .env.test.dist .env.test
docker-compose up -d
docker-compose run --rm errbit rake db:seed
source .env.test

# Run tests
make test

# Cleanup
docker-compose down

License

The MIT License (MIT). Please see License File for more information.

Documentation

Overview

Package airbrake provides Airbrake/Errbit integration.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler is responsible for sending errors to Airbrake/Errbit.

func New

func New(projectID int64, projectKey string) *Handler

New creates a new handler.

Example
package main

import (
	"emperror.dev/handler/airbrake"
)

func main() {
	projectID := int64(1)
	projectKey := "key"

	handler := airbrake.New(projectID, projectKey)
	defer handler.Close() // Make sure to close the handler to flush all error reporting in progress

}
Output:

func NewFromNotifier

func NewFromNotifier(notifier *gobrake.Notifier) *Handler

NewFromNotifier creates a new handler from a notifier instance.

Example
package main

import (
	"github.com/airbrake/gobrake"

	"emperror.dev/handler/airbrake"
)

func main() {
	projectID := int64(1)
	projectKey := "key"

	notifier := gobrake.NewNotifier(projectID, projectKey)

	handler := airbrake.NewFromNotifier(notifier)
	defer handler.Close() // Make sure to close the handler to flush all error reporting in progress

}
Output:

func NewSync

func NewSync(projectID int64, projectKey string) *Handler

NewSync creates a new handler that sends errors synchronously.

Example
package main

import (
	"emperror.dev/handler/airbrake"
)

func main() {
	projectID := int64(1)
	projectKey := "key"

	handler := airbrake.NewSync(projectID, projectKey)
	defer handler.Close()

}
Output:

func NewSyncFromNotifier

func NewSyncFromNotifier(notifier *gobrake.Notifier) *Handler

NewSyncFromNotifier creates a new handler from a notifier instance that sends errors synchronously.

Example
package main

import (
	"github.com/airbrake/gobrake"

	"emperror.dev/handler/airbrake"
)

func main() {
	projectID := int64(1)
	projectKey := "key"

	notifier := gobrake.NewNotifier(projectID, projectKey)

	handler := airbrake.NewSyncFromNotifier(notifier)
	defer handler.Close()

}
Output:

func (*Handler) Close

func (h *Handler) Close() error

Close closes the underlying notifier and waits for asynchronous reports to finish.

func (*Handler) Handle

func (h *Handler) Handle(err error)

Handle sends the error to Airbrake/Errbit.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL