units

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2026 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package units provides a set of predefined units that can be used in the custom metrics.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Unit

type Unit string

The unit should be defined using the appropriate [UCUM](https://ucum.org) case-sensitive code.

const (
	// Time
	Days         Unit = "d"
	Hours        Unit = "h"
	Minutes      Unit = "min"
	Seconds      Unit = "s"
	Milliseconds Unit = "ms"
	Microseconds Unit = "us"
	Nanoseconds  Unit = "ns"

	// Bytes
	Bytes     Unit = "By"
	Kibibytes Unit = "KiBy"
	Mebibytes Unit = "MiBy"
	Gibibytes Unit = "GiBy"
	Tebibytes Unit = "TiBy"
	Kilobytes Unit = "KBy"
	Megabytes Unit = "MBy"
	Gigabytes Unit = "GBy"
	Terabytes Unit = "TBy"

	// SI Units
	Meters  Unit = "m"
	Volts   Unit = "V"
	Amperes Unit = "A"
	Joules  Unit = "J"
	Watts   Unit = "W"
	Grams   Unit = "g"

	// Misc
	Celsius Unit = "Cel"
	Hertz   Unit = "Hz"
	Ratio   Unit = "1"
	Percent Unit = "%"
)

func GenerateUnit

func GenerateUnit(quantity string) Unit

GenerateUnit creates a new unit with the given quantity, wrapped in curly braces.

All non-units that use curly braces to annotate a quantity need to match the grammatical number of the quantity it represent. For example if measuring the number of individual requests to a process the unit would be {request}, not {requests}.

func (Unit) String

func (u Unit) String() string

Jump to

Keyboard shortcuts

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