doggy

package module
v0.0.0-...-d16fb57 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TraceCache    = SpanType("cache")
	TraceDatabase = SpanType("db")
)
View Source
var InitClient = func() (*statsd.Client, error) {
	client, err := statsd.New(os.Getenv("DOGSTATSD_ADDR"))
	if err != nil {
		return nil, err
	}
	return client, nil
}

InitClient is a function that knows how to initialize a dogstatsd client. By default, it will lazily initialize a client when we record our first metric and attempts to connect to the address contained in the 'DOGSTATSD_ADDR' environment variable.

View Source
var (
	PanicOnStatsdError = true
)

Functions

func Event

func Event(event *statsd.Event)

Event sends a new event to Datadog

func FinishSpan

func FinishSpan(span tracer.Span, e *error, options ...tracer.FinishOption)

FinishSpan finishes a previously started span with an optional error. The error is provided as a pointer which allows callers to defer a named return variable err by reference.

	func doSomething() (err error) {
		span := StartSpanFromContext(context.Background())
		defer doggy.FinishSpan(span, &err)
     	...
	}

func NewMetric

func NewMetric[T CounterMetric | HistogramMetric | GaugeMetric | DistributionMetric | TimingMetric](namespace, serviceName, metricName string, options ...MetricOption) (out T)

func StartProfiler

func StartProfiler(serviceName, serviceVersion string, options ...profiler.Option) error

StartProfiler starts the profiler with the provided parameters. The service name is required, but the service version and environment are not required.

func StartSpanFromContext

func StartSpanFromContext(ctx context.Context, operationName string, opts ...TracerStartSpanOption) tracer.Span

StartSpanFromContext starts a new span which is a child of an existing span if one has been injected

func StartTracer

func StartTracer(serviceName, serviceVersion string, options ...tracer.StartOption) error

StartTracer starts the tracer with the correct env variables

func StopProfiler

func StopProfiler()

StopProfiler stops the profiler

func StopTracer

func StopTracer()

StopTracer stops the started tracer. Subsequent calls are valid but become no-op.

Types

type CounterMetric

type CounterMetric struct {
	Metric
}

func (CounterMetric) Count

func (m CounterMetric) Count(value int, options ...MetricOption)

Count tracks how many times something happened per second and panics if no statsd client exists

func (CounterMetric) CountE

func (m CounterMetric) CountE(value int, options ...MetricOption) error

CountE tracks how many times something happened per second.

type DistributionMetric

type DistributionMetric struct {
	Metric
}

func (DistributionMetric) Distribution

func (m DistributionMetric) Distribution(value float64, options ...MetricOption)

Distribution tracks the statistical distribution of a set of values across your infrastructure and panics if no statsd client exists.

func (DistributionMetric) DistributionE

func (m DistributionMetric) DistributionE(value float64, options ...MetricOption) error

DistributionE tracks the statistical distribution of a set of values across your infrastructure.

type GaugeMetric

type GaugeMetric struct {
	Metric
}

func (GaugeMetric) Gauge

func (m GaugeMetric) Gauge(value float64, options ...MetricOption)

Gauge measures the value of a metric at a particular time and panics if no statsd client exists.

func (GaugeMetric) GaugeE

func (m GaugeMetric) GaugeE(value float64, options ...MetricOption) error

GaugeE measures the value of a metric at a particular time.

type HistogramMetric

type HistogramMetric struct {
	Metric
}

func (HistogramMetric) Histogram

func (m HistogramMetric) Histogram(value float64, options ...MetricOption)

Histogram tracks the statistical distribution of a set of values on each host and panics if no statsd client exists.

func (HistogramMetric) HistogramE

func (m HistogramMetric) HistogramE(value float64, options ...MetricOption) error

HistogramE tracks the statistical distribution of a set of values on each host.

type Hostname

type Hostname string

type Message

type Message string

type Metric

type Metric struct {
	Namespace   string
	ServiceName string
	MetricName  string
	Tags        Tags
}

Metric is a common group of fields across every type of metric (counter, gauge, histogram, etc)

type MetricOption

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

type MetricOptions

type MetricOptions struct {
	Tags       Tags
	SampleRate float64
}

type ServiceCheck

type ServiceCheck struct {
	Namespace   string
	ServiceName string
	CheckName   string
}

func NewServiceCheck

func NewServiceCheck(namespace, service, check string) *ServiceCheck

func (ServiceCheck) UpdateStatus

func (s ServiceCheck) UpdateStatus(status ServiceCheckStatus, options ...ServiceCheckOption)

UpdateStatus updates the status of this service check

func (ServiceCheck) UpdateStatusE

func (s ServiceCheck) UpdateStatusE(status ServiceCheckStatus, options ...ServiceCheckOption) error

type ServiceCheckOption

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

type ServiceCheckOptions

type ServiceCheckOptions struct {
	Tags     Tags
	Hostname string
	Message  string
}

type ServiceCheckStatus

type ServiceCheckStatus byte
const (
	// Ok is the "ok" ServiceCheck status
	Ok ServiceCheckStatus = 0
	// Warn is the "warning" ServiceCheck status
	Warn ServiceCheckStatus = 1
	// Critical is the "critical" ServiceCheck status
	Critical ServiceCheckStatus = 2
	// Unknown is the "unknown" ServiceCheck status
	Unknown ServiceCheckStatus = 3
)

type SpanType

type SpanType string

type StartSpanOption

type StartSpanOption tracer.StartSpanOption

type StatsdClient

type StatsdClient interface {
	Count(name string, value int64, tags []string, rate float64) error
	Histogram(name string, value float64, tags []string, rate float64) error
	Gauge(name string, value float64, tags []string, rate float64) error
	Distribution(name string, value float64, tags []string, rate float64) error
	Timing(name string, value time.Duration, tags []string, rate float64) error
	ServiceCheck(sc *statsd.ServiceCheck) error
	Event(event *statsd.Event) error
}

type Tags

type Tags map[string]string

func (Tags) MergeInto

func (t1 Tags) MergeInto(t2 Tags)

MergeInto merges t1 into t2 giving priority to any matching keys in t1

type TimingMetric

type TimingMetric struct {
	Metric
}

func (TimingMetric) Timing

func (m TimingMetric) Timing(value time.Duration, options ...MetricOption)

Timing sends timing information and panics if no statsd client exists.

func (TimingMetric) TimingE

func (m TimingMetric) TimingE(value time.Duration, options ...MetricOption) error

TimingE sends timing information.

type TracerStartSpanOption

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

Jump to

Keyboard shortcuts

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