statsd

package module
v0.8.4 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2022 License: MIT Imports: 14 Imported by: 0

README

Go OpenTelemetry StatsD Meter Provider

Usage

go get github.com/SibrosTech/otel-statsd/go/metric/controller/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/controller/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),
    )
    
    global.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 Controller

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

func New

func New(opts ...Option) *Controller

func (*Controller) Meter

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

func (*Controller) Start

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

func (*Controller) Stop

func (c *Controller) 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 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