telemetry

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2026 License: Apache-2.0 Imports: 18 Imported by: 4

Documentation

Index

Constants

View Source
const Name = "internal/telemetry"

Name is the instrumentation scope name for telemetry.

Variables

This section is empty.

Functions

func CaptureError

func CaptureError(ctx context.Context, err error)

CaptureError logs an error that occured in a request.

func Fatal

func Fatal(ctx context.Context, err error)

Fatal wraps CaptureError with log.Fatal.

func Middleware

func Middleware(name string) func(http.Handler) http.Handler

Middleware returns a middleware that instruments requests with telemetry.

func Open

func Open(driver, dsn string) (*sqlx.DB, error)

Open creates a new instrumented *sqlx.DB without pinging. It wraps otelsql.Open and sqlx.NewDb for full compatibility.

func Start

func Start(ctx context.Context, name string) (context.Context, trace.Span)

Start is a wrapper to tracer.Start and expvar.NewInt.

Calling the function adds a span to the current context. The name should be a symbol reference for the caller. For best results, combine the package, symbol and function into a name like `user.service.Login`.

func StartAuto

func StartAuto(ctx context.Context, symbol any) (context.Context, trace.Span)

StartAuto tries to fill the span name from the symbol.

It's intended to pass a function, or a type. The package name, type name, and function name are combined with `.` to delimit them. See tests under pkg/reflect for more information.

StartAuto uses reflection and may not work correctly under various conditions. If performance or build restrictions are impacting use, use `Start`.

func StartRequest

func StartRequest(r *http.Request, name string) (*http.Request, trace.Span)

StartRequest is an utility to take the http.Request and update it's context.

Types

type Monitor

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

Monitor adds expvar instrumentation over the telemetry API.

func NewMonitor

func NewMonitor() *Monitor

NewMonitor creates a new Monitor for telemetry tracking.

func (*Monitor) Enabled

func (m *Monitor) Enabled() bool

Enabled reports whether telemetry monitoring is enabled.

func (*Monitor) SetEnabled

func (m *Monitor) SetEnabled(enabled bool)

SetEnabled enables or disables telemetry monitoring.

func (*Monitor) Touch

func (m *Monitor) Touch(name string)

Touch increments the counter for a telemetry event name.

Jump to

Keyboard shortcuts

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