Documentation ¶
Index ¶
- Variables
- func Event(event *statsd.Event)
- func FinishSpan(span tracer.Span, e *error, options ...tracer.FinishOption)
- func NewMetric[...](namespace, serviceName, metricName string, options ...MetricOption) (out T)
- func StartProfiler(serviceName, serviceVersion string, options ...profiler.Option) error
- func StartSpanFromContext(ctx context.Context, operationName string, opts ...TracerStartSpanOption) tracer.Span
- func StartTracer(serviceName, serviceVersion string, options ...tracer.StartOption) error
- func StopProfiler()
- func StopTracer()
- type CounterMetric
- type DistributionMetric
- type GaugeMetric
- type HistogramMetric
- type Hostname
- type Message
- type Metric
- type MetricOption
- type MetricOptions
- type ServiceCheck
- type ServiceCheckOption
- type ServiceCheckOptions
- type ServiceCheckStatus
- type SpanType
- type StartSpanOption
- type StatsdClient
- type Tags
- type TimingMetric
- type TracerStartSpanOption
Constants ¶
This section is empty.
Variables ¶
var ( TraceCache = SpanType("cache") TraceDatabase = SpanType("db") )
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.
var (
PanicOnStatsdError = true
)
Functions ¶
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 ¶
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 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 Metric ¶
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 ServiceCheck ¶
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 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 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 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
}