raven

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2022 License: MIT Imports: 24 Imported by: 0

Documentation

Overview

  Forked from github.com/kisielk/raven-go at revision
  1833b9bb1f80ff05746875be4361b52a00c50952

	Package raven is a client and library for sending messages and exceptions to Sentry: http://getsentry.com

	Usage:

	Create a new client using the NewClient() function. The value for the DSN parameter can be obtained
	from the project page in the Sentry web interface. After the client has been created use the CaptureMessage
	method to send messages to the server.

		client, err := sentry.NewClient(dsn)
		...
		id, err := client.CaptureMessage("some text")

	If you want to have more finegrained control over the send event, you can create the event instance yourself

		client.Capture(&sentry.Event{Message: "Some Text", Logger:"auth"})

Index

Constants

View Source
const DefaultSentryDSN = "noop://user:password@localhost:0/0"

Default sentry DSN from https://github.com/getsentry/sentry-java/blob/af5196bd2a2531d4a3a74b51aeb64319c82c4ef6/sentry/src/main/java/io/sentry/dsn/Dsn.java#L20

Variables

This section is empty.

Functions

func AltDsn

func AltDsn(dsn string) interface{}

func CaptureErrors

func CaptureErrors(project, dsn string, comm <-chan glog.Event)

CaptureErrors sets the name of the project so that when events are sent to sentry they are tagged as coming from the given project. It then sets up the connection to sentry and begins to send any errors recieved over comm to sentry. It panics if a client could not be initialized.

func CaptureErrorsAltDsn

func CaptureErrorsAltDsn(project string, dsns []string, comm <-chan glog.Event)

CaptureErrorsAltDsn allows you to have errors sent to one of multiple dsn targes. It sets up a connection to sentry for each of the given dsn URIs.

To tag an event with a dsn:

glog.Error("bad thing happened", glog.Data(raven.AltDsn(YOUR_DSN)))

If the dsn of an event is not specified or is not equal to any of the dsns arg, the dsn target will be assumed to be the first dsn in the dsns list.

func Fingerprint

func Fingerprint(print ...string) interface{}

Fingerprint creates a Sentry fingerprint from a variadic set of strings. This fingerprint will be added to the outgoing event to allow for custom rollup. See: https://docs.sentry.io/learn/rollups/#customize-grouping-with-fingerprints

Types

type Client

type Client struct {
	URL       *url.URL
	PublicKey string
	SecretKey string
	Project   string

	Tags map[string]string
	// contains filtered or unexported fields
}

func NewClient

func NewClient(dsn string) (client *Client, err error)

NewClient creates a new client for a server identified by the given dsn A dsn is a string in the form:

{PROTOCOL}://{PUBLIC_KEY}:{SECRET_KEY}@{HOST}/{PATH}{PROJECT_ID}

eg:

http://abcd:efgh@sentry.example.com/sentry/project1

func (Client) Capture

func (client Client) Capture(ev *Event) error

Sends the given event to the sentry servers after encoding it into a byte slice.

func (Client) CaptureGlogEvent

func (client Client) CaptureGlogEvent(ev glog.Event)

func (Client) CaptureMessage

func (client Client) CaptureMessage(message ...string) (result string, err error)

CaptureMessage sends a message to the Sentry server. The resulting string is an event identifier.

func (Client) CaptureMessagef

func (client Client) CaptureMessagef(format string, a ...interface{}) (result string, err error)

CaptureMessagef is similar to CaptureMessage except it is using Printf like parameters for formatting the message

type Event

type Event struct {
	EventId     string                 `json:"event_id"`
	Project     string                 `json:"project"`
	Message     string                 `json:"message"`
	Timestamp   string                 `json:"timestamp"`
	Level       string                 `json:"level"`
	Logger      string                 `json:"logger"`
	ServerName  string                 `json:"server_name"`
	StackTrace  stacktrace.StackTrace  `json:"stacktrace"`
	Http        *Http                  `json:"request"`
	TargetDsn   string                 `json:"targetDsn"`
	Extra       map[string]interface{} `json:"extra"`
	Tags        map[string]string      `json:"tags"`
	Fingerprint []string               `json:"fingerprint,omitempty"`
}

func NewEvent

func NewEvent(req *http.Request, message string, depth int) *Event

type Http

type Http struct {
	Url         string            `json:"url"`
	Method      string            `json:"method"`
	Headers     map[string]string `json:"headers"`
	Cookies     string            `json:"cookies"`
	Data        interface{}       `json:"data"`
	QueryString string            `json:"query_string"`
}

func NewHttp

func NewHttp(req *http.Request) *Http

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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