Skip to content
This repository was archived by the owner on Dec 5, 2023. It is now read-only.

Commit 8bc59f8

Browse files
committed
Remove old monitoring code.
1 parent 3d787e6 commit 8bc59f8

File tree

2 files changed

+1
-55
lines changed

2 files changed

+1
-55
lines changed

logging.go

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package payment
22

33
import (
44
"github.com/go-kit/kit/log"
5-
"github.com/go-kit/kit/metrics"
65
"time"
76
)
87

@@ -42,36 +41,3 @@ func (mw loggingMiddleware) Health() (health []Health) {
4241
}(time.Now())
4342
return mw.next.Health()
4443
}
45-
46-
type instrumentingService struct {
47-
requestCount metrics.Counter
48-
requestLatency metrics.Histogram
49-
Service
50-
}
51-
52-
// NewInstrumentingService returns an instance of an instrumenting Service.
53-
func NewInstrumentingService(requestCount metrics.Counter, requestLatency metrics.Histogram, s Service) Service {
54-
return &instrumentingService{
55-
requestCount: requestCount,
56-
requestLatency: requestLatency,
57-
Service: s,
58-
}
59-
}
60-
61-
func (s *instrumentingService) Authorise(amount float32) (auth Authorisation, err error) {
62-
defer func(begin time.Time) {
63-
s.requestCount.With("method", "authorise").Add(1)
64-
s.requestLatency.With("method", "authorise").Observe(time.Since(begin).Seconds())
65-
}(time.Now())
66-
67-
return s.Service.Authorise(amount)
68-
}
69-
70-
func (s *instrumentingService) Health() []Health {
71-
defer func(begin time.Time) {
72-
s.requestCount.With("method", "health").Add(1)
73-
s.requestLatency.With("method", "health").Observe(time.Since(begin).Seconds())
74-
}(time.Now())
75-
76-
return s.Service.Health()
77-
}

wiring.go

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@ import (
77
"github.com/go-kit/kit/log"
88
"golang.org/x/net/context"
99

10-
kitprometheus "github.com/go-kit/kit/metrics/prometheus"
11-
stdopentracing "github.com/opentracing/opentracing-go"
12-
stdprometheus "github.com/prometheus/client_golang/prometheus"
1310
"github.com/microservices-demo/payment/middleware"
11+
stdopentracing "github.com/opentracing/opentracing-go"
1412
)
1513

1614
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
2220
logger = log.NewContext(logger).With("caller", log.DefaultCaller)
2321
}
2422

25-
fieldKeys := []string{"method"}
2623
// Service domain.
2724
var service Service
2825
{
2926
service = NewAuthorisationService(declineAmount)
3027
service = LoggingMiddleware(logger)(service)
31-
service = NewInstrumentingService(
32-
kitprometheus.NewCounterFrom(
33-
stdprometheus.CounterOpts{
34-
Namespace: "http",
35-
Subsystem: "requests",
36-
Name: "total",
37-
Help: "Number of requests received.",
38-
},
39-
fieldKeys),
40-
kitprometheus.NewSummaryFrom(stdprometheus.SummaryOpts{
41-
Namespace: "http",
42-
Subsystem: "request",
43-
Name: "duration_microseconds_sum",
44-
Help: "Total duration of requests in microseconds.",
45-
}, fieldKeys),
46-
service,
47-
)
4828
}
4929

5030
// Endpoint domain.

0 commit comments

Comments
 (0)