2
2
{-# LANGUAGE DeriveFunctor #-}
3
3
{-# LANGUAGE DeriveGeneric #-}
4
4
{-# LANGUAGE FlexibleInstances #-}
5
+ {-# LANGUAGE RecordWildCards #-}
5
6
6
7
module Cardano.Logging.Resources.Types
7
8
( Resources (.. )
@@ -33,12 +34,16 @@ data Resources a
33
34
, rHeap :: ! a
34
35
, rRSS :: ! a
35
36
, rCentiBlkIO :: ! a
37
+ , rNetBytesRd :: ! a
38
+ , rNetBytesWr :: ! a
39
+ , rFsBytesRd :: ! a
40
+ , rFsBytesWr :: ! a
36
41
, rThreads :: ! a
37
42
}
38
43
deriving (Functor , Generic , Show )
39
44
40
45
instance Applicative Resources where
41
- pure a = Resources a a a a a a a a a a a
46
+ pure a = Resources a a a a a a a a a a a a a a a
42
47
f <*> x =
43
48
Resources
44
49
{ rCentiCpu = rCentiCpu f (rCentiCpu x)
@@ -51,6 +56,10 @@ instance Applicative Resources where
51
56
, rHeap = rHeap f (rHeap x)
52
57
, rRSS = rRSS f (rRSS x)
53
58
, rCentiBlkIO = rCentiBlkIO f (rCentiBlkIO x)
59
+ , rNetBytesRd = rNetBytesRd f (rNetBytesRd x)
60
+ , rNetBytesWr = rNetBytesWr f (rNetBytesWr x)
61
+ , rFsBytesRd = rFsBytesRd f (rFsBytesRd x)
62
+ , rFsBytesWr = rFsBytesWr f (rFsBytesWr x)
54
63
, rThreads = rThreads f (rThreads x)
55
64
}
56
65
@@ -76,30 +85,38 @@ docResourceStats :: Documented ResourceStats
76
85
docResourceStats = Documented [
77
86
DocMsg
78
87
[]
79
- [(" Resources.Stat.Cputicks" , " Reports the CPU ticks, sice the process was started" )
80
- ,(" Resources.Mem.Resident" , " " )
81
- ,(" Resources.RTS.GcLiveBytes" , " " )
82
- ,(" Resources.RTS.GcMajorNum" , " " )
83
- ,(" Resources.RTS.GcMinorNum" , " " )
84
- ,(" Resources.RTS.Gcticks" , " " )
85
- ,(" Resources.RTS.Mutticks" , " " )
86
- ,(" Resources.RTS.Threads" ," " )
88
+ [(" Resources.Stat.Cputicks" , " Kernel-reported CPU ticks (1/100th of a second), since process start" )
89
+ ,(" Resources.Mem.Resident" , " Kernel-reported RSS (resident set size)" )
90
+ ,(" Resources.RTS.GcLiveBytes" , " RTS-reported live bytes" )
91
+ ,(" Resources.RTS.GcMajorNum" , " Major GCs" )
92
+ ,(" Resources.RTS.GcMinorNum" , " Minor GCs" )
93
+ ,(" Resources.RTS.Gcticks" , " RTS-reported CPU ticks spent on GC" )
94
+ ,(" Resources.RTS.Mutticks" , " RTS-reported CPU ticks spent on mutator" )
95
+ ,(" Resources.State.NetBytesRd" , " IP packet bytes read" )
96
+ ,(" Resources.State.NetBytesWr" , " IP packet bytes written" )
97
+ ,(" Resources.State.FsBytesRd" , " FS bytes read" )
98
+ ,(" Resources.State.FsBytesWr" , " FS bytes written" )
99
+ ,(" Resources.RTS.Threads" ," RTS green thread count" )
87
100
]
88
101
" "
89
102
]
90
103
91
104
instance LogFormatting ResourceStats where
92
- forHuman rs = " Resources:"
93
- <> " Cpu Ticks " <> (pack . show ) (rCentiCpu rs)
94
- <> " , GC centiseconds " <> (pack . show ) (rCentiGC rs)
95
- <> " , Mutator centiseconds " <> (pack . show ) (rCentiMut rs)
96
- <> " , GCs major " <> (pack . show ) (rGcsMajor rs)
97
- <> " , GCs minor " <> (pack . show ) (rGcsMinor rs)
98
- <> " , Allocated bytes " <> (pack . show ) (rAlloc rs)
99
- <> " , GC live bytes " <> (pack . show ) (rLive rs)
100
- <> " , RTS heap " <> (pack . show ) (rHeap rs)
101
- <> " , RSS " <> (pack . show ) (rRSS rs)
102
- <> " , Threads " <> (pack . show ) (rThreads rs)
105
+ forHuman Resources {.. } = " Resources:"
106
+ <> " Cpu Ticks " <> (pack . show ) rCentiCpu
107
+ <> " , GC centiseconds " <> (pack . show ) rCentiGC
108
+ <> " , Mutator centiseconds " <> (pack . show ) rCentiMut
109
+ <> " , GCs major " <> (pack . show ) rGcsMajor
110
+ <> " , GCs minor " <> (pack . show ) rGcsMinor
111
+ <> " , Allocated bytes " <> (pack . show ) rAlloc
112
+ <> " , GC live bytes " <> (pack . show ) rLive
113
+ <> " , RTS heap " <> (pack . show ) rHeap
114
+ <> " , RSS " <> (pack . show ) rRSS
115
+ <> " , Net bytes read " <> (pack . show ) rNetBytesRd
116
+ <> " written " <> (pack . show ) rNetBytesWr
117
+ <> " , FS bytes read " <> (pack . show ) rFsBytesRd
118
+ <> " written " <> (pack . show ) rFsBytesWr
119
+ <> " , Threads " <> (pack . show ) rThreads
103
120
<> " ."
104
121
105
122
forMachine _dtal rs = mconcat
@@ -114,16 +131,27 @@ instance LogFormatting ResourceStats where
114
131
, " Heap" .= Number (fromIntegral $ rHeap rs)
115
132
, " RSS" .= Number (fromIntegral $ rRSS rs)
116
133
, " CentiBlkIO" .= Number (fromIntegral $ rCentiBlkIO rs)
134
+ , " NetBytesRd" .= Number (fromIntegral $ rNetBytesRd rs)
135
+ , " NetBytesWr" .= Number (fromIntegral $ rNetBytesWr rs)
136
+ , " FsBytesRd" .= Number (fromIntegral $ rFsBytesRd rs)
137
+ , " FsBytesWr" .= Number (fromIntegral $ rFsBytesWr rs)
117
138
, " Threads" .= Number (fromIntegral $ rThreads rs)
118
139
]
119
140
120
141
asMetrics rs =
121
- [ IntM " Resources.Stat.Cputicks" (fromIntegral $ rCentiCpu rs)
122
- , IntM " Resources.Mem.Resident" (fromIntegral $ rRSS rs)
123
- , IntM " Resources.RTS.GcLiveBytes" (fromIntegral $ rLive rs)
124
- , IntM " Resources.RTS.GcMajorNum" (fromIntegral $ rGcsMajor rs)
125
- , IntM " Resources.RTS.GcMinorNum" (fromIntegral $ rGcsMinor rs)
126
- , IntM " Resources.RTS.Gcticks" (fromIntegral $ rCentiGC rs)
127
- , IntM " Resources.RTS.Mutticks" (fromIntegral $ rCentiMut rs)
142
+ [ IntM " Resources.Stat.Cputicks" (fromIntegral $ rCentiCpu rs)
143
+ , IntM " Resources.RTS.Gcticks" (fromIntegral $ rCentiGC rs)
144
+ , IntM " Resources.RTS.Mutticks" (fromIntegral $ rCentiMut rs)
145
+ , IntM " Resources.RTS.GcMajorNum" (fromIntegral $ rGcsMajor rs)
146
+ , IntM " Resources.RTS.GcMinorNum" (fromIntegral $ rGcsMinor rs)
147
+ , IntM " Resources.RTS.Alloc" (fromIntegral $ rAlloc rs)
148
+ , IntM " Resources.RTS.GcLiveBytes" (fromIntegral $ rLive rs)
149
+ , IntM " Resources.RTS.Heap" (fromIntegral $ rHeap rs)
150
+ , IntM " Resources.Mem.Resident" (fromIntegral $ rRSS rs)
151
+ , IntM " Resources.Stat.BlkIOticks" (fromIntegral $ rCentiBlkIO rs)
152
+ , IntM " Resources.State.NetBytesRd" (fromIntegral $ rNetBytesRd rs)
153
+ , IntM " Resources.State.NetBytesWr" (fromIntegral $ rNetBytesWr rs)
154
+ , IntM " Resources.State.FsBytesRd" (fromIntegral $ rFsBytesRd rs)
155
+ , IntM " Resources.State.FsBytesWr" (fromIntegral $ rFsBytesWr rs)
128
156
, IntM " Resources.RTS.Stat.Threads" (fromIntegral $ rThreads rs)
129
157
]
0 commit comments