units

package
v1.5.54 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package units provides a common spot for OTel units.

Units should follow the Unified Code for Units of Measure (UCUM).

  • Instruments for utilization metrics (that measure the fraction out of a total) are dimensionless and SHOULD use the default unit 1 (the unity).
  • 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}".
  • Instruments that measure an integer count of something SHOULD only use annotations with curly braces to give additional meaning without the leading default unit (1). For example, use "{packet}", "{error}", "{fault}", etc.
  • Instrument units other than 1 and those that use annotations SHOULD be specified using the UCUM case sensitive ("c/s") variant. For example, "Cel" for the unit with full name "degree Celsius".
  • Instruments SHOULD use non-prefixed units (i.e. "By" instead of "MiBy") unless there is good technical reason to not do so.
  • When instruments are measuring durations, seconds (i.e. "s") SHOULD be used.

Index

Constants

This section is empty.

Variables

View Source
var (
	Byte   = metric.WithUnit("By")
	Second = metric.WithUnit("s")
)

Various common units.

Buckets as suggested for request durations.

LargeBuckets is a 10x multiple of Buckets.

View Source
var VeryLargeBuckets metric.HistogramOption

VeryLargeBuckets is a 20x multiple Buckets.

Functions

func BucketBoundaries

func BucketBoundaries(start float64, count int) []float64

BucketBoundaries returns "count" bucket boundaries in the same pattern as the semconv suggested bucket boundaries.

func Count

func Count(singular string) metric.InstrumentOption

Count returns a metric.InstrumentOption for integer counts of something.

The passed string should be singular and not include braces.

Types

This section is empty.

Jump to

Keyboard shortcuts

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