metrics

package
v0.0.0-...-6442e4a Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

README

metrics

metrics为监控服务提供了统一的调用接口,主要包括counter,gauge,summary.而且为一些流行的metrics服务提供了适配器.

usage

install:

go get -v -u github.com/Schneizelw/mtggokit/metrics/metrics

counter usage:

#path: /project/conf/counter.yaml
Open:
    Log: true
    Prometheus: false
    Elasticsearch: true
MonitorSystem:
    Default:
        Namespace: "Test"
        Subsystem: "testCount"
        Help: "just a test"
        Name: "test"
    Elasticsearch:
        Host: "xxxxx.com"
        Port: "8000"
        Index: "metric"
        Type: "metric_test"
        Interval: "10" #时间间隔
    Log:
        LogPath : "./.metricsLog"
        Interval: "10"
import (
    "time"
    "github.com/Schneizelw/mtggokit/metrics"
)
func main() {
    var logger *log.Logger
    var counter metrics.Counter
    lables := []string{"httpCode", "httpMethod"}
    counter = multi.NewCounter("/project/conf/counter.yaml", lables)
    counter.With({"httpCode":"200","httpMethod":"POST"}).Add(1)
    counter.With({"httpCode":"200","httpMethod":"GET"}).Add(2)
    counter.With({"httpCode":"200","httpMethod":"POST"}).Add(3)
    time.Sleep(1000*time.Second)
}

summary usage:

#path: /project/conf/summary.yaml
Open:
    Log: true
    Prometheus: false
    Elasticsearch: false
MonitorSystem:
    Default:
        Namespace: "summary"
        Subsystem: "summary test"
        Help: "just a test"
        Name: "test"
Metrics:
    Summary:
        Quantile50: 5 #对应分位数的误差
        Quantile90: 2 
        Quantile99: 1 
import (
    "time"
    "github.com/Schneizelw/mtggokit/metrics"
)
func main() {
    lables := []string{"score"}
    summaries := metrics.NewSummary("/project/conf/summary.yaml", lables)
    summaries.With("score","math").Observe(100)
    summaries.With("score","math").Observe(98)
    summaries.With("score","math").Observe(30)
    summaries.With("score","computer").Observe(30)
    summaries.With("score","computer").Observe(300)
    summaries.With("score","computer").Observe(200)
    time.Sleep(1000*time.Second)
}

Documentation

Overview

Package multi provides adapters that send observations to multiple metrics simultaneously. This is useful if your service needs to emit to multiple instrumentation systems at the same time, for example if your organization is transitioning from one system to another.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Counter

type Counter []metrics.Counter

Counter collects multiple individual counters and treats them as a unit.

func NewCounter

func NewCounter(fileName string, lables []string) Counter

NewCounter returns a multi-counter, wrapping the passed counters.

func (Counter) Add

func (c Counter) Add(delta float64)

Add implements counter.

func (Counter) With

func (c Counter) With(labelValues ...string) metrics.Counter

With implements counter.

type Gauge

type Gauge []metrics.Gauge

Gauge collects multiple individual gauges and treats them as a unit.

func NewGauge

func NewGauge(fileName string, lables []string) Gauge

NewGauge returns a multi-gauge, wrapping the passed gauges.

func (Gauge) Add

func (g Gauge) Add(delta float64)

Add implements metrics.Gauge.

func (Gauge) Set

func (g Gauge) Set(value float64)

Set implements Gauge.

func (Gauge) With

func (g Gauge) With(labelValues ...string) metrics.Gauge

With implements gauge.

type Summary

type Summary []metrics.Histogram

Summary collects multiple individual summaries and treats them as a unit.

func NewSummary

func NewSummary(fileName string, lables []string) Summary

NewSummary returns a multi-summary, wrapping the passed summary.

func (Summary) Observe

func (s Summary) Observe(value float64)

Observe implements Histogram.

func (Summary) With

func (s Summary) With(labelValues ...string) metrics.Histogram

With implements histogram.

Directories

Path Synopsis
Package elasticsearch provides Prometheus implementations for metrics.
Package elasticsearch provides Prometheus implementations for metrics.
client_golang/elasticsearch
Package elasticsearch is the core instrumentation package.
Package elasticsearch is the core instrumentation package.
common/expfmt
Package expfmt contains tools for reading and writing Prometheus metrics.
Package expfmt contains tools for reading and writing Prometheus metrics.
common/model
Package model contains common data structures that are shared across Prometheus components and libraries.
Package model contains common data structures that are shared across Prometheus components and libraries.
common/promlog
Package promlog defines standardised ways to initialize Go kit loggers across Prometheus components.
Package promlog defines standardised ways to initialize Go kit loggers across Prometheus components.
procfs Module
internal
lv
Package metricslog provides Prometheus implementations for metrics.
Package metricslog provides Prometheus implementations for metrics.
client_golang/metricslog
Package metricslog is the core instrumentation package.
Package metricslog is the core instrumentation package.
common/expfmt
Package expfmt contains tools for reading and writing Prometheus metrics.
Package expfmt contains tools for reading and writing Prometheus metrics.
common/model
Package model contains common data structures that are shared across Prometheus components and libraries.
Package model contains common data structures that are shared across Prometheus components and libraries.
common/promlog
Package promlog defines standardised ways to initialize Go kit loggers across Prometheus components.
Package promlog defines standardised ways to initialize Go kit loggers across Prometheus components.
procfs
Package procfs provides functions to retrieve system, kernel and process metrics from the pseudo-filesystem proc.
Package procfs provides functions to retrieve system, kernel and process metrics from the pseudo-filesystem proc.
procfs/bcache
Package bcache provides access to statistics exposed by the bcache (Linux block cache).
Package bcache provides access to statistics exposed by the bcache (Linux block cache).
procfs/nfs
Package nfs implements parsing of /proc/net/rpc/nfsd.
Package nfs implements parsing of /proc/net/rpc/nfsd.
procfs/sysfs
Package sysfs provides functions to retrieve system and kernel metrics from the pseudo-filesystem sys.
Package sysfs provides functions to retrieve system and kernel metrics from the pseudo-filesystem sys.
procfs/xfs
Package xfs provides access to statistics exposed by the XFS filesystem.
Package xfs provides access to statistics exposed by the XFS filesystem.
Package prometheus provides Prometheus implementations for metrics.
Package prometheus provides Prometheus implementations for metrics.

Jump to

Keyboard shortcuts

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