olbermann

package module
v0.0.0-...-b6efc24 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2014 License: BSD-3-Clause Imports: 15 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

olbermann

a reporter written in go

GoDoc

Documentation

Overview

Package olbermann is a reporter. Give it a metrics struct with tags, and it will report those metrics for you.

Define a struct with tags "type" indicating what kind of data is there, and "report" requesting that a set of quantities be reported.

Example:

type ReportableMetric struct {
	Transactions   int64   `type:"counter" report:"iter,cum"`
	Faults         int64   `type:"counter" report:"cum,total"`
	ProcessingTime float64 `type:"latency" report:"w50,w90,c90,c99,c99.9"`
}

Then just send ReportableMetric objects or pointers down a channel, olbermann will take care of the rest.

Example

This is not a perfect example, because we can't rely on clocks to generate the right output. So we use a log.Logger that doesn't print times, and we don't use the iter or cum report types on large values in this example. Also, EWMA values take 10 samples to start reporting.

c := make(chan interface{}, 10)
r := &Reporter{C: c}
go r.Feed()
if err := r.Start(exampleValueSet{}, &DstatStyler{Period: time.Second, LinesBetweenHeaders: 0, Logger: log.New(os.Stdout, "example: ", 0)}); err != nil {
	return
}
defer r.Close()
gen(c)
close(c)
Output:
example: ----------- a ------------ ------------------ b ------------------
example:         iter        total |        ewma1          cum        total
example:         2.00            2 |         0.00         2.00            2
example:         1.00            4 |         0.00         2.00            4
example:         1.00            7 |         0.00         2.33            7
example:         0.50            9 |         0.00         2.25            9

Index

Examples

Constants

This section is empty.

Variables

View Source
var BasicDstatStyler = DstatStyler{Period: time.Second, LinesBetweenHeaders: 24, Logger: log.New(os.Stdout, "", log.LstdFlags)}

A Styler that produces good default output similar to dstat, to standard out, with timestamps, once per second, with headers every 24 lines.

Functions

This section is empty.

Types

type CsvStyler

type CsvStyler struct {
	Period time.Duration // How often to print
	Writer *bufio.Writer // A writer to print to
}

CsvStyler is a Styler that produces output in csv format.

type DstatStyler

type DstatStyler struct {
	Period              time.Duration // How often to print
	LinesBetweenHeaders int           // After how many lines to print header info
	Logger              *log.Logger   // A logger to print to
}

DstatStyler is a Styler that produces output similar to dstat.

type Reporter

type Reporter struct {
	C <-chan interface{}
	// contains filtered or unexported fields
}

A Reporter represents a central point to collect a metric stream.

Must create with C a channel of structs or pointers to structs defined with tags explaining the metrics to track and how to report them.

Can Start() multiple reporting goroutines off the same Reporter.

Must invoke Feed() on a goroutine to pull metrics off the stream.

Usage:

	type ReportableMetric struct {
		Ips int64   `type:"counter" report:"iter,cum"`
		Ups int64   `type:"counter" report:"iter,cum"`
		X   float64 `type:"counter" report:"total"`
	}

	{
		metricChannel := make(chan interface{}, 100)
		r := olbermann.Reporter{C: metricChannel}
		go r.Feed()
		if err := r.Start(ReportableMetric{}, &olbermann.BasicDstatStyler); err != nil {
			return
		}
             defer r.Close()
		for i := 0; i < 100; i++ {
			metricChannel <- &ReportableMetric{1000, 20, 0.5}
		}
	}

func (*Reporter) Close

func (r *Reporter) Close()

Close stops the reporter's internal goroutine.

func (*Reporter) Feed

func (r *Reporter) Feed()

Feed is a long-running function that consumes input to the reporter's channel until the channel is closed.

Should be done on a goroutine.

func (*Reporter) Start

func (r *Reporter) Start(sample interface{}, styler Styler) (err error)

Start creates a goroutine printing the Reporter's metrics according to the provided Styler.

You must call Close later.

Needs a sample object to initialize some state, the zero value for the metric will do.

Usage:

if err := r.Start(ReportableMetric{}, &BasicDstatStyler); err != nil {
	return
}
defer r.Close()

type Styler

type Styler interface {
	// contains filtered or unexported methods
}

A Styler describes how, when, and where to display results.

Current implementations:

  • CsvStyler
  • DstatStyler

Jump to

Keyboard shortcuts

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