rkginmetrics

package
v1.2.6 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package rkginmetrics is a middleware for gin framework which record prometheus metrics for RPC

Index

Constants

View Source
const (
	// ElapsedNano records RPC duration
	ElapsedNano = "elapsedNano"
	// Errors records RPC error
	Errors = "errors"
	// ResCode records response code
	ResCode = "resCode"
)

Variables

View Source
var (
	// DefaultLabelKeys are default labels for prometheus metrics
	DefaultLabelKeys = []string{
		"entryName",
		"entryType",
		"realm",
		"region",
		"az",
		"domain",
		"instance",
		"appVersion",
		"appName",
		"restMethod",
		"restPath",
		"type",
		"resCode",
	}
)

Functions

func GetServerDurationMetrics

func GetServerDurationMetrics(ctx *gin.Context) prometheus.Observer

GetServerDurationMetrics server request elapsed metrics.

func GetServerErrorMetrics

func GetServerErrorMetrics(ctx *gin.Context) prometheus.Counter

GetServerErrorMetrics server error metrics.

func GetServerMetricsSet

func GetServerMetricsSet(ctx *gin.Context) *rkprom.MetricsSet

GetServerMetricsSet server metrics set.

func GetServerResCodeMetrics

func GetServerResCodeMetrics(ctx *gin.Context) prometheus.Counter

GetServerResCodeMetrics server response code metrics.

func Interceptor

func Interceptor(opts ...Option) gin.HandlerFunc

Interceptor create a new prometheus metrics interceptor with options.

func ListServerMetricsSets

func ListServerMetricsSets() []*rkprom.MetricsSet

ListServerMetricsSets list all server metrics set associate with GinEntry.

Types

type Option

type Option func(*optionSet)

Option options provided to Interceptor or optionsSet while creating

func WithEntryNameAndType

func WithEntryNameAndType(entryName, entryType string) Option

WithEntryNameAndType provide entry name and entry type.

func WithRegisterer

func WithRegisterer(registerer prometheus.Registerer) Option

WithRegisterer provide prometheus.Registerer.

Jump to

Keyboard shortcuts

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