ginfw

package
v0.0.0-...-9008a76 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// tags shared across all insights ?
	LabelInsApp string = "app"

	LabelInsMethod   string = "method"
	LabelInsPath     string = "path"
	LabelInsReqID    string = "reqid"
	LabelInsRemoteIP string = "ip"
	LabelInsStatus   string = "status"

	// MetDBConnError keeps track of the number of db conn. errors
	MetDBConnError string = "db.connerror"
	MetDBDuration  string = "db.duration"

	LabelMetDBAddress    string = "address"
	LabelMetDBDatasource string = "datasource"

	// Metric definitions for Redis
	MetRedisConnError string = "redis.connerror"

	LabelMetRedisPool    string = "pool"
	LabelMetRedisAddress string = "address"

	// Metric definitions for requests
	MetReqCount    string = "request.count"
	MetReqDuration string = "request.duration"
	MetReqTimeout  string = "request.timeout"
	MetReqSize     string = "request.size"

	// LogTime
	LabelLogTime     string = "reqtime"
	LabelLogDuration string = "duration"
	LabelLogSize     string = "size"
	LabelLogErrors   string = "errors"
)

Constants for configuration parameters related to logs / metrics / traces

Variables

This section is empty.

Functions

func ExtServices

func ExtServices(c *gin.Context) *extdeps.ExtServices

ExtServices returns the ExtServices instance stored in the gin.Context

func ExtServicesMiddleware

func ExtServicesMiddleware(es *extdeps.ExternalServices) gin.HandlerFunc

ExtServicesMiddleware creates a new ExternalServices (or external dependencies) for the incoming request, and stores it in the gin context

func ObsMiddleware

func ObsMiddleware() gin.HandlerFunc

ObsMiddleware creates a middlewware that attaches the ExternalServices instance and insighters instance with some fields already set, like the method and path for the request, the client ip for the logs, the request time as well as a unique request ID. It will also report the duration and size of the response.

func RecoveryWithObs

func RecoveryWithObs(ins *obs.Insighter) gin.HandlerFunc

RecoveryWithObs returns a middleware for a given writer that recovers from any panics and writes a 500 if there was one.

Types

This section is empty.

Directories

Path Synopsis
web

Jump to

Keyboard shortcuts

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