An OpenTelemetry (OTel) metric instrumentation helper inspired by prometheus promauto.
By default it's using the global meter provider.
$ go get github.com/mahboubii/otelauto
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)
}