Documentation
¶
Overview ¶
Package emf implements the spec available here: https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Embedded_Metric_Format_Specification.html
Index ¶
- type Context
- func (c *Context) Dimension(key, value string) *Context
- func (c *Context) DimensionSet(dimensions ...Dimension) *Context
- func (c *Context) Metric(name string, value int) *Context
- func (c *Context) MetricAs(name string, value int, unit MetricUnit) *Context
- func (c *Context) MetricFloat(name string, value float64) *Context
- func (c *Context) MetricFloatAs(name string, value float64, unit MetricUnit) *Context
- func (c *Context) Namespace(namespace string) *Context
- type Dimension
- type DimensionSet
- type Logger
- func (l *Logger) Dimension(key, value string) *Logger
- func (l *Logger) DimensionSet(dimensions ...Dimension) *Logger
- func (l *Logger) Log()
- func (l *Logger) Metric(name string, value int) *Logger
- func (l *Logger) MetricAs(name string, value int, unit MetricUnit) *Logger
- func (l *Logger) MetricFloat(name string, value float64) *Logger
- func (l *Logger) MetricFloatAs(name string, value float64, unit MetricUnit) *Logger
- func (l *Logger) Metrics(m map[string]int) *Logger
- func (l *Logger) MetricsAs(m map[string]int, unit MetricUnit) *Logger
- func (l *Logger) MetricsFloat(m map[string]float64) *Logger
- func (l *Logger) MetricsFloatAs(m map[string]float64, unit MetricUnit) *Logger
- func (l *Logger) Namespace(namespace string) *Logger
- func (l *Logger) NewContext() *Context
- func (l *Logger) Property(key, value string) *Logger
- type LoggerOption
- type Metadata
- type MetricDefinition
- type MetricDirective
- type MetricUnit
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) DimensionSet ¶
DimensionSet adds multiple dimensions 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 ¶
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.
type Dimension ¶
type Dimension struct {
Key, Value string
}
Dimension helps builds DimensionSet.
func NewDimension ¶
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) DimensionSet ¶
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) MetricAs ¶
func (l *Logger) MetricAs(name string, value int, unit MetricUnit) *Logger
MetricAs puts int metric with MetricUnit on default context.
func (*Logger) MetricFloat ¶
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) 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 ¶
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) NewContext ¶
NewContext creates new context for given logger.
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 WithLogGroup ¶ added in v1.2.0
func WithLogGroup(logGroup string) LoggerOption
WithLogGroup sets the log group when ingesting metrics into Cloudwatch Logging Agent.
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"`
LogGroupName string `json:"LogGroupName,omitempty"`
}
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" )