metrics

package
v0.0.0-...-7a25296 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Configuration

type Configuration struct {
	Node             string `yaml:"-" json:"-"`
	ReportingFreqSec int    `yaml:"reporting_freq_sec" json:"reporting_freq_sec" usage:"指标导出的频率。默认值为60秒."`
	Namespace        string `yaml:"namespace" json:"namespace" usage:"Prometheus metrics的命名空间.它将始终在节点名称之前加上前缀."`
	PrometheusPort   int    `yaml:"prometheus_port" json:"prometheus_port" usage:"指示的http服务端口,如果是0将禁用s."`
	Prefix           string `yaml:"prefix" json:"prefix" usage:"指标名称的前缀. 默认是'linna', 可以为空."`
	CustomPrefix     string `yaml:"custom_prefix" json:"custom_prefix" usage:"用户指定指标名称的前缀. 默认是'linna', 可以为空."`
	ReadTimeoutMs    int    `yaml:"http_read_timeout_ms" json:"http_read_timeout_ms" usage:"http读取超时,默认 10000 ms"`
	WriteTimeoutMs   int    `yaml:"http_write_timeout_ms" json:"http_write_timeout_ms" usage:"http写入超时,默认 10000 ms"`
	IdleTimeoutMs    int    `` /* 149-byte string literal not displayed */
	APIPrefix        string `yaml:"api_prefix" json:"api_prefix" usage:"api 接口前缀', 可以为空."`
}

Configuration 日志配置信息

func NewConfiguration

func NewConfiguration() Configuration

NewConfiguration creates a new MatricsConfig struct.

type LocalMetrics

type LocalMetrics struct {
	PrometheusScope tally.Scope
	// contains filtered or unexported fields
}

func NewLocalMetrics

func NewLocalMetrics(logger, startupLogger *zap.Logger, db *sql.DB, config Configuration) *LocalMetrics

func (*LocalMetrics) Api

func (m *LocalMetrics) Api(name string, elapsed time.Duration, recvBytes, sentBytes int64, isErr bool)

func (*LocalMetrics) ApiAfter

func (m *LocalMetrics) ApiAfter(name string, elapsed time.Duration, isErr bool)

func (*LocalMetrics) ApiBefore

func (m *LocalMetrics) ApiBefore(name string, elapsed time.Duration, isErr bool)

func (*LocalMetrics) ApiRpc

func (m *LocalMetrics) ApiRpc(id string, elapsed time.Duration, recvBytes, sentBytes int64, isErr bool)

func (*LocalMetrics) CountDroppedEvents

func (m *LocalMetrics) CountDroppedEvents(delta int64)

Increment the number of dropped events.

func (*LocalMetrics) CountWebsocketClosed

func (m *LocalMetrics) CountWebsocketClosed(delta int64)

Increment the number of closed WS connections.

func (*LocalMetrics) CountWebsocketOpened

func (m *LocalMetrics) CountWebsocketOpened(delta int64)

Increment the number of opened WS connections.

func (*LocalMetrics) CustomCounter

func (m *LocalMetrics) CustomCounter(name string, tags map[string]string, delta int64)

CustomCounter adds the given delta to a counter with the specified name and tags.

func (*LocalMetrics) CustomGauge

func (m *LocalMetrics) CustomGauge(name string, tags map[string]string, value float64)

CustomGauge sets the given value to a gauge with the specified name and tags.

func (*LocalMetrics) CustomTimer

func (m *LocalMetrics) CustomTimer(name string, tags map[string]string, value time.Duration)

CustomTimer records the given value to a timer with the specified name and tags.

func (*LocalMetrics) GaugeAuthoritativeMatches

func (m *LocalMetrics) GaugeAuthoritativeMatches(value float64)

Set the absolute value of currently running authoritative matches.

func (*LocalMetrics) GaugeJsRuntimes

func (m *LocalMetrics) GaugeJsRuntimes(value float64)

Set the absolute value of currently allocated JavaScript runtime VMs.

func (*LocalMetrics) GaugeLuaRuntimes

