Skip to content

Commit a66bcc9

Browse files
committed
Collect cache metrics from aws-sdk-go-cache library
1 parent 49b0071 commit a66bcc9

File tree

26 files changed

+1337
-101
lines changed

26 files changed

+1337
-101
lines changed

Gopkg.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/main.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"time"
2929

3030
"github.com/golang/glog"
31+
"github.com/kubernetes-sigs/aws-alb-ingress-controller/internal/ingress/metric/collectors"
3132
"github.com/prometheus/client_golang/prometheus"
3233
"github.com/prometheus/client_golang/prometheus/promhttp"
3334
"github.com/ticketmaster/aws-sdk-go-cache/cache"
@@ -87,8 +88,11 @@ func main() {
8788

8889
conf.Client = kubeClient
8990

91+
cc := cache.NewConfig(5 * time.Minute)
92+
9093
reg := prometheus.NewRegistry()
9194

95+
reg.MustRegister(cc.NewCacheCollector(collectors.PrometheusNamespace))
9296
reg.MustRegister(prometheus.NewGoCollector())
9397
reg.MustRegister(prometheus.NewProcessCollector(prometheus.ProcessCollectorOpts{}))
9498

@@ -98,8 +102,6 @@ func main() {
98102
}
99103
mc.Start()
100104

101-
cc := cache.NewConfig(5 * time.Minute)
102-
103105
c := controller.NewALBController(conf, mc, cc)
104106
go handleSigterm(c, func(code int) {
105107
os.Exit(code)

internal/aws/albsession/session.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,6 @@ func NewSession(awsconfig *aws.Config, AWSDebug bool, mc metric.Collector, cc *c
3939
})
4040

4141
session.Handlers.Complete.PushFront(func(r *request.Request) {
42-
ctx := r.HTTPRequest.Context()
43-
cacheName := r.ClientInfo.ServiceName + "." + r.Operation.Name
44-
if cache.IsCacheHit(ctx) {
45-
mc.IncAPICacheCount(prometheus.Labels{"cache": cacheName, "action": "hit"})
46-
} else {
47-
mc.IncAPICacheCount(prometheus.Labels{"cache": cacheName, "action": "miss"})
48-
}
49-
5042
if r.Error != nil {
5143
mc.IncAPIErrorCount(prometheus.Labels{"service": r.ClientInfo.ServiceName, "operation": r.Operation.Name})
5244
if AWSDebug {

internal/ingress/metric/collectors/aws.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ type AWSAPIController struct {
2727
awsAPIRequest *prometheus.CounterVec
2828
awsAPIError *prometheus.CounterVec
2929
awsAPIRetry *prometheus.CounterVec
30-
awsAPICache *prometheus.CounterVec
3130
}
3231

3332
// NewAWSAPIController creates a new prometheus collector for the
@@ -58,14 +57,6 @@ func NewAWSAPIController() *AWSAPIController {
5857
},
5958
[]string{"service", "operation"},
6059
),
61-
awsAPICache: prometheus.NewCounterVec(
62-
prometheus.CounterOpts{
63-
Namespace: PrometheusNamespace,
64-
Name: "aws_api_cache",
65-
Help: `Cache action`,
66-
},
67-
[]string{"cache", "action"},
68-
),
6960
}
7061
}
7162

@@ -84,23 +75,16 @@ func (a *AWSAPIController) IncAPIRetryCount(l prometheus.Labels) {
8475
a.awsAPIRetry.With(l).Inc()
8576
}
8677

87-
// IncAPICacheCount increment the reconcile counter
88-
func (a *AWSAPIController) IncAPICacheCount(l prometheus.Labels) {
89-
a.awsAPICache.With(l).Inc()
90-
}
91-
9278
// Describe implements prometheus.Collector
9379
func (a AWSAPIController) Describe(ch chan<- *prometheus.Desc) {
9480
a.awsAPIRequest.Describe(ch)
9581
a.awsAPIError.Describe(ch)
9682
a.awsAPIRetry.Describe(ch)
97-
a.awsAPICache.Describe(ch)
9883
}
9984

10085
// Collect implements the prometheus.Collector interface.
10186
func (a AWSAPIController) Collect(ch chan<- prometheus.Metric) {
10287
a.awsAPIRequest.Collect(ch)
10388
a.awsAPIError.Collect(ch)
10489
a.awsAPIRetry.Collect(ch)
105-
a.awsAPICache.Collect(ch)
10690
}

internal/ingress/metric/dummy.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ func (dc DummyCollector) IncAPIErrorCount(prometheus.Labels) {}
3939
// IncAPIRetryCount ...
4040
func (dc DummyCollector) IncAPIRetryCount(prometheus.Labels) {}
4141

42-
// IncAPICacheCount ...
43-
func (dc DummyCollector) IncAPICacheCount(prometheus.Labels) {}
44-
4542
// Start ...
4643
func (dc DummyCollector) Start() {}
4744

internal/ingress/metric/main.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ type Collector interface {
3232
IncAPIRequestCount(prometheus.Labels)
3333
IncAPIErrorCount(prometheus.Labels)
3434
IncAPIRetryCount(prometheus.Labels)
35-
IncAPICacheCount(prometheus.Labels)
3635

3736
RemoveMetrics(string)
3837

@@ -83,10 +82,6 @@ func (c *collector) IncAPIRetryCount(l prometheus.Labels) {
8382
c.awsAPIController.IncAPIRetryCount(l)
8483
}
8584

86-
func (c *collector) IncAPICacheCount(l prometheus.Labels) {
87-
c.awsAPIController.IncAPICacheCount(l)
88-
}
89-
9085
func (c *collector) RemoveMetrics(ingressName string) {
9186
c.ingressController.RemoveMetrics(ingressName)
9287
}

vendor/github.com/aws/aws-sdk-go/CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/aws/aws-sdk-go/aws/version.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/aws/aws-sdk-go/models/apis/ds/2015-04-16/api-2.json

Lines changed: 109 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)