librato

package module
v10.0.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

README

codebeat badge

InstallationExamplesLicense


Package for working with Librato Metrics API from Go code.

Installation

Before the initial install allows git to use redirects for pkg.re service (reason why you should do this described here):

git config --global http.https://pkg.re.followRedirects true

Make sure you have a working Go 1.13+ workspace (instructions), then

go get pkg.re/essentialkaos/librato.v10

For update to latest stable release, do:

go get -u pkg.re/essentialkaos/librato.v10

Examples

License

Apache License, Version 2.0

Documentation

Overview

Package librato provides methods and structs for working with Librato Metrics API

Index

Constants

View Source
const VERSION = "10.0.1"

VERSION contains current version of librato package and used as part of User-Agent

Variables

View Source
var (
	Mail  = ""
	Token = ""
)

Access credentials

View Source
var APIEndpoint = "https://metrics-api.librato.com"

APIEndpoint contians URL of Librato API endpoint

View Source
var Engine = &req.Engine{}

Engine is global req.Engine which used for sync requests

View Source
var UseGlobalEngine = false

UseGlobalEngine set to true for using global engine for all requests

Functions

func AddAnnotation

func AddAnnotation(stream string, a Annotation) []error

AddAnnotation synchronously send annotation to librato

func AddMetric

func AddMetric(m ...Measurement) []error

AddMetric synchronously send metric to librato

func DeleteAnnotations

func DeleteAnnotations(stream string) []error

DeleteAnnotations synchronously remove annotation stream on librato

Types

type Annotation

type Annotation struct {

	// The title of an annotation is a string and may contain spaces. The title should
	// be a short, high-level summary of the annotation e.g. v45 Deployment. The title
	// is a required parameter to create an annotation.
	Title string `json:"title"`

	// A string which describes the originating source of an annotation when that
	// annotation is tracked across multiple members of a population.
	// Examples: foo3.bar.com, user-123, 77025.
	Source string `json:"source,omitempty"`

	// The description contains extra meta-data about a particular annotation. The
	// description should contain specifics on the individual annotation e.g.
	// Deployed 9b562b2: shipped new feature foo! A description is not required to
	// create an annotation.
	Desc string `json:"description,omitempty"`

	// An optional list of references to resources associated with the particular
	// annotation. For example, these links could point to a build page in a CI
	// system or a changeset description of an SCM. Each link has a tag that
	// defines the link\'s relationship to the annotation.
	Links []string `json:"links,omitempty"`

	// The unix timestamp indicating the the time at which the event referenced by this
	// annotation started. By default this is set to the current time if not specified.
	StartTime int64 `json:"start_time,omitempty"`

	// The unix timestamp indicating the the time at which the event referenced by
	// this annotation ended. For events that have a duration, this is a useful way
	// to annotate the duration of the event.
	EndTime int64 `json:"end_time,omitempty"`
}

Annotation struct

type Collector

type Collector struct {

	// Function executed if we have errors while sending data to Librato
	ErrorHandler func(errs []error)
	Engine       *req.Engine
	// contains filtered or unexported fields
}

Collector struct

func NewCollector

func NewCollector(period time.Duration, collectFunc func() []Measurement) *Collector

NewCollector create new metrics struct for async metrics collecting and sending

func (*Collector) Send

func (cl *Collector) Send() []error

Send sends metrics data to Librato service

type Counter

type Counter struct {
	// Each metric has a name that is unique to its class of metrics e.g. a gauge name
	// must be unique amongst gauges. The name identifies a metric in subsequent API
	// calls to store/query individual measurements and can be up to 255 characters
	// in length. Valid characters for metric names are 'A-Za-z0-9.:-_'. The metric
	// namespace is case insensitive.
	Name string `json:"name"`

	// The numeric value of an individual measurement. Multiple formats are
	// supported (e.g. integer, floating point, etc) but the value must be numeric.
	Value interface{} `json:"value"`

	// The epoch time at which an individual measurement occurred with a maximum
	// resolution of seconds.
	MeasureTime int64 `json:"measure_time,omitempty"`

	// Source is an optional property that can be used to subdivide a common
	// gauge/counter amongst multiple members of a population. For example
	// the number of requests/second serviced by an application could be broken
	// up amongst a group of server instances in a scale-out tier by setting
	// the hostname as the value of source.
	//
	// Source names can be up to 255 characters in length and must be composed
	// of the following 'A-Za-z0-9.:-_'. The word all is a reserved word and
	// cannot be used as a user source. The source namespace is case insensitive.
	Source string `json:"source,omitempty"`
}