func (m *LocalMetrics) GaugeLuaRuntimes(value float64)

Set the absolute value of currently allocated Lua runtime VMs.

func (*LocalMetrics) GaugePresences

func (m *LocalMetrics) GaugePresences(value float64)

Set the absolute value of currently tracked presences.

func (*LocalMetrics) GaugeRuntimes

func (m *LocalMetrics) GaugeRuntimes(value float64)

Set the absolute value of currently allocated Lua runtime VMs.

func (*LocalMetrics) GaugeSessions

func (m *LocalMetrics) GaugeSessions(value float64)

Set the absolute value of currently active sessions.

func (*LocalMetrics) Message

func (m *LocalMetrics) Message(recvBytes int64, isErr bool)

func (*LocalMetrics) MessageBytesSent

func (m *LocalMetrics) MessageBytesSent(sentBytes int64)

func (*LocalMetrics) PresenceEvent

func (m *LocalMetrics) PresenceEvent(dequeueElapsed, processElapsed time.Duration)

Count presence events and time their processing.

func (*LocalMetrics) SnapshotLatencyMs

func (m *LocalMetrics) SnapshotLatencyMs() float64

func (*LocalMetrics) SnapshotRateSec

func (m *LocalMetrics) SnapshotRateSec() float64

func (*LocalMetrics) SnapshotRecvKbSec

func (m *LocalMetrics) SnapshotRecvKbSec() float64

func (*LocalMetrics) SnapshotSentKbSec

func (m *LocalMetrics) SnapshotSentKbSec() float64

func (*LocalMetrics) Stop

func (m *LocalMetrics) Stop(logger *zap.Logger)

type Metrics

type Metrics interface {
	Stop(logger *zap.Logger)

	SnapshotLatencyMs() float64
	SnapshotRateSec() float64
	SnapshotRecvKbSec() float64
	SnapshotSentKbSec() float64

	Api(name string, elapsed time.Duration, recvBytes, sentBytes int64, isErr bool)
	ApiRpc(id string, elapsed time.Duration, recvBytes, sentBytes int64, isErr bool)
	ApiBefore(name string, elapsed time.Duration, isErr bool)
	ApiAfter(name string, elapsed time.Duration, isErr bool)

	Message(recvBytes int64, isErr bool)
	MessageBytesSent(sentBytes int64)

	GaugeRuntimes(value float64)
	GaugeLuaRuntimes(value float64)
	GaugeJsRuntimes(value float64)
	GaugeAuthoritativeMatches(value float64)
	CountDroppedEvents(delta int64)
	CountWebsocketOpened(delta int64)
	CountWebsocketClosed(delta int64)
	GaugeSessions(value float64)
	GaugePresences(value float64)

	PresenceEvent(dequeueElapsed, processElapsed time.Duration)

	CustomCounter(name string, tags map[string]string, delta int64)
	CustomGauge(name string, tags map[string]string, value float64)
	CustomTimer(name string, tags map[string]string, value time.Duration)
}

type MetricsGrpcHandler

type MetricsGrpcHandler struct {
	MetricsFn func(name string, elapsed time.Duration, recvBytes, sentBytes int64, isErr bool)
}

func (*MetricsGrpcHandler) HandleConn

HandleConn processes the Conn stats.

func (*MetricsGrpcHandler) HandleRPC

func (m *MetricsGrpcHandler) HandleRPC(ctx context.Context, rs stats.RPCStats)

HandleRPC processes the RPC stats.

func (*MetricsGrpcHandler) TagConn

TagConn can attach some information to the given context. The returned context will be used for stats handling. For conn stats handling, the context used in HandleConn for this connection will be derived from the context returned. For RPC stats handling,

  • On server side, the context used in HandleRPC for all RPCs on this

connection will be derived from the context returned.

  • On client side, the context is not derived from the context returned.

func (*MetricsGrpcHandler) TagRPC

TagRPC can attach some information to the given context. The context used for the rest lifetime of the RPC will be derived from the returned context.

Jump to

Keyboard shortcuts

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