echosentry

package module
v0.0.0-...-360e359 Latest Latest
Warning

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

Go to latest
Published: May 5, 2018 License: MIT Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

echosentry

GoDoc

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

Note: this support echo with the standard http engine (no fasthttp support yet)

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)
  • 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