emf

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2021 License: MIT Imports: 6 Imported by: 5

Documentation

Overview

Package emf implements the spec available here: https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Embedded_Metric_Format_Specification.html

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context struct {
	// contains filtered or unexported fields
}

Context gives ability to add another MetricDirective section for Logger.

func (*Context) Dimension

func (c *Context) Dimension(key, value string) *Context

Dimension adds single dimension on given context.

func (*Context) DimensionSet

func (c *Context) DimensionSet(dimensions ...Dimension) *Context

DimensionSet adds multiple dimensions on given context.

func (*Context) Metric

func (c *Context) Metric(name string, value int) *Context

Metric puts int metric on given context.

func (*Context) MetricAs

func (c *Context) MetricAs(name string, value int, unit MetricUnit) *Context

MetricAs puts int metric with MetricUnit on given context.

func (*Context) MetricFloat

func (c *Context) MetricFloat(name string, value float64) *Context

MetricFloat puts float metric on given context.

func (*Context) MetricFloatAs

func (c *Context) MetricFloatAs(name string, value float64, unit MetricUnit) *Context

MetricFloatAs puts float metric with MetricUnit on given context.

func (*Context) Namespace

func (c *Context) Namespace(namespace string) *Context

Namespace sets namespace on given context.

type Dimension

type Dimension struct {
	Key, Value string
}

Dimension helps builds DimensionSet.

func NewDimension

func NewDimension(key, value string) Dimension

NewDimension creates Dimension from key/value pair.

type DimensionSet

type DimensionSet []string

DimensionSet as defined in AWS Embedded Metrics Format spec.

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

Logger for metrics with default Context.

func New

func New(opts ...LoggerOption) *Logger

New creates logger with reasonable defaults for Lambda functions: - Prints to os.Stdout. - Context based on Lambda environment variables. - Timestamp set to the time when New was called. Specify LoggerOptions to customize the logger.

func (*Logger) Dimension

func (l *Logger) Dimension(key, value string) *Logger

Dimension adds single dimension on default context.

func (*Logger) DimensionSet

func (l *Logger) DimensionSet(dimensions ...Dimension) *Logger

DimensionSet adds multiple dimensions on default context.

func (*Logger) Log

func (l *Logger) Log()

Log prints all Contexts and metric values to chosen output in Embedded Metric Format.

func (*Logger) Metric

func (l *Logger) Metric(name string, value int) *Logger

Metric puts int metric on default context.

func (*Logger) MetricAs

func (l *Logger) MetricAs(name string, value int, unit MetricUnit) *Logger

MetricAs puts int metric with MetricUnit on default context.

func (*Logger) MetricFloat

func (l *Logger) MetricFloat(name string, value float64) *Logger

MetricFloat puts float metric on default context.

func (*Logger) MetricFloatAs

func (l *Logger) MetricFloatAs(name string, value float64, unit MetricUnit) *Logger

MetricFloatAs puts float metric with MetricUnit on default context.

func (*Logger) Metrics

func (l *Logger) Metrics(m map[string]int) *Logger

Metrics puts all of the int metrics on default context.

func (*Logger) MetricsAs

func (l *Logger) MetricsAs(m map[string]int, unit MetricUnit) *Logger

MetricsAs puts all of the int metrics with MetricUnit on default context.

func (*Logger) MetricsFloat

func (l *Logger) MetricsFloat(m map[string]float64) *Logger

MetricsFloat puts all of the float metrics on default context.

func (*Logger) MetricsFloatAs

func (l *Logger) MetricsFloatAs(m map[string]float64, unit MetricUnit) *Logger

MetricsFloatAs puts all of the float metrics with MetricUnit on default context.

func (*Logger) Namespace

func (l *Logger) Namespace(namespace string) *Logger

Namespace sets namespace on default context.

func (*Logger) NewContext

func (l *Logger) NewContext() *Context

NewContext creates new context for given logger.

func (*Logger) Property

func (l *Logger) Property(key, value string) *Logger

Property sets property.

type LoggerOption added in v1.0.0

type LoggerOption func(l *Logger)

LoggerOption defines a function that can be used to customize a logger.

func WithTimestamp added in v1.0.0

func WithTimestamp(t time.Time) LoggerOption

WithTimestamp customizes the timestamp used by a logger.

func WithWriter added in v1.0.0

func WithWriter(w io.Writer) LoggerOption

WithWriter customizes the writer used by a logger.

func WithoutDimensions added in v1.1.0

func WithoutDimensions() LoggerOption

WithoutDimensions ignores default AWS Lambda related properties and dimensions.

type Metadata

type Metadata struct {
	Timestamp int64             `json:"Timestamp"`
	Metrics   []MetricDirective `json:"CloudWatchMetrics"`
}

Metadata struct as defined in AWS Embedded Metrics Format spec.

type MetricDefinition

type MetricDefinition struct {
	Name string     `json:"Name"`
	Unit MetricUnit `json:"Unit,omitempty"`
}

MetricDefinition struct as defined in AWS Embedded Metrics Format spec.

type MetricDirective

type MetricDirective struct {
	Namespace  string             `json:"Namespace"`
	Dimensions []DimensionSet     `json:"Dimensions"`
	Metrics    []MetricDefinition `json:"Metrics"`
}

MetricDirective struct as defined in AWS Embedded Metrics Format spec.

type MetricUnit

type MetricUnit string
const (
	None            MetricUnit = "None"
	Seconds         MetricUnit = "Seconds"
	Microseconds    MetricUnit = "Microseconds"
	Milliseconds    MetricUnit = "Milliseconds"
	Bytes           MetricUnit = "Bytes"
	Kilobytes       MetricUnit = "Kilobytes"
	Megabytes       MetricUnit = "Megabytes"
	Gigabytes       MetricUnit = "Gigabytes"
	Terabytes       MetricUnit = "Terabytes"
	Bits            MetricUnit = "Bits"
	Kilobits        MetricUnit = "Kilobits"
	Megabits        MetricUnit = "Megabits"
	Gigabits        MetricUnit = "Gigabits"
	Terabits        MetricUnit = "Terabits"
	Percent         MetricUnit = "Percent"
	Count           MetricUnit = "Count"
	BytesSecond     MetricUnit = "Bytes/Second"
	KilobytesSecond MetricUnit = "Kilobytes/Second"
	MegabytesSecond MetricUnit = "Megabytes/Second"
	GigabytesSecond MetricUnit = "Gigabytes/Second"
	TerabytesSecond MetricUnit = "Terabytes/Second"
	BitsSecond      MetricUnit = "Bits/Second"
	KilobitsSecond  MetricUnit = "Kilobits/Second"
	MegabitsSecond  MetricUnit = "Megabits/Second"
	GigabitsSecond  MetricUnit = "Gigabits/Second"
	TerabitsSecond  MetricUnit = "Terabits/Second"
	CountSecond     MetricUnit = "Count/Second"
)

Jump to

Keyboard shortcuts

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