Skip to content
This repository was archived by the owner on Oct 2, 2022. It is now read-only.

Commit 831390e

Browse files
author
Janos Pasztor
committed
Added metric for config server requests and updated libraries.
1 parent 616a7d4 commit 831390e

File tree

5 files changed

+157
-16
lines changed

5 files changed

+157
-16
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## 0.9.5: Security configuration
44

5-
This release adds support for the new [security library](https://github.com/containerssh/security).
5+
This release adds support for the new [security library](https://github.com/containerssh/security). It also adds a metric for config server requests and updates several libraries to their latest versions.
66

77
## 0.9.4: New docker and kubernetes backends
88

client_factory.go

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ import (
66
"github.com/containerssh/metrics"
77
)
88

9+
// MetricNameConfigBackendRequests is the number of requests to the config server
10+
const MetricNameConfigBackendRequests = "containerssh_config_server_requests"
11+
912
// MetricNameConfigBackendFailure is the number of request failures to the configuration backend.
1013
const MetricNameConfigBackendFailure = "containerssh_config_server_failures"
1114

@@ -23,17 +26,20 @@ func NewClient(
2326
return nil, err
2427
}
2528
}
26-
backendFailureMetric, err := metricsCollector.CreateCounter(
29+
backendRequestsMetric := metricsCollector.MustCreateCounter(
30+
MetricNameConfigBackendRequests,
31+
"requests",
32+
"The number of requests sent to the configuration server.",
33+
)
34+
backendFailureMetric := metricsCollector.MustCreateCounter(
2735
MetricNameConfigBackendFailure,
28-
"",
29-
"The number of request failures to the configuration backend.",
36+
"requests",
37+
"The number of request failures to the configuration server.",
3038
)
31-
if err != nil {
32-
return nil, err
33-
}
3439
return &client{
35-
httpClient: httpClient,
36-
logger: logger,
37-
backendFailureMetric: backendFailureMetric,
40+
httpClient: httpClient,
41+
logger: logger,
42+
backendRequestsMetric: backendRequestsMetric,
43+
backendFailureMetric: backendFailureMetric,
3844
}, nil
3945
}

client_impl.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ import (
1414
)
1515

1616
type client struct {
17-
httpClient http.Client
18-
logger log.Logger
19-
backendFailureMetric metrics.SimpleCounter
17+
httpClient http.Client
18+
logger log.Logger
19+
backendRequestsMetric metrics.SimpleCounter
20+
backendFailureMetric metrics.SimpleCounter
2021
}
2122

2223
func (c *client) Get(
@@ -34,6 +35,7 @@ func (c *client) Get(
3435
loop:
3536
for {
3637
lastLabels = []metrics.MetricLabel{}
38+
c.backendRequestsMetric.Increment()
3739
statusCode, err := c.httpClient.Post("", &request, &response)
3840
lastError = err
3941
if err != nil {

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ go 1.14
55
require (
66
github.com/containerssh/auditlog v0.9.5
77
github.com/containerssh/auth v0.9.3
8-
github.com/containerssh/docker v0.9.3
8+
github.com/containerssh/docker v0.9.5
99
github.com/containerssh/geoip v0.9.3
1010
github.com/containerssh/http v0.9.4
11-
github.com/containerssh/kubernetes v0.9.1
11+
github.com/containerssh/kubernetes v0.9.2
1212
github.com/containerssh/log v0.9.7
13-
github.com/containerssh/metrics v0.9.3
13+
github.com/containerssh/metrics v0.9.5
1414
github.com/containerssh/security v0.9.0
1515
github.com/containerssh/service v0.9.0
1616
github.com/containerssh/sshserver v0.9.14

0 commit comments

Comments
 (0)