Skip to content

Commit

Permalink
More tests, remove backwards compatibility metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
mindw committed Sep 20, 2024
1 parent fd3ea08 commit 17efb98
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 16 deletions.
12 changes: 0 additions & 12 deletions exporter/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,18 +212,6 @@ func (e *Exporter) extractConnectedClientMetrics(ch chan<- prometheus.Metric, c
clientInfoLabelsValues...,
)

// keep the old name for backwards compatability
e.metricDescriptions["connected_clients_details"] = newMetricDescr(
e.options.Namespace,
"connected_clients_details",
"Details about a connected client",
clientInfoLabels,
)
e.registerConstMetricGauge(
ch, "connected_clients_details", 1.0,
clientInfoLabelsValues...,
)

clientBaseLabels := []string{"id", "name"}
clientBaseLabelsValues := []string{info.Id, info.Name}

Expand Down
36 changes: 32 additions & 4 deletions exporter/clients_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,45 @@ func TestParseClientListString(t *testing.T) {
expectedOk: true,
expectedInfo: ClientInfo{Id: "14", CreatedAt: convertDurationToTimestampInt64("5"), IdleSince: convertDurationToTimestampInt64("0"), Flags: "N", Db: "0", Ssub: -1, Watch: -1, Qbuf: 26, QbufFree: 32742, OMem: 0, TotMem: 0, Host: "127.0.0.1", Port: "64959", User: "default", Resp: "3"},
}, {
in: "id=40253233 addr=fd40:1481:21:dbe0:7021:300:a03:1a06:44426 fd=19 name= age=782 idle=0 flags=N db=0 sub=0 psub=0 ssub=17 watch=3 multi=-1 qbuf=26 qbuf-free=32742 argv-mem=10 obl=0 oll=0 omem=0 tot-mem=61466 ow=0 owmem=0 events=r cmd=client user=default lib-name=redis-py lib-ver=5.0.1 numops=9",
in: "id=40253233 addr=fd40:1481:21:dbe0:7021:300:a03:1a06:44426 fd=19 name= age=782 idle=0 flags=N db=0 sub=896 psub=18 ssub=17 watch=3 multi=-1 qbuf=26 qbuf-free=32742 argv-mem=10 obl=0 oll=555 omem=0 tot-mem=61466 ow=0 owmem=0 events=r cmd=client user=default lib-name=redis-py lib-ver=5.0.1 numops=9",
expectedOk: true,
expectedInfo: ClientInfo{Id: "40253233", CreatedAt: convertDurationToTimestampInt64("782"), IdleSince: convertDurationToTimestampInt64("0"), Flags: "N", Db: "0", Ssub: 17, Watch: 3, Qbuf: 26, QbufFree: 32742, OMem: 0, TotMem: 61466, Host: "fd40:1481:21:dbe0:7021:300:a03:1a06", Port: "44426", User: "default"},
expectedInfo: ClientInfo{Id: "40253233", CreatedAt: convertDurationToTimestampInt64("782"), IdleSince: convertDurationToTimestampInt64("0"), Flags: "N", Db: "0", Sub: 896, Psub: 18, Ssub: 17, Watch: 3, Qbuf: 26, QbufFree: 32742, Oll: 555, OMem: 0, TotMem: 61466, Host: "fd40:1481:21:dbe0:7021:300:a03:1a06", Port: "44426", User: "default"},
}, {
in: "id=14 addr=127.0.0.1:64958 fd=9 name=foo age=ABCDE idle=0 flags=N db=1 sub=0 psub=0 multi=-1 qbuf=26 qbuf-free=32742 obl=0 oll=0 omem=0 tot-mem=0 events=r cmd=client",
expectedOk: false,
}, {
in: "id=14 addr=127.0.0.1:64958 fd=9 name=foo age=5 idle=NOPE flags=N db=1 sub=0 psub=0 multi=-1 qbuf=26 qbuf-free=32742 obl=0 oll=0 omem=0 tot-mem=0 events=r cmd=client",
expectedOk: false,
}, {
in: "id=14 addr=127.0.0.1:64958 fd=9 name=foo age=5 idle=0 flags=N db=1 sub=ERR psub=0 multi=-1 qbuf=26 qbuf-free=32742 obl=0 oll=0 omem=0 tot-mem=0 events=r cmd=client",
expectedOk: false,
}, {
in: "id=14 addr=127.0.0.1:64958 fd=9 name=foo age=5 idle=0 flags=N db=1 sub=0 psub=ERR multi=-1 qbuf=26 qbuf-free=32742 obl=0 oll=0 omem=0 tot-mem=0 events=r cmd=client",
expectedOk: false,
}, {
in: "id=14 addr=127.0.0.1:64958 ssub=ERR",
expectedOk: false,
}, {
in: "id=14 addr=127.0.0.1:64958 watch=ERR",
expectedOk: false,
}, {
in: "id=14 addr=127.0.0.1:64958 qbuf=ERR",
expectedOk: false,
}, {
in: "id=14 addr=127.0.0.1:64958 qbuf-free=ERR",
expectedOk: false,
}, {
in: "id=14 addr=127.0.0.1:64958 obl=ERR",
expectedOk: false,
}, {
in: "id=14 addr=127.0.0.1:64958 oll=ERR",
expectedOk: false,
}, {
in: "id=14 addr=127.0.0.1:64958 omem=ERR",
expectedOk: false,
}, {
in: "id=14 addr=127.0.0.1:64958 tot-mem=ERR",
expectedOk: false,
}, {
in: "",
expectedOk: false,
Expand Down Expand Up @@ -121,8 +151,6 @@ func TestExportClientList(t *testing.T) {
}{
{
in: "connected_client_info",
}, {
in: "connected_clients_details",
}, {
in: "connected_client_output_buffer_memory_usage_bytes",
}, {
Expand Down

0 comments on commit 17efb98

Please sign in to comment.