Documentation ¶
Overview ¶
Package ocsentry provides OpenCensus instrumentation for Sentry.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ErrorHandler ¶
ErrorHandler is a handler for ErrorCatcher of github.com/swaggest/usecase.
func HTTPHandlerMiddleware ¶
HTTPHandlerMiddleware prepares request context without creating sentry trace span for trace span is to be created by OpenCensus instrumentation.
func WrapTracer ¶
WrapTracer creates a tracer that manages Sentry spans together with OpenCensus spans.
Example ¶
// Initialize Sentry. err := sentry.Init(sentry.ClientOptions{ Dsn: "https://abc123abc123abc123abc123@o123456.ingest.sentry.io/1234567", ServerName: "my-service", Release: "v1.2.3", }) if err != nil { log.Fatal(err) } defer func() { sentry.Flush(time.Second) }() // Setup OC sampling. trace.ApplyConfig(trace.Config{ DefaultSampler: trace.ProbabilitySampler(0.01), }) // Enable Sentry wrapper. trace.DefaultTracer = ocsentry.WrapTracer(trace.DefaultTracer) var h http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { _, err := w.Write([]byte("Hello, world!")) if err != nil { log.Print(err) return } }) // Apply OpenCensus middleware and Sentry middlewares to your http.Handler. h = ocsentry.HTTPHandlerMiddleware(h) h = &ochttp.Handler{Handler: h} if err := http.ListenAndServe(":80", h); err != nil { log.Print(err) return }
Output:
Types ¶
type Option ¶ added in v0.1.1
type Option func(o *Options)
Option is a functional option.
func SkipTransactionNames ¶ added in v0.1.1
SkipTransactionNames is an option to skip transactions with provided names from sentry collection.
Can be useful to filter out automated requests that do not bring value, e.g. "GET /health", "GET /metrics".
Click to show internal directories.
Click to hide internal directories.