@@ -83,7 +83,7 @@ To create a simple counter:
8383
8484``` scala
8585scala> val totalRequests = Counter (metric " total_requests " , " Total requests" ).labels()
86- totalRequests: org.lyranthe.prometheus.client.internal. counter.Counter0 = Counter (MetricName (total_requests))()
86+ totalRequests: org.lyranthe.prometheus.client.counter.Counter0 = Counter (MetricName (total_requests))()
8787```
8888
8989The resulting counter has a metric name ` total_requests ` , a help message with the contents,
@@ -102,7 +102,7 @@ the `.labels` method:
102102
103103``` scala
104104scala> val totalErrors = Counter (metric " total_errors " , " Total errors" ).labels(label " code " )
105- totalErrors: org.lyranthe.prometheus.client.internal. counter.Counter1 = Counter1 (MetricName (total_errors),Total errors,List (LabelName (code)))
105+ totalErrors: org.lyranthe.prometheus.client.counter.Counter1 = Counter1 (MetricName (total_errors),Total errors,List (LabelName (code)))
106106```
107107
108108To increment a counter with an error code of "404", one might
@@ -119,7 +119,7 @@ number of values when using this counter:
119119
120120``` scala
121121scala> totalErrors.labelValues(" 404" , " /path" ).inc()
122- <console >: 17 : error : too many arguments for method labelValues : (labelValue1 : String )org.lyranthe.prometheus.client.internal. counter.LabelledCounter
122+ <console >: 17 : error : too many arguments for method labelValues : (labelValue1 : String )org.lyranthe.prometheus.client.counter.LabelledCounter
123123 totalErrors.labelValues(" 404" , " /path" ).inc()
124124 ^
125125```
@@ -134,30 +134,36 @@ You can create a registry with a default implementation with:
134134
135135``` scala
136136scala> implicit val defaultRegistry = DefaultRegistry ()
137- defaultRegistry: org.lyranthe.prometheus.client.DefaultRegistry =
137+ defaultRegistry: org.lyranthe.prometheus.client.DefaultRegistry = org.lyranthe.prometheus.client. DefaultRegistry @ 252a4792
138138```
139139
140140``` scala
141141scala> implicit val histogramBuckets = HistogramBuckets (1 , 2 , 5 , 10 , 20 , 50 , 100 )
142142histogramBuckets: org.lyranthe.prometheus.client.HistogramBuckets {val buckets : List [Double ]} = HistogramBuckets (1.0 ,2.0 ,5.0 ,10.0 ,20.0 ,50.0 ,100.0 ,Infinity )
143143
144144scala> val activeRequests = Gauge (metric " active_requests " , " Active requests" ).labels().unsafeRegister
145- activeRequests: org.lyranthe.prometheus.client.internal. gauge.Gauge0 = Counter (MetricName (active_requests))()
145+ activeRequests: org.lyranthe.prometheus.client.gauge.Gauge0 = Counter (MetricName (active_requests))()
146146
147147scala> val numErrors = Counter (metric " num_errors " , " Total errors" ).labels().unsafeRegister
148- numErrors: org.lyranthe.prometheus.client.internal. counter.Counter0 = Counter (MetricName (num_errors))()
148+ numErrors: org.lyranthe.prometheus.client.counter.Counter0 = Counter (MetricName (num_errors))()
149149
150150scala> val requestLatency = Histogram (metric " request_latency " , " Request latency" ).labels(label " path " ).unsafeRegister
151- requestLatency: org.lyranthe.prometheus.client.internal. histogram.Histogram1 = Histogram1 (MetricName (request_latency),Request latency,List (LabelName (path)),List (1.0 , 2.0 , 5.0 , 10.0 , 20.0 , 50.0 , 100.0 , Infinity ))
151+ requestLatency: org.lyranthe.prometheus.client.histogram.Histogram1 = Histogram1 (MetricName (request_latency),Request latency,List (LabelName (path)),List (1.0 , 2.0 , 5.0 , 10.0 , 20.0 , 50.0 , 100.0 , Infinity ))
152152
153153scala> activeRequests.set(50 )
154154
155155scala> numErrors.inc
156156
157157scala> requestLatency.labelValues(" /home" ).observe(17 )
158158
159- scala> implicitly[Registry ]
160- res10: org.lyranthe.prometheus.client.Registry =
159+ scala> implicitly[Registry ].outputText
160+ res10: String =
161+ " # HELP active_requests Active requests
162+ # TYPE active_requests gauge
163+ active_requests 50.0
164+ # HELP num_errors Total errors
165+ # TYPE num_errors counter
166+ num_errors 1.0
161167# HELP request_latency Request latency
162168# TYPE request_latency histogram
163169request_latency_bucket{le=" 1.0 " ,path=" / home " } 0
@@ -170,12 +176,7 @@ request_latency_bucket{le="100.0",path="/home"} 1
170176request_latency_bucket{le= " + Inf " ,path= " / home " } 1
171177request_latency_count{path= " / home " } 1
172178request_latency_sum{path= " / home " } 17.0
173- # HELP num_errors Total errors
174- # TYPE num_errors counter
175- num_errors 1.0
176- # HELP active_requests Active requests
177- # TYPE active_requests gauge
178- active_requests 50.0
179+ "
179180```
180181
181182## Using with FS2 Task (WIP)
@@ -198,14 +199,14 @@ import org.lyranthe.prometheus.client.fs2_syntax._
198199Then the method ` timeSuccess ` can be used to capture the duration of the task (in seconds):
199200
200201``` scala
201- implicit val registry = DefaultRegistry ()
202+ implicit val defaultRegistry = DefaultRegistry ()
202203```
203204``` scala
204205scala> implicit val histogramBuckets = HistogramBuckets (0.02 , 0.05 , 0.1 , 0.2 , 0.5 , 1.0 )
205206histogramBuckets: org.lyranthe.prometheus.client.HistogramBuckets {val buckets : List [Double ]} = HistogramBuckets (0.02 ,0.05 ,0.1 ,0.2 ,0.5 ,1.0 ,Infinity )
206207
207208scala> val requestLatency = Histogram (metric " request_latency " , " Request latency" ).labels(label " path " ).unsafeRegister
208- requestLatency: org.lyranthe.prometheus.client.internal. histogram.Histogram1 = Histogram1 (MetricName (request_latency),Request latency,List (LabelName (path)),List (0.02 , 0.05 , 0.1 , 0.2 , 0.5 , 1.0 , Infinity ))
209+ requestLatency: org.lyranthe.prometheus.client.histogram.Histogram1 = Histogram1 (MetricName (request_latency),Request latency,List (LabelName (path)),List (0.02 , 0.05 , 0.1 , 0.2 , 0.5 , 1.0 , Infinity ))
209210
210211scala> val mySleepyTask = Task .delay(Thread .sleep(scala.util.Random .nextInt(800 )))
211212mySleepyTask: fs2.Task [Unit ] = Task
@@ -215,27 +216,28 @@ myTimedSleepyTask: fs2.Task[Unit] = Task
215216
216217scala> for (i <- Range (1 , 10 )) myTimedSleepyTask.unsafeRun
217218
218- scala> implicitly[Registry ]
219- res1: org.lyranthe.prometheus.client. Registry =
220- # HELP request_latency Request latency
219+ scala> implicitly[Registry ].outputText
220+ res1: String =
221+ " # HELP request_latency Request latency
221222# TYPE request_latency histogram
222223request_latency_bucket{le=" 0.02 " ,path=" / home " } 0
223224request_latency_bucket{le= " 0.05 " ,path=" / home " } 0
224225request_latency_bucket{le= " 0.1 " ,path=" / home " } 0
225- request_latency_bucket{le= " 0.2" ,path= " /home" } 4
226- request_latency_bucket{le= " 0.5" ,path= " /home" } 6
226+ request_latency_bucket{le= " 0.2 " ,path=" / home " } 1
227+ request_latency_bucket{le= " 0.5 " ,path=" / home " } 5
227228request_latency_bucket{le= " 1.0 " ,path=" / home " } 9
228229request_latency_bucket{le= " + Inf " ,path= " / home " } 9
229230request_latency_count{path= " / home " } 9
230- request_latency_sum{path= " /home" } 3.398811496
231+ request_latency_sum{path= " / home " } 3.8517136149999995
232+ "
231233```
232234
233235## Exposing JMX Statistics
234236
235237Some JVM statistics can be exposed with:
236238
237239``` scala
238- implicit val registry = DefaultRegistry ()
240+ implicit val defaultRegistry = DefaultRegistry ()
239241```
240242``` scala
241243scala> import fs2 ._
@@ -246,34 +248,34 @@ import org.lyranthe.prometheus.client._
246248
247249scala> jmx.unsafeRegister
248250
249- scala> println(implicitly[Registry ])
250- # HELP jvm_threads JVM Thread Information
251- # TYPE jvm_threads gauge
252- jvm_threads{type = " non-daemon" } 11.0
253- jvm_threads{type = " daemon" } 4.0
254- # HELP jvm_start_time JVM Start Time
255- # TYPE jvm_start_time gauge
256- jvm_start_time 1.477244444947E9
251+ scala> println(implicitly[Registry ].outputText)
252+ # HELP jvm_classloader JVM Classloader statistics
253+ # TYPE jvm_classloader gauge
254+ jvm_classloader{classloader= " loaded" } 15479.0
255+ jvm_classloader{classloader= " total-loaded" } 15554.0
256+ jvm_classloader{classloader= " unloaded" } 75.0
257+ # HELP jvm_gc_stats JVM Garbage Collector Statistics
258+ # TYPE jvm_gc_stats gauge
259+ jvm_gc_stats{name= " PS Scavenge" ,type = " count" } 10.0
260+ jvm_gc_stats{name= " PS Scavenge" ,type = " time" } 0.217
261+ jvm_gc_stats{name= " PS MarkSweep" ,type = " count" } 5.0
262+ jvm_gc_stats{name= " PS MarkSweep" ,type = " time" } 0.406
257263# HELP jvm_memory_usage JVM Memory Usage
258264# TYPE jvm_memory_usage gauge
259- jvm_memory_usage{region= " heap" ,type = " committed" } 1.038614528E9
265+ jvm_memory_usage{region= " heap" ,type = " committed" } 1.042808832E9
260266jvm_memory_usage{region= " heap" ,type = " init" } 5.36870912E8
261267jvm_memory_usage{region= " heap" ,type = " max" } 1.431830528E9
262- jvm_memory_usage{region= " heap" ,type = " used" } 2.84849344E8
263- jvm_memory_usage{region= " non-heap" ,type = " committed" } 1.48914176E8
268+ jvm_memory_usage{region= " heap" ,type = " used" } 4.70523048E8
269+ jvm_memory_usage{region= " non-heap" ,type = " committed" } 1.67591936E8
264270jvm_memory_usage{region= " non-heap" ,type = " init" } 2555904.0
265271jvm_memory_usage{region= " non-heap" ,type = " max" } - 1.0
266- jvm_memory_usage{region= " non-heap" ,type = " used" } 1.47149728E8
267- # HELP jvm_gc_stats JVM Garbage Collector Statistics
268- # TYPE jvm_gc_stats gauge
269- jvm_gc_stats{name= " PS Scavenge" ,type = " count" } 9.0
270- jvm_gc_stats{name= " PS Scavenge" ,type = " time" } 0.176
271- jvm_gc_stats{name= " PS MarkSweep" ,type = " count" } 5.0
272- jvm_gc_stats{name= " PS MarkSweep" ,type = " time" } 0.325
273- # HELP jvm_classloader JVM Classloader statistics
274- # TYPE jvm_classloader gauge
275- jvm_classloader{classloader= " loaded" } 15230.0
276- jvm_classloader{classloader= " total-loaded" } 15305.0
277- jvm_classloader{classloader= " unloaded" } 75.0
272+ jvm_memory_usage{region= " non-heap" ,type = " used" } 1.65366072E8
273+ # HELP jvm_start_time JVM Start Time
274+ # TYPE jvm_start_time gauge
275+ jvm_start_time 1.477262878978E9
276+ # HELP jvm_threads JVM Thread Information
277+ # TYPE jvm_threads gauge
278+ jvm_threads{type = " non-daemon" } 11.0
279+ jvm_threads{type = " daemon" } 4.0
278280
279281```
0 commit comments