Version: v0.0.2 Latest Latest

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

Go to latest
Published: Sep 26, 2016 License: MPL-2.0 Imports: 8 Imported by: 0


pulse logo
Build Status


Pulse is a stat collecting and publishing service. It serves historical stats over an http api while live stats are sent to mist for live updates.

Client Example:

package main

import (

  // if we want to see pulse client logs

  pulse ""

// address of pulse server
var address = ""

func main() {
  // because we want to see all pulse client logs

  // returns system command getter for cpu-used
  var cpuGetter = func() float64 {
    raw, err := exec.Command("bash", "-c", "cat /proc/stat | awk '/cpu / {usage=($2+$4)/($2+$4+$5)} END {print usage}' | tr -d '\n'").Output()
    if err != nil {
      return -1
    floatData, _ := strconv.ParseFloat(string(raw), 64)
    return floatData

  // returns golang func for mock ram-used
  var ramGetter = rand.Float64

  // register a new client
  relay, err := pulse.NewRelay(address, "lester.tester")
  if err != nil {
    fmt.Printf("Unable to connect to pulse server %v\n", err)
  defer relay.Close()

  // add new cpu collector for a container
  cpuCollector := pulse.NewPointCollector(cpuGetter)
  if err := relay.AddCollector("cpu_used", []string{"","service:web1"}, cpuCollector); err != nil {

  // a ram collector for the host
  ramCollector := pulse.NewPointCollector(ramGetter)
  if err := relay.AddCollector("ram_used", nil, ramCollector); err != nil {

  // keep it running for a while
  time.Sleep(time.Minute * 30)

open source



Package provides the client the ability to connect to pulse and add metrics/stats to be collected.



This section is empty.


View Source
var (
	UnableToIdentify   = errors.New("unable to identify with pulse")
	ReservedName       = errors.New("cannot use - or : or , or _connected in your name")
	DuplicateCollector = errors.New("cannot add a duplicate collector to the set")


This section is empty.


type Collector

type Collector interface {
	Collect() map[string]float64

Collector is a stat to be collected

func NewPointCollector

func NewPointCollector(pf func() float64) Collector

func NewSetCollector

func NewSetCollector(sf collectorHandle) Collector

type Relay

type Relay struct {
	// contains filtered or unexported fields

Relay is a pulse client

func NewRelay

func NewRelay(address, id string) (*Relay, error)

NewRelay creates a new relay

func (*Relay) AddCollector

func (relay *Relay) AddCollector(name string, tags []string, collector Collector) error

AddCollector adds a collector to relay

func (*Relay) Close

func (relay *Relay) Close() error

func (*Relay) Info

func (relay *Relay) Info() map[string]float64

func (*Relay) RemoveCollector

func (relay *Relay) RemoveCollector(name string)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL