gostats

package module
v0.0.0-...-69a3232 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2023 License: MIT Imports: 4 Imported by: 0

README

Intro

gostats is a simple, self contained package that collects runtime statistics from runtime.MemStats and sends them over UDP to statsd as a set of gauges.

Usage

You need graphite and statsd running in your preferred way, for example using Docker:

docker pull graphiteapp/graphite-statsd
docker run -p 8080:80 -p 8125:8125/udp --rm --name statsd graphiteapp/graphite-statsd

Then simply, collect the data:

package main

import (
	"fmt"
	"github.com/shjala/gostats"
)

func main() {
  // Endpoint is statsd endpoint address
  var Endpoint = "localhost:2125"

  // Tag is bucket tag
  var Tag = "your_tag"

  // collect stats every 5 seconds
  err := gostats.Collect(Endpoint, Tag, 5, true, true, true)
  if err != nil {
    fmt.Printf("Failed to start collecting runtime stats : %v\n", err)
    return
  }

  // Rest of the code
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Endpoint = "localhost:8125"

Statsd host:port pair

Functions

func Collect

func Collect(endpoint string, prefix string, pauseDuration int, cpu bool, mem bool, gc bool) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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