Documentation ¶
Overview ¶
package rkmidmetrics provide options
Index ¶
- Constants
- func ClearAllMetrics()
- func GetServerMetricsSet(entryName string) *rkprom.MetricsSet
- type AfterCtx
- type BeforeCtx
- type BootConfig
- type Option
- func ToOptions(config *BootConfig, entryName, entryType string, reg *prometheus.Registry, ...) []Option
- func WithEntryNameAndType(entryName, entryType string) Option
- func WithIgnorePrefix(paths ...string) Option
- func WithLabelerType(l string) Option
- func WithMockOptionSet(mock OptionSetInterface) Option
- func WithRegisterer(registerer prometheus.Registerer) Option
- type OptionSetInterface
Constants ¶
const ( // LabelerTypeHttp type of labeler LabelerTypeHttp = "http" // LabelerTypeGrpc type of labeler LabelerTypeGrpc = "grpc" )
const ( // MetricsNameElapsedNano records RPC duration MetricsNameElapsedNano = "elapsedNano" // MetricsNameResCode records response code MetricsNameResCode = "resCode" )
Variables ¶
This section is empty.
Functions ¶
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 ¶
WithEntryNameAndType provide entry name and entry type.
func WithIgnorePrefix ¶
WithIgnorePrefix provide paths prefix that will ignore. Mainly used for swagger main page and RK TV entry.
func WithLabelerType ¶
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