Fix open connections metric

Co-authored-by: Romain <rtribotte@users.noreply.github.com>
This commit is contained in:
mpl 2023-03-20 16:02:06 +01:00 committed by GitHub
parent 598a257ae1
commit 7c2af10bbd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 126 additions and 236 deletions

View file

@ -101,6 +101,10 @@ func TestPrometheus(t *testing.T) {
prometheusRegistry.ConfigReloadsCounter().Add(1)
prometheusRegistry.LastConfigReloadSuccessGauge().Set(float64(time.Now().Unix()))
prometheusRegistry.
OpenConnectionsGauge().
With("entrypoint", "test", "protocol", "TCP").
Set(1)
prometheusRegistry.
TLSCertsNotAfterTimestampGauge().
@ -115,10 +119,6 @@ func TestPrometheus(t *testing.T) {
EntryPointReqDurationHistogram().
With("code", strconv.Itoa(http.StatusOK), "method", http.MethodGet, "protocol", "http", "entrypoint", "http").
Observe(1)
prometheusRegistry.
EntryPointOpenConnsGauge().
With("method", http.MethodGet, "protocol", "http", "entrypoint", "http").
Set(1)
prometheusRegistry.
EntryPointRespsBytesCounter().
With("code", strconv.Itoa(http.StatusOK), "method", http.MethodGet, "protocol", "http", "entrypoint", "http").
@ -140,10 +140,6 @@ func TestPrometheus(t *testing.T) {
RouterReqDurationHistogram().
With("router", "demo", "service", "service1", "code", strconv.Itoa(http.StatusOK), "method", http.MethodGet, "protocol", "http").
Observe(10000)
prometheusRegistry.
RouterOpenConnsGauge().
With("router", "demo", "service", "service1", "method", http.MethodGet, "protocol", "http").
Set(1)
prometheusRegistry.
RouterRespsBytesCounter().
With("router", "demo", "service", "service1", "code", strconv.Itoa(http.StatusOK), "method", http.MethodGet, "protocol", "http").
@ -165,10 +161,6 @@ func TestPrometheus(t *testing.T) {
ServiceReqDurationHistogram().
With("service", "service1", "code", strconv.Itoa(http.StatusOK), "method", http.MethodGet, "protocol", "http").
Observe(10000)
prometheusRegistry.
ServiceOpenConnsGauge().
With("service", "service1", "method", http.MethodGet, "protocol", "http").
Set(1)
prometheusRegistry.
ServiceRetriesCounter().
With("service", "service1").
@ -204,13 +196,21 @@ func TestPrometheus(t *testing.T) {
assert: buildTimestampAssert(t, configLastReloadSuccessName),
},
{
name: tlsCertsNotAfterTimestamp,
name: openConnectionsName,
labels: map[string]string{
"protocol": "TCP",
"entrypoint": "test",
},
assert: buildGaugeAssert(t, openConnectionsName, 1),
},
{
name: tlsCertsNotAfterTimestampName,
labels: map[string]string{
"cn": "value",
"serial": "value",
"sans": "value",
},
assert: buildTimestampAssert(t, tlsCertsNotAfterTimestamp),
assert: buildTimestampAssert(t, tlsCertsNotAfterTimestampName),
},
{
name: entryPointReqsTotalName,
@ -232,15 +232,6 @@ func TestPrometheus(t *testing.T) {
},
assert: buildHistogramAssert(t, entryPointReqDurationName, 1),
},
{
name: entryPointOpenConnsName,
labels: map[string]string{
"method": http.MethodGet,
"protocol": "http",
"entrypoint": "http",
},
assert: buildGaugeAssert(t, entryPointOpenConnsName, 1),
},
{
name: entryPointReqsBytesTotalName,
labels: map[string]string{
@ -293,16 +284,6 @@ func TestPrometheus(t *testing.T) {
},
assert: buildHistogramAssert(t, routerReqDurationName, 1),
},
{
name: routerOpenConnsName,
labels: map[string]string{
"method": http.MethodGet,
"protocol": "http",
"service": "service1",
"router": "demo",
},
assert: buildGaugeAssert(t, routerOpenConnsName, 1),
},
{
name: routerReqsBytesTotalName,
labels: map[string]string{
@ -354,15 +335,6 @@ func TestPrometheus(t *testing.T) {
},
assert: buildHistogramAssert(t, serviceReqDurationName, 1),
},
{
name: serviceOpenConnsName,
labels: map[string]string{
"method": http.MethodGet,
"protocol": "http",
"service": "service1",
},
assert: buildGaugeAssert(t, serviceOpenConnsName, 1),
},
{
name: serviceRetriesTotalName,
labels: map[string]string{