trace

package
v2.5.8 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package trace provides Sentry-based user context management.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultBeforeBreadcrumb added in v2.4.0

func DefaultBeforeBreadcrumb(breadcrumb *sentry.Breadcrumb, hint *sentry.BreadcrumbHint) *sentry.Breadcrumb

Modify breadcrumbs through beforeBreadcrumb function.

func DefaultBeforeSend added in v2.4.0

func DefaultBeforeSend(event *sentry.Event, hint *sentry.EventHint) *sentry.Event

Modify event through beforeSend function.

func LogAndSentryCaptureException added in v2.4.0

func LogAndSentryCaptureException(ctx context.Context, err error)

LogAndSentryCaptureException logs the error and captures an exception with context and send to sentry if sentry is configured. It caputures the exception even if the context or sentry hub in the context is nil.

func LogAndSentryCaptureMessage added in v2.4.0

func LogAndSentryCaptureMessage(ctx context.Context, msg string)

LogAndSentryCaptureMessage logs the message and captures a message with context and send to sentry if sentry is configured. It captures the message without context even if the context or sentry hub in the context is nil.

func PropagateToGRPC added in v2.4.0

func PropagateToGRPC(ctx context.Context) context.Context

PropagateToGRPC propagates the Sentry tracing information to the outgoing gRPC request metadata. Refers to the following link for more information. https://docs.sentry.io/platforms/go/tracing/trace-propagation/custom-instrumentation/#step-2-inject-tracing-information-to-outgoing-requests

func PropagateToHTTP added in v2.4.0

func PropagateToHTTP(ctx context.Context, header http.Header) http.Header

PropagateToHTTP propagates the Sentry tracing information to the outgoing HTTP/1.X request header. Refers to the following link for more information. https://docs.sentry.io/platforms/go/tracing/trace-propagation/custom-instrumentation/#step-2-inject-tracing-information-to-outgoing-requests

func SentryCaptureException added in v2.4.0

func SentryCaptureException(ctx context.Context, err error)

SentryCaptureException captures an exception with context and send to sentry if sentry is configured. It caputures the exception even if the context or sentry hub in the context is nil. To capture an exception with a stack trace, include the top-level error. For supported libraries, see: https://pkg.go.dev/github.com/getsentry/sentry-go@v0.30.0#ExtractStacktrace

func SentryCaptureExceptionWithEcho added in v2.4.0

func SentryCaptureExceptionWithEcho(c echo.Context, err error)

SentryCaptureExceptionWithEcho captures an exception with echo context and send to sentry if sentry is configured. It caputures the exception even if the context or sentry hub in the context is nil. To capture an exception with a stack trace, include the top-level error. For supported libraries, see: https://pkg.go.dev/github.com/getsentry/sentry-go@v0.30.0#ExtractStacktrace

func SentryCaptureMessage added in v2.4.0

func SentryCaptureMessage(ctx context.Context, msg string)

SentryCaptureMessage captures a message with context and send to sentry if sentry is configured. It captures the message even if the context or sentry hub in the context is nil.

func SentryCaptureMessageWithEcho added in v2.4.0

func SentryCaptureMessageWithEcho(c echo.Context, msg string)

SentryCaptureMessageWithEcho captures a message with echo context and send to sentry. It captures the message even if the context or sentry hub in the context is nil.

func SetUser added in v2.5.8

func SetUser(ctx context.Context, user sentry.User) context.Context

SetUser sets user information into Sentry's Scope: User Effect Analysis. Returns the context with Hub attached for propagation.

Example:

ctx := trace.SetUser(c.Request().Context(), sentry.User{
    ID:        "12345",
    Email:     "user@example.com",
    IPAddress: c.RealIP(),
    Username:  "johndoe",
    Name:      "John Doe",
	Data:      map[string]string{"customerID":"1"}
})

func StartSpan added in v2.0.7

func StartSpan(c context.Context, operation string, spanOpts ...sentry.SpanOption) (context.Context, func())

StartSpan starts a span and returns context containing the span and a function to finish the corresponding span. Make sure to call the returned function to finish the span.

func StartSpanWithEcho added in v2.4.0

func StartSpanWithEcho(c echo.Context, operation string, spanOpts ...sentry.SpanOption) (context.Context, func())

StartSpanWithEcho starts a span and returns context containing the span and a function to finish the corresponding span. It also carries over the sentry hub from the echo context to child context. Make sure to call the returned function to finish the span.

Types

This section is empty.

Jump to

Keyboard shortcuts

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