telemetry

package
v0.17.1 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2026 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DBSystemSQLite   = "sqlite"
	DBSystemPostgres = "postgresql"
)

Variables

This section is empty.

Functions

func AppAttributes

func AppAttributes(app *types.AppEntry) []attribute.KeyValue

AppAttributes returns the immutable per-app attribute set. Cache the result on the App and reuse across requests; do not call this on the hot path.

func AppIdentityAttributes

func AppIdentityAttributes(app *types.AppEntry) []attribute.KeyValue

AppIdentityAttributes returns the per-app identity attributes used on app traces and metrics.

func Enabled

func Enabled() bool

Enabled reports whether telemetry is currently active.

func Meter

func Meter() metric.Meter

Meter returns the OpenRun meter (a no-op when telemetry is disabled).

func MetricsEnabled

func MetricsEnabled() bool

MetricsEnabled reports whether metric instrumentation is currently active.

func PluginSpansEnabled

func PluginSpansEnabled() bool

PluginSpansEnabled reports whether per-plugin-call spans should be created. Plugin spans can be expensive in apps with high plugin call counts, so they are gated independently of the master telemetry switch.

func RecordAppProxyBytes

func RecordAppProxyBytes(ctx context.Context, bytesIn, bytesOut uint64, attrs ...attribute.KeyValue)

RecordAppProxyBytes records app reverse-proxy byte counters. bytesIn is traffic received from the client, and bytesOut is traffic sent to the client.

func RecordAppRequest

func RecordAppRequest(ctx context.Context, method string, attrs ...attribute.KeyValue)

RecordAppRequest records app-level request counters. It is a no-op when metrics are disabled.

func RecordAppResponse

func RecordAppResponse(ctx context.Context, status int, attrs ...attribute.KeyValue)

RecordAppResponse records app-level HTTP status counters. It is a no-op when metrics are disabled.

func RecordContainerCall

func RecordContainerCall(ctx context.Context, kind, operation string, start time.Time, err error, extraAttrs ...attribute.KeyValue)

RecordContainerCall records the duration and outcome of a container manager call. It is a no-op when metrics are disabled.

func RecordDBCall

func RecordDBCall(ctx context.Context, dbSystem, invoker, operation string, start time.Time, err error)

RecordDBCall records the duration and outcome of a SQL driver call. It is a no-op when metrics are disabled.

func RecordError

func RecordError(span trace.Span, err error)

RecordError annotates a span with an error if err is non-nil. Safe with a nil span.

func RequestAttributes

func RequestAttributes(r *http.Request) []attribute.KeyValue

RequestAttributes returns per-request attributes that are safe to record. Notably, no client-supplied values (Host, URL path, query) are included here; those must be added by callers that have applied per-app redaction.

func SQLDriverName

func SQLDriverName(driverName, dbSystem, invoker string) (string, error)

func StartSpan

func StartSpan(ctx context.Context, name string, attrs ...attribute.KeyValue) (context.Context, trace.Span)

StartSpan starts a span with the given name and attributes. When telemetry is disabled it returns the input context and a no-op span.

func Tracer

func Tracer() trace.Tracer

Tracer returns the OpenRun tracer (a no-op when telemetry is disabled).

func WrapServerHandler

func WrapServerHandler(handler http.Handler, opt ServerHandlerOption) http.Handler

WrapServerHandler wraps an http.Handler with otelhttp instrumentation. When telemetry is disabled the handler is returned unchanged.

func WrapTransport

func WrapTransport(base http.RoundTripper) http.RoundTripper

WrapTransport wraps an outbound RoundTripper with otelhttp instrumentation, which propagates the active trace context to the upstream and records a client span.

Types

type Providers

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

Providers owns the lifecycle of the SDK providers. It is always returned non-nil from Setup so callers do not need to nil-check before Shutdown.

func Setup

func Setup(ctx context.Context, config *types.ServerConfig, logger *types.Logger) (*Providers, error)

Setup initializes OpenTelemetry providers based on the server config. It always returns a non-nil Providers value: when telemetry is disabled or when initialization fails, Shutdown becomes a no-op and the helper functions short-circuit through Enabled().

func (*Providers) Shutdown

func (p *Providers) Shutdown(ctx context.Context) error

Shutdown flushes and closes the SDK providers. It is safe to call on a disabled or partially-initialized Providers value.

type ServerHandlerOption

type ServerHandlerOption struct {
	// Operation is the otelhttp base operation name.
	Operation string
	// Public marks the listener as untrusted. When true, incoming
	// trace-context headers are NOT extracted, so external clients cannot
	// inject parent spans into our trace.
	Public bool
	// ExtraSkipPaths lists URL path prefixes that should never be traced. The
	// internal health endpoint is always skipped.
	ExtraSkipPaths []string
	// TraceOnlyPrefixes, when set, limits server-level instrumentation to URL
	// path prefixes owned by OpenRun itself. Public app traffic should rely on
	// app-level spans where per-app redaction/skip policy is available.
	TraceOnlyPrefixes []string
}

ServerHandlerOption configures WrapServerHandler.

Jump to

Keyboard shortcuts

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