echosentry

package module
v0.0.0-...-ecc55b5 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2017 License: MIT Imports: 6 Imported by: 0

README

echosentry

GoDoc

A sentry (raven-go) middleware for echo micro web framework.

Usage

echosentry.SetDSN("https://<key>:<secret>@app.getsentry.com/<project>")
e.Use(echosentry.Middleware())

By default, the middleware logs the HTTP context and sends it along with the stacktrace, this adds info about the user's browser, URL, OS, device, interface_type ..etc.

You can disable HTTP context as follow:

echosentry.WithContext(false)

Additional tags

You can append additional tags to be captured by Sentry. Tags content can be extracted from the current request context or just static tags, e.g. tags["app_version"] = appVersion.

echosentry.SetTags(func(c *echo.Context) map[string]string {
    return map[string]string{
        "endpoint":       c.Request().URL.String(),
        "http_interface": c.Request().Proto,
        "app_version":    appVersion,
    }
})

TODO

  • Log the user info (user context), currently raven-go has an issue with that...
  • Expose more options

License

MIT License. A copy is included with the source.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Middleware

func Middleware() echo.MiddlewareFunc

Middleware returns an echo middleware which recovers from panics anywhere in the chain and logs to the sentry server specified in DSN.

func SetDSN

func SetDSN(dsn string)

SetDSN creates a raven client and sets its Sentry server DSN.

func SetTags

func SetTags(fn TagsFunc)

Sets any other additional tags to be captured by Sentry. Tags can be extracted from the current request context or just static tags, e.g. tags["app_version"] = appVersion.

func WithContext

func WithContext(yepnope bool)

WithContext sets weather or not the HTTP context is sent with the log. This adds info about the user's browser, URL, OS, device, interface_type ..etc

Types

type Sentry

type Sentry struct {
	RavenClient *raven.Client
	Tags        map[string]string
	// contains filtered or unexported fields
}

Sentry struct holding the raven client and some of its configs

type TagsFunc

type TagsFunc func(c echo.Context) map[string]string

TagsFunc given a request context, extract some additional tags and return them as map[string]string as required by the raven client.

Jump to

Keyboard shortcuts

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