metrics

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package metrics is part of the Tarmac suite of Host Callback packages. This package provides users with the ability to provide WASM functions with a host callback interface that provides metrics tracking capabilities.

import (
	"github.com/madflojo/tarmac/pkg/callbacks"
	"github.com/madflojo/tarmac/pkg/callbacks/metrics"
)

func main() {
	// Create instance of metrics to register for callback execution
	metrics := metrics.New(metrics.Config{})

	// Create Callback router and register metrics
	router := callbacks.New()
	router.RegisterCallback("metrics", "Counter", metrics.Counter)
}

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidMetricName = fmt.Errorf("invalid metric name")

ErrInvalidMetricName is an error returned when the user supplies an invalid formatted metric name.

Functions

This section is empty.

Types

type Config

type Config struct{}

Config is provided to users to configure the Host Callback. All Tarmac Callbacks follow the same configuration format; each Config struct gives the specific Host Callback unique functionality.

type Metrics

type Metrics struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Metrics stores and manages the user-defined metrics created via WASM function callbacks.

func New

func New(cfg Config) (*Metrics, error)

New will create a new instance of metrics enabling users to collect custom metrics.

func (*Metrics) Counter

func (m *Metrics) Counter(b []byte) ([]byte, error)

Counter will create and increment a counter metric. The expected input for this function is a MetricsCounter JSON.

func (*Metrics) Gauge

func (m *Metrics) Gauge(b []byte) ([]byte, error)

Gauge will create a gauge metric and either increment or decrement the value based on the provided input. The expected input for this function is a MetricsGauge JSON.

func (*Metrics) Histogram

func (m *Metrics) Histogram(b []byte) ([]byte, error)

Histogram will create a histogram or summary metric and observe the provided values. The expected input for this function is a MetricsHistogram JSON.

Jump to

Keyboard shortcuts

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