serverboot

package
v0.0.0-...-00a90a8 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package serverboot collects the startup boilerplate shared by the long-running substrate server binaries (ateapi, atelet, ateom-gvisor): slog wiring, OTel tracer + meter providers, a Prometheus + /readyz HTTP surface, and a couple of small helpers for startup fail-fast.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fatal

func Fatal(ctx context.Context, msg string, err error)

Fatal logs msg + err and exits with status 1. For startup-time fail-fast where there's no recovery path.

func InitLogger

func InitLogger()

InitLogger sets the global slog logger to a JSON handler wrapped in contextlogging.NewHandler. Call once at process start.

func InitMetrics

func InitMetrics(ctx context.Context, serviceName string) (*sdkmetric.MeterProvider, error)

InitMetrics registers a global MeterProvider with both a Prometheus reader (exposed via StartMetricsServer's /metrics handler) and an OTLP periodic reader.

func InitTracing

func InitTracing(ctx context.Context, opts TracingOptions) (*sdktrace.TracerProvider, error)

InitTracing registers a global TracerProvider with the given options and the TraceContext text-map propagator.

func ShutdownProvider

func ShutdownProvider(name string, shutdown func(context.Context) error)

ShutdownProvider invokes the OTel provider's Shutdown and logs any error. Designed to be deferred from main():

defer serverboot.ShutdownProvider("TracerProvider", tp.Shutdown)

func StartMetricsServer

func StartMetricsServer(ctx context.Context, opts MetricsServerOptions)

StartMetricsServer runs an HTTP server exposing /metrics (Prometheus) and optionally /readyz. Blocks until http.ListenAndServe returns; designed to be `go`-launched.

Types

type MetricsServerOptions

type MetricsServerOptions struct {
	// Addr is the TCP listen address (e.g. ":9090").
	Addr string
	// EnableReadyz adds a /readyz handler that returns 200 OK. Some
	// binaries (ateapi) want it for Kubernetes readiness probes; others
	// (atelet) historically didn't surface one.
	EnableReadyz bool
}

MetricsServerOptions configures StartMetricsServer.

type TracingOptions

type TracingOptions struct {
	// ServiceName is required; populates resource.semconv ServiceName.
	ServiceName string
	// Sampler is required. ateapi typically uses ParentBased(AlwaysSample);
	// atelet/ateom-gvisor use ParentBased(NeverSample).
	Sampler sdktrace.Sampler
}

TracingOptions configures InitTracing.

Jump to

Keyboard shortcuts

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