Skip to content

mahboubii/otelauto

Repository files navigation

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)
}