Documentation
¶
Index ¶
- Constants
- Variables
- func CircuitBreaker(commandName string, commandCfg hystrix.CommandConfig) endpoint.Middleware
- func Cleanup() endpoint.Middleware
- func CleanupEndpoint(key string)
- func InitMetrics()
- func IsCircuitOpen(key string) (open, ok bool)
- func Metrics(src, tgt, uri, method string) endpoint.Middleware
- func Tracing(uri string) endpoint.Middleware
- type PrometheusCollector
Constants ¶
const PrometheusNamespace = "hystrix_go"
PrometheusNamespace namespace for hystrix metrics
Variables ¶
var DefaultCBConfig = hystrix.CommandConfig{
Timeout: 5000,
MaxConcurrentRequests: 500,
ErrorPercentThreshold: 50,
SleepWindow: 5000,
RequestVolumeThreshold: 20,
}
DefaultCBConfig provides default circuitbreak setting
Functions ¶
func CircuitBreaker ¶
func CircuitBreaker(commandName string, commandCfg hystrix.CommandConfig) endpoint.Middleware
CircuitBreaker provides hystrix circuitbreaker for HTTP calls.
func Cleanup ¶
func Cleanup() endpoint.Middleware
Cleanup is a middleware guarding the call and doing some cleanup
func CleanupEndpoint ¶
func CleanupEndpoint(key string)
CleanupEndpoint cleans up endpoint info by given key(format: <addr>-<uri>-<method>)
func InitMetrics ¶
func InitMetrics()
InitMetrics inits prometheus setting and starts server on given port
func IsCircuitOpen ¶
IsCircuitOpen return whether circuit of given key(format: <addr>-<uri>-<method>) is open
func Metrics ¶
func Metrics(src, tgt, uri, method string) endpoint.Middleware
Metrics returns a middleware to export metrics to prometheus
func Tracing ¶
func Tracing(uri string) endpoint.Middleware
Tracing adds opentracing support for outgoing calls
Types ¶
type PrometheusCollector ¶
type PrometheusCollector struct {
// contains filtered or unexported fields
}
PrometheusCollector struct contains the metrics for prometheus. The handling of the values is completely done by the prometheus client library. The function `Collector` can be registered to the metricsCollector.Registry. If one want to use a custom registry it can be given via the reg parameter. If reg is nil, the prometheus default registry is used. The RunDuration is observed via a prometheus histogram ( https://prometheus.io/docs/concepts/metric_types/#histogram ). If the duration_buckets slice is nil, the "github.com/prometheus/client_golang/prometheus".DefBuckets are used. As stated by the prometheus documentation, one should tailor the buckets to the response times of your application.
Example use
package main import ( "github.com/afex/hystrix-go/plugins" "github.com/afex/hystrix-go/hystrix/metric_collector" ) func main() { pc := plugins.NewPrometheusCollector(nil, nil) metricCollector.Registry.Register(pc.Collector) }
func NewPrometheusCollector ¶
func NewPrometheusCollector(reg prometheus.Registerer, durationBuckets []float64) PrometheusCollector
NewPrometheusCollector creates collector
func (*PrometheusCollector) Collector ¶
func (hm *PrometheusCollector) Collector(name string) metricCollector.MetricCollector
Collector returns collector for a given command