recovery

package
v0.6.13 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package recovery turns a panic in a request handler into an error for that request instead of a crashed process: gRPC and ws-proto calls get codes.Internal, HTTP requests 500. Every recovered panic is logged as an OpenTelemetry exception record (with its stack and the request's trace) and counted in backplane.panics{where}.

Index

Constants

View Source
const (
	GRPCPublic   = "grpc.public"
	GRPCInternal = "grpc.internal"
	WSProto      = "wsproto"
	HTTPPublic   = "http.public"
	HTTPPlatform = "http.platform"
)

Where a panic was recovered: the value of the metric's where attribute.

Variables

This section is empty.

Functions

func HTTP

func HTTP(log *xlog.Logger, where string, next http.Handler) http.Handler

HTTP recovers a panicking handler: the client gets 500 when nothing was written yet. http.ErrAbortHandler keeps its meaning (abort the response silently) and is re-raised for net/http.

func ServerOptions

func ServerOptions(log *xlog.Logger, where string) []grpc.ServerOption

ServerOptions installs Unary and Stream first in the server's chain, so they also cover the interceptors that follow.

func Stream

func Stream(log *xlog.Logger, where string) grpc.StreamServerInterceptor

Stream recovers a panicking stream handler into codes.Internal.

The directive below is read by contextcheck itself (callers are checked through this function), so nolintlint cannot see it used.

func Unary

func Unary(log *xlog.Logger, where string) grpc.UnaryServerInterceptor

Unary recovers a panicking unary handler (and the interceptors after this one) into codes.Internal.

Types

This section is empty.

Jump to

Keyboard shortcuts

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