observability

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2026 License: MIT Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LOG_SQL_ALL       = "all"
	LOG_SQL_NONE      = "none"
	LOG_SQL_STATEMENT = "statement"
)

Variables

This section is empty.

Functions

func AddRequestID

func AddRequestID(globalConfig *conf.GlobalConfiguration) func(next http.Handler) http.Handler

func ConfigureLogging

func ConfigureLogging(config *conf.LoggingConfig) error

func ConfigureMetrics

func ConfigureMetrics(ctx context.Context, mc *conf.MetricsConfig) error

func ConfigureProfiler

func ConfigureProfiler(ctx context.Context, pc *conf.ProfilerConfig) error

func ConfigureTracing

func ConfigureTracing(ctx context.Context, tc *conf.TracingConfig) error

ConfigureTracing sets up global tracing configuration for OpenTracing / OpenTelemetry. The context should be the global context. Cancelling this context will cancel tracing collection.

func Debug

func Debug(msg string, projectRef string, metadata map[string]interface{})

Debug logs a debug-level message

func Error

func Error(msg string, projectRef string, metadata map[string]interface{})

Error logs an error-level message

func GetLogEntry

func GetLogEntry(r *http.Request) *logEntry

func GetLogEntryFromContext

func GetLogEntryFromContext(ctx context.Context) *logEntry

func Info

func Info(msg string, projectRef string, metadata map[string]interface{})

Info logs an info-level message

func Log

func Log(entry LogEntry)

Log writes a structured JSON log entry to stdout

func LogEntrySetField

func LogEntrySetField(r *http.Request, key string, value interface{})

func LogEntrySetFields

func LogEntrySetFields(r *http.Request, fields logrus.Fields)

func Meter

func Meter(instrumentationName string, opts ...metric.MeterOption) metric.Meter

func NewLogEntry

func NewLogEntry(le *logrus.Entry) chimiddleware.LogEntry

NewLogEntry returns a new chimiddleware.LogEntry from a *logrus.Entry.

func NewStructuredLogger

func NewStructuredLogger(logger *logrus.Logger, config *conf.GlobalConfiguration) func(next http.Handler) http.Handler

func ObtainMetricCounter

func ObtainMetricCounter(name, desc string) metric.Int64Counter

func RequestTracing

func RequestTracing() func(http.Handler) http.Handler

RequestTracing returns an HTTP handler that traces all HTTP requests coming in. Supports Chi routers, so this should be one of the first middlewares on the router.

func SetLogEntryWithContext

func SetLogEntryWithContext(
	ctx context.Context,
	entry chimiddleware.LogEntry,
) context.Context

func Tracer

func Tracer(name string, opts ...trace.TracerOption) trace.Tracer

func WaitForCleanup

func WaitForCleanup(ctx context.Context)

WaitForCleanup waits until all observability long-running goroutines shut down cleanly or until the provided context signals done.

func Warn

func Warn(msg string, projectRef string, metadata map[string]interface{})

Warn logs a warn-level message

Types

type CustomFormatter

type CustomFormatter struct {
	logrus.JSONFormatter
}

func NewCustomFormatter

func NewCustomFormatter() *CustomFormatter

func (*CustomFormatter) Format

func (f *CustomFormatter) Format(entry *logrus.Entry) ([]byte, error)

type LogEntry

type LogEntry struct {
	Timestamp  string                 `json:"timestamp"`
	Level      string                 `json:"level"`
	Service    string                 `json:"service"`
	ProjectRef string                 `json:"project_ref,omitempty"`
	RequestID  string                 `json:"request_id,omitempty"`
	Message    string                 `json:"message"`
	DurationMs int64                  `json:"duration_ms,omitempty"`
	Method     string                 `json:"method,omitempty"`
	Path       string                 `json:"path,omitempty"`
	StatusCode int                    `json:"status_code,omitempty"`
	Metadata   map[string]interface{} `json:"metadata,omitempty"`
}

LogEntry represents a structured log entry

type ProfilerHandler

type ProfilerHandler struct{}

func (*ProfilerHandler) ServeHTTP

func (p *ProfilerHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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