Categorygithub.com/cryptopay-dev/go-metrics
repositorypackage
0.0.0-20180322103407-b3db16ac5589
Repository: https://github.com/cryptopay-dev/go-metrics.git
Documentation: pkg.go.dev

# Packages

No description provided by the author

# README

Golang application metrics

NATS application metrics package

Build Status codecov GoDoc Go Report Card

Installation

go get github.com/cryptopay-dev/go-metrics

Default metrics tags

hostname - application host
app - application name

Metrics

    "alloc":         8810230, // memory allocated in bytes
    "alloc_objects": 123, // total heap objects allocated
    "gorotines":     10, // number of goroutines
    "gc":            1495532586, // timestamp of last GC
    "next_gc":       9000000, // heap size when GC will be run next time
    "pause_ns":      100 // pause time of GC

Usage

Basic

package main

import (
    "log"

    "github.com/cryptopay.dev/go-metrics"
)

func main() {
    err := metrics.Setup("nats://localhost:4222", "application_name", "hostname")
    if err != nil {
        log.Fatal(err)
    }

    for i:=0; i<10; i++ {
        // You metrics will be reported at application_name:metric
        // You metrics will be send to: mymetric,[email protected] counter=1,gauge=true,string=name
        // E.t.c.
        err = metrics.SendAndWait("metric", metrics.M{
            "counter": i,
            "gauge": true,
            "string": "name",
        }, metrics.T{
            "user": "[email protected]"
        }, "mymetric")

        if err != nil {
            log.Fatal(err)
        }
    }
}

More stuff

You can find more examples in /examples folder