otelauto

package module
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

README

OTelAuto

ci Go Report Card Documentation

An OpenTelemetry (OTel) metric instrumentation helper inspired by prometheus promauto.

By default it's using the global meter provider.

Install

$ go get github.com/mahboubii/otelauto

Usage

This library implements all instrument types from the OpenTelemetry Meter interface.

package main

import (
  "context"

  "github.com/mahboubii/otelauto"
)

var counter = otelauto.Int64Counter("my.counter")

func main() {
  counter.Add(context.Background(), 1)
}

Alternatively, you can provide custom meters:


import (
  "context"

  "github.com/mahboubii/otelauto"
  "go.opentelemetry.io/otel/metric"
)

var counter = otelauto.With(metric.NewNoopMeter()).Int64Counter("my.counter")

func main() {
  counter.Add(context.Background(), 1)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Float64Counter

func Float64Counter(name string, opts ...metric.Float64CounterOption) metric.Float64Counter

Float64Counter returns a new instrument identified by name and configured with options. The instrument is used to synchronously record increasing float64 measurements during a computational operation.

func Float64Histogram

func Float64Histogram(name string, opts ...metric.Float64HistogramOption) metric.Float64Histogram

Float64Histogram returns a new instrument identified by name and configured with options. The instrument is used to synchronously record the distribution of float64 measurements during a computational operation.

func Float64ObservableCounter

func Float64ObservableCounter(name string, opts ...metric.Float64ObservableCounterOption) metric.Float64ObservableCounter

Float64ObservableCounter returns a new instrument identified by name and configured with options. The instrument is used to asynchronously record increasing float64 measurements once per a measurement collection cycle.

func Float64ObservableGauge

func Float64ObservableGauge(name string, opts ...metric.Float64ObservableGaugeOption) metric.Float64ObservableGauge

Float64ObservableGauge returns a new instrument identified by name and configured with options. The instrument is used to asynchronously record instantaneous float64 measurements once per a measurement collection cycle.

func Float64ObservableUpDownCounter

func Float64ObservableUpDownCounter(name string, opts ...metric.Float64ObservableUpDownCounterOption) metric.Float64ObservableUpDownCounter

Float64ObservableUpDownCounter returns a new instrument identified by name and configured with options. The instrument is used to asynchronously record float64 measurements once per a measurement collection cycle.

func Float64UpDownCounter

func Float64UpDownCounter(name string, opts ...metric.Float64UpDownCounterOption) metric.Float64UpDownCounter

Float64UpDownCounter returns a new instrument identified by name and configured with options. The instrument is used to synchronously record float64 measurements during a computational operation.

func Int64Counter

func Int64Counter(name string, opts ...metric.Int64CounterOption) metric.Int64Counter

Int64Counter returns a new instrument identified by name and configured with options. The instrument is used to synchronously record increasing int64 measurements during a computational operation.

func Int64Histogram

func Int64Histogram(name string, opts ...metric.Int64HistogramOption) metric.Int64Histogram

Int64Histogram returns a new instrument identified by name and configured with options. The instrument is used to synchronously record the distribution of int64 measurements during a computational operation.

func Int64ObservableCounter

func Int64ObservableCounter(name string, opts ...metric.Int64ObservableCounterOption) metric.Int64ObservableCounter

Int64ObservableCounter returns a new instrument identified by name and configured with options. The instrument is used to asynchronously record increasing int64 measurements once per a measurement collection cycle.

func Int64ObservableGauge

func Int64ObservableGauge(name string, opts ...metric.Int64ObservableGaugeOption) metric.Int64ObservableGauge

Int64ObservableGauge returns a new instrument identified by name and configured with options. The instrument is used to asynchronously record instantaneous int64 measurements once per a measurement collection cycle.

func Int64ObservableUpDownCounter

func Int64ObservableUpDownCounter(name string, opts ...metric.Int64ObservableUpDownCounterOption) metric.Int64ObservableUpDownCounter

Int64ObservableUpDownCounter returns a new instrument identified by name and configured with options. The instrument is used to asynchronously record int64 measurements once per a measurement collection cycle.

func Int64UpDownCounter

func Int64UpDownCounter(name string, opts ...metric.Int64UpDownCounterOption) metric.Int64UpDownCounter

Int64UpDownCounter returns a new instrument identified by name and configured with options. The instrument is used to synchronously record int64 measurements during a computational operation.

func RegisterCallback

func RegisterCallback(c metric.Callback, instruments ...metric.Observable) metric.Registration

RegisterCallback registers f to be called during the collection of a measurement cycle.

If Unregister of the returned Registration is called, f needs to be unregistered and not called during collection.

The instruments f is registered with are the only instruments that f may observe values for.

If no instruments are passed, f should not be registered nor called during collection.

Types

type Factory

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

func With

func With(mp metric.Meter) Factory

With creates a Factory using the provided Meter for registration of the created Collectors. If the provided Meter is nil, it will panic.

func (Factory) Float64Counter

func (f Factory) Float64Counter(name string, opts ...metric.Float64CounterOption) metric.Float64Counter

Float64Counter returns a new instrument identified by name and configured with options. The instrument is used to synchronously record increasing float64 measurements during a computational operation.

func (Factory) Float64Histogram

func (f Factory) Float64Histogram(name string, opts ...metric.Float64HistogramOption) metric.Float64Histogram

Float64Histogram returns a new instrument identified by name and configured with options. The instrument is used to synchronously record the distribution of float64 measurements during a computational operation.

func (Factory) Float64ObservableCounter

func (f Factory) Float64ObservableCounter(name string, opts ...metric.Float64ObservableCounterOption) metric.Float64ObservableCounter

Float64ObservableCounter returns a new instrument identified by name and configured with options. The instrument is used to asynchronously record increasing float64 measurements once per a measurement collection cycle.

func (Factory) Float64ObservableGauge

func (f Factory) Float64ObservableGauge(name string, opts ...metric.Float64ObservableGaugeOption) metric.Float64ObservableGauge

Float64ObservableGauge returns a new instrument identified by name and configured with options. The instrument is used to asynchronously record instantaneous float64 measurements once per a measurement collection cycle.

func (Factory) Float64ObservableUpDownCounter

func (f Factory) Float64ObservableUpDownCounter(name string, opts ...metric.Float64ObservableUpDownCounterOption) metric.Float64ObservableUpDownCounter

Float64ObservableUpDownCounter returns a new instrument identified by name and configured with options. The instrument is used to asynchronously record float64 measurements once per a measurement collection cycle.

func (Factory) Float64UpDownCounter

func (f Factory) Float64UpDownCounter(name string, opts ...metric.Float64UpDownCounterOption) metric.Float64UpDownCounter

Float64UpDownCounter returns a new instrument identified by name and configured with options. The instrument is used to synchronously record float64 measurements during a computational operation.

func (Factory) Int64Counter

func (f Factory) Int64Counter(name string, opts ...metric.Int64CounterOption) metric.Int64Counter

Int64Counter returns a new instrument identified by name and configured with options. The instrument is used to synchronously record increasing int64 measurements during a computational operation.

func (Factory) Int64Histogram

func (f Factory) Int64Histogram(name string, opts ...metric.Int64HistogramOption) metric.Int64Histogram

Int64Histogram returns a new instrument identified by name and configured with options. The instrument is used to synchronously record the distribution of int64 measurements during a computational operation.

func (Factory) Int64ObservableCounter

func (f Factory) Int64ObservableCounter(name string, opts ...metric.Int64ObservableCounterOption) metric.Int64ObservableCounter

Int64ObservableCounter returns a new instrument identified by name and configured with options. The instrument is used to asynchronously record increasing int64 measurements once per a measurement collection cycle.

func (Factory) Int64ObservableGauge

func (f Factory) Int64ObservableGauge(name string, opts ...metric.Int64ObservableGaugeOption) metric.Int64ObservableGauge

Int64ObservableGauge returns a new instrument identified by name and configured with options. The instrument is used to asynchronously record instantaneous int64 measurements once per a measurement collection cycle.

func (Factory) Int64ObservableUpDownCounter

func (f Factory) Int64ObservableUpDownCounter(name string, opts ...metric.Int64ObservableUpDownCounterOption) metric.Int64ObservableUpDownCounter

Int64ObservableUpDownCounter returns a new instrument identified by name and configured with options. The instrument is used to asynchronously record int64 measurements once per a measurement collection cycle.

func (Factory) Int64UpDownCounter

func (f Factory) Int64UpDownCounter(name string, opts ...metric.Int64UpDownCounterOption) metric.Int64UpDownCounter

Int64UpDownCounter returns a new instrument identified by name and configured with options. The instrument is used to synchronously record int64 measurements during a computational operation.

func (Factory) RegisterCallback

func (f Factory) RegisterCallback(c metric.Callback, instruments ...metric.Observable) metric.Registration

RegisterCallback registers f to be called during the collection of a measurement cycle.

If Unregister of the returned Registration is called, f needs to be unregistered and not called during collection.

The instruments f is registered with are the only instruments that f may observe values for.

If no instruments are passed, f should not be registered nor called during collection.

Jump to

Keyboard shortcuts

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