plugins

package
v0.0.0-...-e39a78a Latest Latest
Warning

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

Go to latest
Published: May 12, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDatadogCollector

func NewDatadogCollector(addr, prefix string) (func(string) metricCollector.MetricCollector, error)

NewDatadogCollector creates a collector for a specific circuit with a "github.com/DataDog/datadog-go/statsd".(*Client).

addr is in the format "<host>:<port>" (e.g. "localhost:8125")

prefix may be an empty string

Example use

package main

import (
	"github.com/myteksi/hystrix-go/plugins"
	"github.com/myteksi/hystrix-go/hystrix/metric_collector"
)

func main() {
	collector, err := plugins.NewDatadogCollector("localhost:8125", "")
	if err != nil {
		panic(err)
	}
	metricCollector.Registry.Register(collector)
}

func NewDatadogCollectorWithClient

func NewDatadogCollectorWithClient(client DatadogClient) func(string) metricCollector.MetricCollector

NewDatadogCollectorWithClient accepts an interface which allows you to provide your own implementation of a statsd client, alter configuration on "github.com/DataDog/datadog-go/statsd".(*Client), provide additional tags per circuit-metric tuple, and add logging if you need it.

Types

type DatadogClient

type DatadogClient interface {
	Count(name string, value int64, tags []string, rate float64) error
	Gauge(name string, value float64, tags []string, rate float64) error
	TimeInMilliseconds(name string, value float64, tags []string, rate float64) error
}

DatadogClient is the minimum interface needed by NewDatadogCollectorWithClient

type DatadogCollector

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

DatadogCollector fulfills the metricCollector interface allowing users to ship circuit stats to Datadog.

This Collector, by default, uses github.com/DataDog/datadog-go/statsd for transport. The main advantage of this over statsd is building graphs and multi-alert monitors around single metrics (constantized above) and adding tag dimensions. You can set up a single monitor to rule them all across services and geographies. Graphs become much simpler to setup by allowing you to create queries like the following

{
  "viz": "timeseries",
  "requests": [
    {
      "q": "max:hystrix.runDuration.95percentile{$region} by {hystrixcircuit}",
      "type": "line"
    }
  ]
}

As new circuits come online you get graphing and monitoring "for free".

func (*DatadogCollector) IncrementAttempts

func (dc *DatadogCollector) IncrementAttempts()

IncrementAttempts increments the number of calls to this circuit.

func (*DatadogCollector) IncrementErrors

func (dc *DatadogCollector) IncrementErrors()

IncrementErrors increments the number of unsuccessful attempts. Attempts minus Errors will equal successes within a time range. Errors are any result from an attempt that is not a success.

func (*DatadogCollector) IncrementFailures

func (dc *DatadogCollector) IncrementFailures()

IncrementFailures increments the number of requests that fail.

func (*DatadogCollector) IncrementFallbackFailures

func (dc *DatadogCollector) IncrementFallbackFailures()

IncrementFallbackFailures increments the number of failures that occurred during the execution of the fallback function.

func (*DatadogCollector) IncrementFallbackSuccesses

func (dc *DatadogCollector) IncrementFallbackSuccesses()

IncrementFallbackSuccesses increments the number of successes that occurred during the execution of the fallback function.

func (*DatadogCollector) IncrementQueueSize

func (dc *DatadogCollector) IncrementQueueSize()

IncrementQueueSize increments the number of elements in the queue.

func (*DatadogCollector) IncrementRejects

func (dc *DatadogCollector) IncrementRejects()

IncrementRejects increments the number of requests that are rejected.

func (*DatadogCollector) IncrementShortCircuits

func (dc *DatadogCollector) IncrementShortCircuits()

IncrementShortCircuits increments the number of requests that short circuited due to the circuit being open.

func (*DatadogCollector) IncrementSuccesses

func (dc *DatadogCollector) IncrementSuccesses()

IncrementSuccesses increments the number of requests that succeed.

func (*DatadogCollector) IncrementTimeouts

func (dc *DatadogCollector) IncrementTimeouts()

IncrementTimeouts increments the number of timeouts that occurred in the circuit breaker.

func (*DatadogCollector) Reset

func (dc *DatadogCollector) Reset()

Reset is a noop operation in this collector.

func (*DatadogCollector) UpdateRunDuration

func (dc *DatadogCollector) UpdateRunDuration(runDuration time.Duration)

UpdateRunDuration updates the internal counter of how long the last run took.

func (*DatadogCollector) UpdateTotalDuration

func (dc *DatadogCollector) UpdateTotalDuration(timeSinceStart time.Duration)

UpdateTotalDuration updates the internal counter of how long we've run for.

Jump to

Keyboard shortcuts

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