From 8bc59f8c3bd4db80df3989c362e08d26eb5c36e2 Mon Sep 17 00:00:00 2001 From: Phil Winder Date: Mon, 13 Mar 2017 14:50:09 +0000 Subject: [PATCH] Remove old monitoring code. --- logging.go | 34 ---------------------------------- wiring.go | 22 +--------------------- 2 files changed, 1 insertion(+), 55 deletions(-) diff --git a/logging.go b/logging.go index e2290f9..4118e46 100644 --- a/logging.go +++ b/logging.go @@ -2,7 +2,6 @@ package payment import ( "github.com/go-kit/kit/log" - "github.com/go-kit/kit/metrics" "time" ) @@ -42,36 +41,3 @@ func (mw loggingMiddleware) Health() (health []Health) { }(time.Now()) return mw.next.Health() } - -type instrumentingService struct { - requestCount metrics.Counter - requestLatency metrics.Histogram - Service -} - -// NewInstrumentingService returns an instance of an instrumenting Service. -func NewInstrumentingService(requestCount metrics.Counter, requestLatency metrics.Histogram, s Service) Service { - return &instrumentingService{ - requestCount: requestCount, - requestLatency: requestLatency, - Service: s, - } -} - -func (s *instrumentingService) Authorise(amount float32) (auth Authorisation, err error) { - defer func(begin time.Time) { - s.requestCount.With("method", "authorise").Add(1) - s.requestLatency.With("method", "authorise").Observe(time.Since(begin).Seconds()) - }(time.Now()) - - return s.Service.Authorise(amount) -} - -func (s *instrumentingService) Health() []Health { - defer func(begin time.Time) { - s.requestCount.With("method", "health").Add(1) - s.requestLatency.With("method", "health").Observe(time.Since(begin).Seconds()) - }(time.Now()) - - return s.Service.Health() -} diff --git a/wiring.go b/wiring.go index 5cb28eb..d8bd3aa 100644 --- a/wiring.go +++ b/wiring.go @@ -7,10 +7,8 @@ import ( "github.com/go-kit/kit/log" "golang.org/x/net/context" - kitprometheus "github.com/go-kit/kit/metrics/prometheus" - stdopentracing "github.com/opentracing/opentracing-go" - stdprometheus "github.com/prometheus/client_golang/prometheus" "github.com/microservices-demo/payment/middleware" + stdopentracing "github.com/opentracing/opentracing-go" ) func WireUp(ctx context.Context, declineAmount float32, tracer stdopentracing.Tracer, serviceName string) (http.Handler, log.Logger) { @@ -22,29 +20,11 @@ func WireUp(ctx context.Context, declineAmount float32, tracer stdopentracing.Tr logger = log.NewContext(logger).With("caller", log.DefaultCaller) } - fieldKeys := []string{"method"} // Service domain. var service Service { service = NewAuthorisationService(declineAmount) service = LoggingMiddleware(logger)(service) - service = NewInstrumentingService( - kitprometheus.NewCounterFrom( - stdprometheus.CounterOpts{ - Namespace: "http", - Subsystem: "requests", - Name: "total", - Help: "Number of requests received.", - }, - fieldKeys), - kitprometheus.NewSummaryFrom(stdprometheus.SummaryOpts{ - Namespace: "http", - Subsystem: "request", - Name: "duration_microseconds_sum", - Help: "Total duration of requests in microseconds.", - }, fieldKeys), - service, - ) } // Endpoint domain.