From ad376bf70fe46b099f6e0bf7b9fe672ae800a19b Mon Sep 17 00:00:00 2001 From: fengwei Date: Wed, 3 Dec 2025 21:07:02 +0800 Subject: [PATCH 1/2] Remove metrics with empty data Because empty data cannot be considered an error. --- extra/redisotel/metrics.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/redisotel/metrics.go b/extra/redisotel/metrics.go index 77aa5d144..98b8c2441 100644 --- a/extra/redisotel/metrics.go +++ b/extra/redisotel/metrics.go @@ -329,7 +329,7 @@ func milliseconds(d time.Duration) float64 { } func statusAttr(err error) attribute.KeyValue { - if err != nil { + if err != nil && err != redis.Nil { return attribute.String("status", "error") } return attribute.String("status", "ok") From 2c1e4bca523ec3d67a892084b75b37b89c30a70a Mon Sep 17 00:00:00 2001 From: fengwei Date: Wed, 3 Dec 2025 21:46:09 +0800 Subject: [PATCH 2/2] redis.Nil uses a separate state. Better differentiation between values, null values, and errors. --- extra/redisotel/metrics.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/extra/redisotel/metrics.go b/extra/redisotel/metrics.go index 98b8c2441..85065402a 100644 --- a/extra/redisotel/metrics.go +++ b/extra/redisotel/metrics.go @@ -329,7 +329,10 @@ func milliseconds(d time.Duration) float64 { } func statusAttr(err error) attribute.KeyValue { - if err != nil && err != redis.Nil { + if err != nil { + if err == redis.Nil { + return attribute.String("status", "nil") + } return attribute.String("status", "error") } return attribute.String("status", "ok")