rkmidmetrics

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2022 License: Apache-2.0 Imports: 8 Imported by: 4

Documentation

Overview

package rkmidmetrics provide options

Index

Constants

View Source
const (
	// LabelerTypeHttp type of labeler
	LabelerTypeHttp = "http"
	// LabelerTypeGrpc type of labeler
	LabelerTypeGrpc = "grpc"
)
View Source
const (
	// MetricsNameElapsedNano records RPC duration
	MetricsNameElapsedNano = "elapsedNano"
	// MetricsNameResCode records response code
	MetricsNameResCode = "resCode"
)

Variables

This section is empty.

Functions

func ClearAllMetrics

func ClearAllMetrics()

Internal use only.

func GetServerMetricsSet

func GetServerMetricsSet(entryName string) *rkprom.MetricsSet

GetServerMetricsSet server metrics set.

Types

type AfterCtx

type AfterCtx struct {
	Input struct {
		ResCode string
	}
	Output struct{}
}

AfterCtx context for After() function

func NewAfterCtx

func NewAfterCtx() *AfterCtx

NewAfterCtx create new AfterCtx with fields initialized

type BeforeCtx

type BeforeCtx struct {
	Input struct {
		RestMethod  string
		RestPath    string
		GrpcType    string
		GrpcMethod  string
		GrpcService string
	}
	Output struct {
		StartTime time.Time
	}
}

BeforeCtx context for Before() function

func NewBeforeCtx

func NewBeforeCtx() *BeforeCtx

NewBeforeCtx create new BeforeCtx with fields initialized

type BootConfig

type BootConfig struct {
	Enabled      bool     `yaml:"enabled" json:"enabled"`
	IgnorePrefix []string `yaml:"ignorePrefix" json:"ignorePrefix"`
}

BootConfig for YAML

type Option

type Option func(*optionSet)

Option options provided to Interceptor or optionsSet while creating

func ToOptions

func ToOptions(config *BootConfig,
	entryName, entryType string,
	reg *prometheus.Registry, labelerType string) []Option

ToOptions convert BootConfig into Option list

func WithEntryNameAndType

func WithEntryNameAndType(entryName, entryType string) Option

WithEntryNameAndType provide entry name and entry type.

func WithIgnorePrefix

func WithIgnorePrefix(paths ...string) Option

WithIgnorePrefix provide paths prefix that will ignore. Mainly used for swagger main page and RK TV entry.

func WithLabelerType

func WithLabelerType(l string) Option

WithLabelerType provide Labeler which will init metrics based on that

func WithMockOptionSet

func WithMockOptionSet(mock OptionSetInterface) Option

WithMockOptionSet provide mock OptionSetInterface

func WithRegisterer

func WithRegisterer(registerer prometheus.Registerer) Option

WithRegisterer provide prometheus.Registerer.

type OptionSetInterface

type OptionSetInterface interface {
	GetEntryName() string

	GetEntryType() string

	BeforeCtx(*http.Request) *BeforeCtx

	Before(*BeforeCtx)

	AfterCtx(string) *AfterCtx

	After(before *BeforeCtx, after *AfterCtx)
}

OptionSetInterface mainly for testing purpose

func NewOptionSet

func NewOptionSet(opts ...Option) OptionSetInterface

NewOptionSet Create new optionSet with options.

func NewOptionSetMock

func NewOptionSetMock(before *BeforeCtx, after *AfterCtx) OptionSetInterface

NewOptionSetMock for testing purpose

Jump to

Keyboard shortcuts

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