Counter struct

func (Counter) Validate

func (c Counter) Validate() error

Validate validates gauge struct

type DataSource

type DataSource interface {
	Send() []error
	// contains filtered or unexported methods
}

DataSource is interface for diferent type of data source

type Gauge

type Gauge struct {

	// Each metric has a name that is unique to its class of metrics e.g. a gauge name
	// must be unique amongst gauges. The name identifies a metric in subsequent API
	// calls to store/query individual measurements and can be up to 255 characters
	// in length. Valid characters for metric names are 'A-Za-z0-9.:-_'. The metric
	// namespace is case insensitive.
	Name string `json:"name"`

	// The numeric value of an individual measurement. Multiple formats are
	// supported (e.g. integer, floating point, etc) but the value must be numeric.
	Value interface{} `json:"value"`

	// The epoch time at which an individual measurement occurred with a maximum
	// resolution of seconds.
	MeasureTime int64 `json:"measure_time,omitempty"`

	// Source is an optional property that can be used to subdivide a common
	// gauge/counter amongst multiple members of a population. For example
	// the number of requests/second serviced by an application could be broken
	// up amongst a group of server instances in a scale-out tier by setting
	// the hostname as the value of source.
	//
	// Source names can be up to 255 characters in length and must be composed
	// of the following 'A-Za-z0-9.:-_'. The word all is a reserved word and
	// cannot be used as a user source. The source namespace is case insensitive.
	Source string `json:"source,omitempty"`

	// Indicates the request corresponds to a multi-sample measurement. This is
	// useful if measurements are taken very frequently in a closed loop and the
	// metric value is only periodically reported. If count is set, then sum must
	// also be set in order to calculate an average value for the recorded metric
	// measurement. Additionally min, max, and sum_squares may also be set when
	// count is set. The value parameter should not be set if count is set.
	Count interface{} `json:"count,omitempty"`

	// If count was set, sum must be set to the summation of the individual
	// measurements. The combination of count and sum are used to calculate an
	// average value for the recorded metric measurement.
	Sum interface{} `json:"sum,omitempty"`

	// If count was set, min can be used to report the smallest individual
	// measurement amongst the averaged set.
	Min interface{} `json:"min,omitempty"`

	// If count was set, max can be used to report the largest individual
	// measurement amongst the averaged set.
	Max interface{} `json:"max,omitempty"`

	// If count was set, sum_squares report the summation of the squared
	// individual measurements. If sum_squares is set, a standard deviation
	// can be calculated for the recorded metric measurement.
	SumSquares interface{} `json:"sum_squares,omitempty"`
}

Gauge struct

func (Gauge) Validate

func (g Gauge) Validate() error

Validate validates gauge struct

type Measurement

type Measurement interface {
	Validate() error
}

Measurement is interface for different type of measurements

type Metrics

type Metrics struct {

	// Function executed if we have errors while sending data to Librato
	ErrorHandler func(errs []error)
	Engine       *req.Engine
	// contains filtered or unexported fields
}

Metrics struct

func NewMetrics

func NewMetrics(period time.Duration, maxQueueSize int) (*Metrics, error)

NewMetrics create new metrics struct for async metrics sending

func (*Metrics) Add

func (mt *Metrics) Add(m ...Measurement) error

Add adds gauge to sending queue

func (*Metrics) Send

func (mt *Metrics) Send() []error

Send sends metrics data to Librato service

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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