prometheus_hystrix_go

package module
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2021 License: MIT Imports: 5 Imported by: 0

README

prometheus-hystrix-go

license Go Report Card

OVERVIEW

prometheus-hystrix-go is metric collector of prometheus for hystrix-go.

HOW TO USE

package main

import (
	"net/http"
        "github.com/afex/hystrix-go/hystrix"
	hystrix_metric "github.com/afex/hystrix-go/hystrix/metric_collector"
	prometheus_hystrix_go "github.com/gjbae1212/prometheus-hystrix-go"
	"github.com/prometheus/client_golang/prometheus/promhttp"
)

func main() {
        // get hystrix wrapper
 	wrapper := prometheus_hystrix_go.NewPrometheusCollector("hystrix", map[string]string{"app": "myapp"})
 
 	// register and initialize to hystrix prometheus
 	hystrix_metric.Registry.Register(wrapper)
 
 	http.HandleFunc("/", func(rw http.ResponseWriter, r *http.Request) {
 		hystrix.Do("my_command", func() error { return nil }, nil)
 	})
 
 	// start server
 	http.Handle("/metrics", promhttp.Handler())
 	http.ListenAndServe(":8080", nil)
}

This example allows you get to the prometheus metric of the hystrix when you request to /metrics path.

LICENSE

This project is following The MIT.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPrometheusCollector

func NewPrometheusCollector(namespace string, labels map[string]string) func(string) hystrix_metric.MetricCollector

NewPrometheusCollector returns wrapper function returning an implemented struct from MetricCollector.

Types

type PrometheusCollector

type PrometheusCollector struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

PrometheusCollector is collecting information that is made from hystrix-go.

func (*PrometheusCollector) Reset

func (c *PrometheusCollector) Reset()

Reset is to reset information (not call method).

func (*PrometheusCollector) Update

Update is to update information from hystrix-go at this time.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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