statsd

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 23, 2024 License: MIT Imports: 15 Imported by: 0

README

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MeterProvider

type MeterProvider struct {
	embedded.MeterProvider
	// contains filtered or unexported fields
}

func NewMeterProvider

func NewMeterProvider(opts ...Option) *MeterProvider

func (*MeterProvider) Meter

func (c *MeterProvider) Meter(instrumentationName string, opts ...metric.MeterOption) metric.Meter

func (*MeterProvider) Start

func (c *MeterProvider) Start(_ context.Context) error

func (*MeterProvider) Stop

func (c *MeterProvider) Stop(_ context.Context) error

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option is the interface that applies the value to a configuration option.

func WithInterval added in v0.9.2

func WithInterval(d time.Duration) Option

WithInterval sets the intervening time to call observables

func WithResource

func WithResource(r *resource.Resource) Option

WithResource sets the Resource configuration option of a Config by merging it with the Resource configuration in the environment.

func WithStatsdClient

func WithStatsdClient(s statsd.StatSender) Option

WithStatsdClient sets the StatsD client. If not set, a default one will be created.

func WithWorkerChanBufferSize

func WithWorkerChanBufferSize(workers int) Option

WithWorkerChanBufferSize sets the size of the worker chan buffer. Default is workers * 10

func WithWorkers

func WithWorkers(workers int) Option

WithWorkers sets the number of Workers. If <= 0, send synchronously

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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