emf

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2025 License: MIT Imports: 11 Imported by: 3

Documentation

Overview

Package emf helps with AWS Embedded Metric Format.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultUnixMilli

func DefaultUnixMilli() int64

DefaultUnixMilli is default function used when Options.UnixMilli is left undefined.

Types

type DimensionSet

type DimensionSet []string

DimensionSet defines EMF DimensionSet.

type Metadata

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

Metadata defines EMF Metadata.

type Metric

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

Metric holds full EMF metric context.

func New

func New(options Options) *Metric

New creates EMF metric.

func (*Metric) CloudWatchLogEvents

func (m *Metric) CloudWatchLogEvents() []types.InputLogEvent

CloudWatchLogEvents yields EMF metric as input for cloudwatch log events.

func (*Metric) CloudWatchString

func (m *Metric) CloudWatchString() string

CloudWatchString yields EMF metric as cloudwatch string for aws cli.

func (*Metric) Fprintln

func (m *Metric) Fprintln(w io.Writer)

Fprintln yields EMF metric to Writer.

func (*Metric) Println

func (m *Metric) Println()

Println yields EMF metric to stdout.

func (*Metric) Record

func (m *Metric) Record(namespace string, metric MetricDefinition, dimensions map[string]string, value int)

Record records a metric.

func (*Metric) Render

func (m *Metric) Render() []string

Render renders metrics as string.

func (*Metric) Reset

func (m *Metric) Reset()

Reset clears all defined metrics and dimensions. If in the previsou cycle you sent any metric what you won't update with Record() in the next cycle, use Reset() to clear all metrics before the next cycle. Otherwise those stale metrics will be sent again.

type MetricDefinition

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

MetricDefinition defines EMF MetricDefinition.

type MetricDirective

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

MetricDirective defines EMF MetricDirective.

type Options

type Options struct {
	UnixMilli func() int64
}

Options define options.

Jump to

Keyboard shortcuts

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