telemetry

package
v0.2.10 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Overview

Package telemetry connects the shared Go runtime to Sentry. Instrumentation is a no-op without a DSN and never depends on Sentry being reachable.

Index

Constants

View Source
const FlushTimeout = 2 * time.Second

Variables

This section is empty.

Functions

func Breadcrumb(ctx context.Context, category, message string, data map[string]any)

func Capture

func Capture(ctx context.Context, err error) *sentry.EventID

func Count

func Count(ctx context.Context, name string, n int64, opts ...MetricOption)

func Duration

func Duration(ctx context.Context, name string, elapsed time.Duration, opts ...MetricOption)

func Enabled

func Enabled() bool

func FinishSpan

func FinishSpan(span *sentry.Span, err error)

func Flush

func Flush() bool

func Gauge

func Gauge(ctx context.Context, name string, value float64, opts ...MetricOption)

func HTTP

func HTTP(surface string, next http.Handler) http.Handler

func NormalizeSQL

func NormalizeSQL(query string) string

NormalizeSQL preserves the query shape, never bind arguments or literals. This also handles SQL/Cypher comments and PostgreSQL dollar-quoted bodies.

func Observe

func Observe(ctx context.Context, name string, elapsed time.Duration, err error, attrs ...string)

Observe emits one domain outcome without copying an operation's input/body.

func Recording

func Recording(ctx context.Context) bool

func RecoverAndRepanic

func RecoverAndRepanic(ctx context.Context)

RecoverAndRepanic preserves the original crash behavior after delivery.

func RegisterCollector

func RegisterCollector(name string, collector func(context.Context)) func()

RegisterCollector installs cheap runtime gauges. A returned cleanup removes the collector when a pool, cache or queue consumer is stopped.

func SetRoute

func SetRoute(ctx context.Context, method, pattern string)

SetRoute accepts router templates, never a query string or a concrete ID.

func StartSpan

func StartSpan(ctx context.Context, operation, description string) (context.Context, *sentry.Span)

func Transport

func Transport(service string, base http.RoundTripper) http.RoundTripper

Transport instruments outbound calls without forwarding cookies, bodies, auth headers, query strings, or trace headers to unrelated external services.

Types

type LogHook

type LogHook struct{}

LogHook carries event context through zerolog's JSON writer without keeping a global map of requests or leaking one goroutine's scope into another.

func (LogHook) Run

func (LogHook) Run(event *zerolog.Event, _ zerolog.Level, _ string)

type LogWriter

type LogWriter struct{}

func (LogWriter) Write

func (w LogWriter) Write(data []byte) (int, error)

func (LogWriter) WriteLevel

func (LogWriter) WriteLevel(level zerolog.Level, data []byte) (int, error)

type MetricOption

type MetricOption struct {
	// contains filtered or unexported fields
}

func Attributes

func Attributes(values ...string) MetricOption

func WithUnit

func WithUnit(unit string) MetricOption

type Options

type Options struct {
	Config                   *config.Config
	Version, Commit, Service string
	// Transport is normally nil; tests use an in-memory transport.
	Transport sentry.Transport
}

type Runtime

type Runtime struct {
	// contains filtered or unexported fields
}

func Init

func Init(opts Options) (*Runtime, error)

func (*Runtime) Close

func (r *Runtime) Close()

type Task

type Task struct {
	Context context.Context
	// contains filtered or unexported fields
}

func StartTask

func StartTask(ctx context.Context, operation, name string, attrs ...string) (context.Context, *Task)

StartTask gives concurrent workers separate hubs, breadcrumbs and scopes.

func StartTaskWithTrace

func StartTaskWithTrace(ctx context.Context, operation, name string, carrier TraceCarrier, attrs ...string) (context.Context, *Task)

func (*Task) End

func (task *Task) End(outcome string, err error)

type TraceCarrier

type TraceCarrier struct {
	Trace   string `json:"trace"`
	Baggage string `json:"baggage"`
}

func Propagation

func Propagation(ctx context.Context) TraceCarrier

Jump to

Keyboard shortcuts

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