"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "pkg/metrics/prometheus.go" between
traefik-v2.3.2.src.tar.gz and traefik-v2.3.3.src.tar.gz

About: Traefik is a cloud native edge router, a reverse proxy and load balancer for HTTP and TCP-based applications.

prometheus.go  (traefik-v2.3.2.src):prometheus.go  (traefik-v2.3.3.src)
package metrics package metrics
import ( import (
"context" "context"
"errors"
"net/http" "net/http"
"sort" "sort"
"strings" "strings"
"sync" "sync"
"time" "time"
"github.com/go-kit/kit/metrics" "github.com/go-kit/kit/metrics"
stdprometheus "github.com/prometheus/client_golang/prometheus" stdprometheus "github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp" "github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/traefik/traefik/v2/pkg/config/dynamic" "github.com/traefik/traefik/v2/pkg/config/dynamic"
skipping to change at line 77 skipping to change at line 78
func PrometheusHandler() http.Handler { func PrometheusHandler() http.Handler {
return promhttp.HandlerFor(promRegistry, promhttp.HandlerOpts{}) return promhttp.HandlerFor(promRegistry, promhttp.HandlerOpts{})
} }
// RegisterPrometheus registers all Prometheus metrics. // RegisterPrometheus registers all Prometheus metrics.
// It must be called only once and failing to register the metrics will lead to a panic. // It must be called only once and failing to register the metrics will lead to a panic.
func RegisterPrometheus(ctx context.Context, config *types.Prometheus) Registry { func RegisterPrometheus(ctx context.Context, config *types.Prometheus) Registry {
standardRegistry := initStandardRegistry(config) standardRegistry := initStandardRegistry(config)
if err := promRegistry.Register(stdprometheus.NewProcessCollector(stdprom etheus.ProcessCollectorOpts{})); err != nil { if err := promRegistry.Register(stdprometheus.NewProcessCollector(stdprom etheus.ProcessCollectorOpts{})); err != nil {
if _, ok := err.(stdprometheus.AlreadyRegisteredError); !ok { var arErr stdprometheus.AlreadyRegisteredError
if !errors.As(err, &arErr) {
log.FromContext(ctx).Warn("ProcessCollector is already re gistered") log.FromContext(ctx).Warn("ProcessCollector is already re gistered")
} }
} }
if err := promRegistry.Register(stdprometheus.NewGoCollector()); err != n il { if err := promRegistry.Register(stdprometheus.NewGoCollector()); err != n il {
if _, ok := err.(stdprometheus.AlreadyRegisteredError); !ok { var arErr stdprometheus.AlreadyRegisteredError
if !errors.As(err, &arErr) {
log.FromContext(ctx).Warn("GoCollector is already registe red") log.FromContext(ctx).Warn("GoCollector is already registe red")
} }
} }
if !registerPromState(ctx) { if !registerPromState(ctx) {
return nil return nil
} }
return standardRegistry return standardRegistry
} }
skipping to change at line 215 skipping to change at line 219
reg.serviceReqDurationHistogram, _ = NewHistogramWithScale(servic eReqDurations, time.Second) reg.serviceReqDurationHistogram, _ = NewHistogramWithScale(servic eReqDurations, time.Second)
reg.serviceOpenConnsGauge = serviceOpenConns reg.serviceOpenConnsGauge = serviceOpenConns
reg.serviceRetriesCounter = serviceRetries reg.serviceRetriesCounter = serviceRetries
reg.serviceServerUpGauge = serviceServerUp reg.serviceServerUpGauge = serviceServerUp
} }
return reg return reg
} }
func registerPromState(ctx context.Context) bool { func registerPromState(ctx context.Context) bool {
if err := promRegistry.Register(promState); err != nil { err := promRegistry.Register(promState)
logger := log.FromContext(ctx) if err == nil {
if _, ok := err.(stdprometheus.AlreadyRegisteredError); !ok { return true
logger.Errorf("Unable to register Traefik to Prometheus: }
%v", err)
return false logger := log.FromContext(ctx)
}
var arErr stdprometheus.AlreadyRegisteredError
if errors.As(err, &arErr) {
logger.Debug("Prometheus collector already registered.") logger.Debug("Prometheus collector already registered.")
return true
} }
return true
logger.Errorf("Unable to register Traefik to Prometheus: %v", err)
return false
} }
// OnConfigurationUpdate receives the current configuration from Traefik. // OnConfigurationUpdate receives the current configuration from Traefik.
// It then converts the configuration to the optimized package internal format // It then converts the configuration to the optimized package internal format
// and sets it to the promState. // and sets it to the promState.
func OnConfigurationUpdate(conf dynamic.Configuration, entryPoints []string) { func OnConfigurationUpdate(conf dynamic.Configuration, entryPoints []string) {
dynamicConfig := newDynamicConfig() dynamicConfig := newDynamicConfig()
for _, value := range entryPoints { for _, value := range entryPoints {
dynamicConfig.entryPoints[value] = true dynamicConfig.entryPoints[value] = true
 End of changes. 7 change blocks. 
10 lines changed or deleted 19 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)