4141ProcPath string = "/bin/run"
4242ProcName string = "runner"
4343Device string = "en0"
44+ Disk string = "nvme0n1p128"
4445)
4546
4647func TestRemap (t * testing.T ) {
@@ -66,6 +67,8 @@ func doTestRemap(t *testing.T, id string, remapOpts ...Option) {
6667m ["process.name" ] = ProcName
6768case "network" :
6869m ["system.network.name" ] = Device
70+ case "disk" :
71+ m ["system.diskio.name" ] = Disk
6972}
7073return m
7174}
@@ -267,6 +270,30 @@ func doTestRemap(t *testing.T, id string, remapOpts ...Option) {
267270{Type : Sum , Name : "system.network.out.errors" , DP : testDP {Ts : now , Int : ptr (int64 (2 )), Attrs : outAttr ("network" )}},
268271},
269272},
273+ {
274+ name : "disk" ,
275+ scraper : "disk" ,
276+ input : []testMetric {
277+ {Type : Sum , Name : "system.disk.io" , DP : testDP {Ts : now , Int : ptr (int64 (1888256 )), Attrs : map [string ]any {"device" : Disk , "direction" : "read" }}},
278+ {Type : Sum , Name : "system.disk.io" , DP : testDP {Ts : now , Int : ptr (int64 (512 )), Attrs : map [string ]any {"device" : Disk , "direction" : "write" }}},
279+ {Type : Sum , Name : "system.disk.operations" , DP : testDP {Ts : now , Int : ptr (int64 (15390 )), Attrs : map [string ]any {"device" : Disk , "direction" : "read" }}},
280+ {Type : Sum , Name : "system.disk.operations" , DP : testDP {Ts : now , Int : ptr (int64 (371687 )), Attrs : map [string ]any {"device" : Disk , "direction" : "write" }}},
281+ {Type : Sum , Name : "system.disk.operation_time" , DP : testDP {Ts : now , Dbl : ptr (11.182 ), Attrs : map [string ]any {"device" : Disk , "direction" : "read" }}},
282+ {Type : Sum , Name : "system.disk.operation_time" , DP : testDP {Ts : now , Dbl : ptr (617.289 ), Attrs : map [string ]any {"device" : Disk , "direction" : "write" }}},
283+ {Type : Sum , Name : "system.disk.io_time" , DP : testDP {Ts : now , Dbl : ptr (520.3 ), Attrs : map [string ]any {"device" : Disk }}},
284+ {Type : Sum , Name : "system.disk.pending_operations" , DP : testDP {Ts : now , Int : ptr (int64 (102 )), Attrs : map [string ]any {"device" : Disk }}},
285+ },
286+ expected : []testMetric {
287+ {Type : Sum , Name : "system.diskio.read.bytes" , DP : testDP {Ts : now , Int : ptr (int64 (1888256 )), Attrs : outAttr ("disk" )}},
288+ {Type : Sum , Name : "system.diskio.write.bytes" , DP : testDP {Ts : now , Int : ptr (int64 (512 )), Attrs : outAttr ("disk" )}},
289+ {Type : Sum , Name : "system.diskio.read.count" , DP : testDP {Ts : now , Int : ptr (int64 (15390 )), Attrs : outAttr ("disk" )}},
290+ {Type : Sum , Name : "system.diskio.write.count" , DP : testDP {Ts : now , Int : ptr (int64 (371687 )), Attrs : outAttr ("disk" )}},
291+ {Type : Sum , Name : "system.diskio.read.time" , DP : testDP {Ts : now , Dbl : ptr (11182.0 ), Attrs : outAttr ("disk" )}},
292+ {Type : Sum , Name : "system.diskio.write.time" , DP : testDP {Ts : now , Dbl : ptr (617289.0 ), Attrs : outAttr ("disk" )}},
293+ {Type : Sum , Name : "system.diskio.io.time" , DP : testDP {Ts : now , Dbl : ptr (520300.0 ), Attrs : outAttr ("disk" )}},
294+ {Type : Sum , Name : "system.diskio.io.ops" , DP : testDP {Ts : now , Int : ptr (int64 (102 )), Attrs : outAttr ("disk" )}},
295+ },
296+ },
270297} {
271298t .Run (fmt .Sprintf ("%s/%s" , tc .name , id ), func (t * testing.T ) {
272299sm := pmetric .NewScopeMetrics ()
0 commit comments