Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .chloggen/redisreceiver.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: breaking

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: redisreceiver

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Support more metric label values for redis.cpu.time

# One or more tracking issues related to the change
issues: [14943]
2 changes: 1 addition & 1 deletion receiver/redisreceiver/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ metrics:
| cmd | Redis command name | |
| db | Redis database identifier | |
| role | Redis node's role | replica, primary |
| state | Redis CPU usage state | |
| state | Redis CPU usage state | sys, sys_children, sys_main_thread, user, user_children, user_main_thread |
46 changes: 44 additions & 2 deletions receiver/redisreceiver/internal/metadata/generated_metrics.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions receiver/redisreceiver/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,21 @@ resource_attributes:
attributes:
state:
description: Redis CPU usage state
# Redis versions < 6.0 have:
# used_cpu_sys: System CPU consumed by the Redis server, which is the sum of system CPU consumed by all threads of the server process (main thread and background threads)
# used_cpu_user: User CPU consumed by the Redis server, which is the sum of user CPU consumed by all threads of the server process (main thread and background threads)
# used_cpu_sys_children: System CPU consumed by the background processes
# used_cpu_user_children: User CPU consumed by the background processes
# Redis versions >= 6.0 have two more:
# used_cpu_sys_main_thread: System CPU consumed by the Redis server main thread
# used_cpu_user_main_thread: User CPU consumed by the Redis server main thread
Comment thread
singku marked this conversation as resolved.
Outdated
enum:
- sys
- sys_children
- sys_main_thread
- user
- user_children
- user_main_thread
db:
description: Redis database identifier
role:
Expand Down
31 changes: 25 additions & 6 deletions receiver/redisreceiver/metric_functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@

package redisreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/redisreceiver"

import "go.opentelemetry.io/collector/pdata/pcommon"
import (
"go.opentelemetry.io/collector/pdata/pcommon"

"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/redisreceiver/internal/metadata"
)

// dataPointRecorders is called once at startup. Returns recorders for all metrics (except keyspace)
// we want to extract from Redis INFO.
Expand Down Expand Up @@ -44,7 +48,10 @@ func (rs *redisScraper) dataPointRecorders() map[string]interface{} {
"uptime_in_seconds": rs.mb.RecordRedisUptimeDataPoint,
"used_cpu_sys": rs.recordUsedCPUSys,
"used_cpu_sys_children": rs.recordUsedCPUSysChildren,
"used_cpu_user": rs.recordUsedCPUSysUser,
"used_cpu_sys_main_thread": rs.recordUsedCPUSysMainThread,
"used_cpu_user": rs.recordUsedCPUUser,
"used_cpu_user_children": rs.recordUsedCPUUserChildren,
"used_cpu_user_main_thread": rs.recordUsedCPUUserMainThread,
"used_memory": rs.mb.RecordRedisMemoryUsedDataPoint,
"used_memory_lua": rs.mb.RecordRedisMemoryLuaDataPoint,
"used_memory_peak": rs.mb.RecordRedisMemoryPeakDataPoint,
Expand All @@ -53,13 +60,25 @@ func (rs *redisScraper) dataPointRecorders() map[string]interface{} {
}

func (rs *redisScraper) recordUsedCPUSys(now pcommon.Timestamp, val float64) {
rs.mb.RecordRedisCPUTimeDataPoint(now, val, "sys")
rs.mb.RecordRedisCPUTimeDataPoint(now, val, metadata.AttributeStateSys)
}

func (rs *redisScraper) recordUsedCPUSysChildren(now pcommon.Timestamp, val float64) {
rs.mb.RecordRedisCPUTimeDataPoint(now, val, "children")
rs.mb.RecordRedisCPUTimeDataPoint(now, val, metadata.AttributeStateSysChildren)
}

func (rs *redisScraper) recordUsedCPUSysMainThread(now pcommon.Timestamp, val float64) {
rs.mb.RecordRedisCPUTimeDataPoint(now, val, metadata.AttributeStateSysMainThread)
}

func (rs *redisScraper) recordUsedCPUUser(now pcommon.Timestamp, val float64) {
rs.mb.RecordRedisCPUTimeDataPoint(now, val, metadata.AttributeStateUser)
}

func (rs *redisScraper) recordUsedCPUUserChildren(now pcommon.Timestamp, val float64) {
rs.mb.RecordRedisCPUTimeDataPoint(now, val, metadata.AttributeStateUserChildren)
}

func (rs *redisScraper) recordUsedCPUSysUser(now pcommon.Timestamp, val float64) {
rs.mb.RecordRedisCPUTimeDataPoint(now, val, "user")
func (rs *redisScraper) recordUsedCPUUserMainThread(now pcommon.Timestamp, val float64) {
rs.mb.RecordRedisCPUTimeDataPoint(now, val, metadata.AttributeStateUserMainThread)
}
2 changes: 1 addition & 1 deletion receiver/redisreceiver/redis_svc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ func TestParser(t *testing.T) {
s := newFakeAPIParser()
info, err := s.info()
require.Nil(t, err)
require.Equal(t, 128, len(info))
require.Equal(t, 130, len(info))
require.Equal(t, "1.24", info["allocator_frag_ratio"]) // spot check
}
2 changes: 2 additions & 0 deletions receiver/redisreceiver/testdata/info.txt
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ used_cpu_sys:185.649184
used_cpu_user:46.396430
used_cpu_sys_children:0.002354
used_cpu_user_children:0.001619
used_cpu_sys_main_thread:180.0
used_cpu_user_main_thread:42.39

# Cluster
cluster_enabled:0
Expand Down