Skip to content

Latest commit

 

History

History

statsd

Go OpenTelemetry StatsD Meter Provider

Usage

go get github.com/SibrosTech/otel-statsd/go/metric/provider/statsd@latest
import (
    "go.opentelemetry.io/otel/metric/global"
    "go.opentelemetry.io/otel/sdk/resource"
    "github.com/cactus/go-statsd-client/v5/statsd"
    otel_statsd "github.com/SibrosTech/otel-statsd/go/metric/provider/statsd"
)

func main() {
    statsdClient, err := statsd.NewClientWithConfig(&statsd.ClientConfig{
        Address:     "127.0.0.1:8125",
        UseBuffered: false, // for AWS lambda
        TagFormat:   statsd.SuffixOctothorpe, // for OpenTelemetry-Collector's statsd receiver
    })
    if err != nil {
        panic(err)
    }

	r := resource.Default()
	
    pusher := otel_statsd.New(
        otel_statsd.WithStatsdClient(statsdClient),
        otel_statsd.WithResource(r),
    )
    
    otel.SetMeterProvider(pusher)
    if err := pusher.Start(ctx); err != nil {
        panic(err)
    }
}