@@ -80,19 +80,22 @@ object JvmStats {
80
80
case compilation =>
81
81
val compilationStats = stats.scope(" compilation" )
82
82
gauges.add(
83
- compilationStats.metricBuilder(GaugeType ).withCounterishGauge.gauge(" time_msec" ) {
83
+ compilationStats.addGauge(
84
+ compilationStats.metricBuilder(GaugeType ).withCounterishGauge.withName(" time_msec" )) {
84
85
compilation.getTotalCompilationTime().toFloat
85
86
})
86
87
}
87
88
88
89
val classes = ManagementFactory .getClassLoadingMXBean()
89
90
val classLoadingStats = stats.scope(" classes" )
90
91
gauges.add(
91
- classLoadingStats.metricBuilder(GaugeType ).withCounterishGauge.gauge(" total_loaded" ) {
92
+ classLoadingStats.addGauge(
93
+ classLoadingStats.metricBuilder(GaugeType ).withCounterishGauge.withName(" total_loaded" )) {
92
94
classes.getTotalLoadedClassCount().toFloat
93
95
})
94
96
gauges.add(
95
- classLoadingStats.metricBuilder(GaugeType ).withCounterishGauge.gauge(" total_unloaded" ) {
97
+ classLoadingStats.addGauge(
98
+ classLoadingStats.metricBuilder(GaugeType ).withCounterishGauge.withName(" total_unloaded" )) {
96
99
classes.getUnloadedClassCount().toFloat
97
100
})
98
101
gauges.add(
@@ -142,15 +145,20 @@ object JvmStats {
142
145
}
143
146
144
147
val spStats = stats.scope(" safepoint" )
145
- gauges.add(spStats.metricBuilder(GaugeType ).withCounterishGauge.gauge(" sync_time_millis" ) {
146
- jvm.safepoint.syncTimeMillis.toFloat
147
- })
148
- gauges.add(spStats.metricBuilder(GaugeType ).withCounterishGauge.gauge(" total_time_millis" ) {
149
- jvm.safepoint.totalTimeMillis.toFloat
150
- })
151
- gauges.add(spStats.metricBuilder(GaugeType ).withCounterishGauge.gauge(" count" ) {
152
- jvm.safepoint.count.toFloat
153
- })
148
+ gauges.add(
149
+ spStats.addGauge(
150
+ spStats.metricBuilder(GaugeType ).withCounterishGauge.withName(" sync_time_millis" )) {
151
+ jvm.safepoint.syncTimeMillis.toFloat
152
+ })
153
+ gauges.add(
154
+ spStats.addGauge(
155
+ spStats.metricBuilder(GaugeType ).withCounterishGauge.withName(" total_time_millis" )) {
156
+ jvm.safepoint.totalTimeMillis.toFloat
157
+ })
158
+ gauges.add(
159
+ spStats.addGauge(spStats.metricBuilder(GaugeType ).withCounterishGauge.withName(" count" )) {
160
+ jvm.safepoint.count.toFloat
161
+ })
154
162
155
163
ManagementFactory .getPlatformMXBeans(classOf [BufferPoolMXBean ]) match {
156
164
case null =>
@@ -169,10 +177,12 @@ object JvmStats {
169
177
gcPool.foreach { gc =>
170
178
val name = gc.getName.regexSub(""" [^\w]""" .r) { m => " _" }
171
179
val poolCycles =
172
- gcStats.metricBuilder(GaugeType ).withCounterishGauge.gauge(name, " cycles" ) {
180
+ gcStats.addGauge(
181
+ gcStats.metricBuilder(GaugeType ).withCounterishGauge.withName(name, " cycles" )) {
173
182
gc.getCollectionCount.toFloat
174
183
}
175
- val poolMsec = gcStats.metricBuilder(GaugeType ).withCounterishGauge.gauge(name, " msec" ) {
184
+ val poolMsec = gcStats.addGauge(
185
+ gcStats.metricBuilder(GaugeType ).withCounterishGauge.withName(name, " msec" )) {
176
186
gc.getCollectionTime.toFloat
177
187
}
178
188
@@ -195,12 +205,14 @@ object JvmStats {
195
205
}
196
206
197
207
// note, these could be -1 if the collector doesn't have support for it.
198
- val cycles = gcStats.metricBuilder(GaugeType ).withCounterishGauge.gauge(" cycles" ) {
199
- gcPool.map(_.getCollectionCount).filter(_ > 0 ).sum.toFloat
200
- }
201
- val msec = gcStats.metricBuilder(GaugeType ).withCounterishGauge.gauge(" msec" ) {
202
- gcPool.map(_.getCollectionTime).filter(_ > 0 ).sum.toFloat
203
- }
208
+ val cycles =
209
+ gcStats.addGauge(gcStats.metricBuilder(GaugeType ).withCounterishGauge.withName(" cycles" )) {
210
+ gcPool.map(_.getCollectionCount).filter(_ > 0 ).sum.toFloat
211
+ }
212
+ val msec =
213
+ gcStats.addGauge(gcStats.metricBuilder(GaugeType ).withCounterishGauge.withName(" msec" )) {
214
+ gcPool.map(_.getCollectionTime).filter(_ > 0 ).sum.toFloat
215
+ }
204
216
205
217
gauges.add(cycles)
206
218
gauges.add(msec)
0 commit comments