Documentation
¶
Index ¶
- Constants
- func AppAttributes(app *types.AppEntry) []attribute.KeyValue
- func AppIdentityAttributes(app *types.AppEntry) []attribute.KeyValue
- func Enabled() bool
- func Meter() metric.Meter
- func MetricsEnabled() bool
- func PluginSpansEnabled() bool
- func RecordAppProxyBytes(ctx context.Context, bytesIn, bytesOut uint64, attrs ...attribute.KeyValue)
- func RecordAppRequest(ctx context.Context, method string, attrs ...attribute.KeyValue)
- func RecordAppResponse(ctx context.Context, status int, attrs ...attribute.KeyValue)
- func RecordContainerCall(ctx context.Context, kind, operation string, start time.Time, err error, ...)
- func RecordDBCall(ctx context.Context, dbSystem, invoker, operation string, start time.Time, ...)
- func RecordError(span trace.Span, err error)
- func RequestAttributes(r *http.Request) []attribute.KeyValue
- func SQLDriverName(driverName, dbSystem, invoker string) (string, error)
- func StartSpan(ctx context.Context, name string, attrs ...attribute.KeyValue) (context.Context, trace.Span)
- func Tracer() trace.Tracer
- func WrapServerHandler(handler http.Handler, opt ServerHandlerOption) http.Handler
- func WrapTransport(base http.RoundTripper) http.RoundTripper
- type Providers
- type ServerHandlerOption
Constants ¶
const ( DBSystemSQLite = "sqlite" DBSystemPostgres = "postgresql" )
Variables ¶
This section is empty.
Functions ¶
func AppAttributes ¶
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 ¶
AppIdentityAttributes returns the per-app identity attributes used on app traces and metrics.
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 ¶
RecordAppRequest records app-level request counters. It is a no-op when metrics are disabled.
func RecordAppResponse ¶
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 ¶
RecordError annotates a span with an error if err is non-nil. Safe with a nil span.
func RequestAttributes ¶
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 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 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().
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.