@@ -6,10 +6,7 @@ import Dispatch
66/// Prometheus Summary metric
77///
88/// See https://prometheus.io/docs/concepts/metric_types/#summary
9- public class PromSummary < NumType: DoubleRepresentable > : PromMetric , PrometheusHandled {
10- /// Prometheus instance that created this Summary
11- internal weak var prometheus : PrometheusClient ?
12-
9+ public class PromSummary < NumType: DoubleRepresentable > : PromMetric {
1310 /// Name of this Summary, required
1411 public let name : String
1512 /// Help text of this Summary, optional
@@ -49,17 +46,15 @@ public class PromSummary<NumType: DoubleRepresentable>: PromMetric, PrometheusHa
4946 /// - capacity: Number of values to keep for calculating quantiles
5047 /// - quantiles: Quantiles to use for the Summary
5148 /// - p: Prometheus instance creating this Summary
52- internal init ( _ name: String , _ help: String ? = nil , _ capacity: Int = Prometheus . defaultSummaryCapacity, _ quantiles: [ Double ] = Prometheus . defaultQuantiles, _ p : PrometheusClient ) {
49+ internal init ( _ name: String , _ help: String ? = nil , _ capacity: Int = Prometheus . defaultSummaryCapacity, _ quantiles: [ Double ] = Prometheus . defaultQuantiles) {
5350 self . name = name
5451 self . help = help
5552
56- self . prometheus = p
57-
5853 self . displayUnit = nil
5954
60- self . sum = . init( " \( self . name) _sum " , nil , 0 , p )
55+ self . sum = . init( " \( self . name) _sum " , nil , 0 )
6156
62- self . count = . init( " \( self . name) _count " , nil , 0 , p )
57+ self . count = . init( " \( self . name) _count " , nil , 0 )
6358
6459 self . values = CircularBuffer ( initialCapacity: capacity)
6560
@@ -197,10 +192,7 @@ public class PromSummary<NumType: DoubleRepresentable>: PromMetric, PrometheusHa
197192 """ )
198193 return summary
199194 }
200- guard let prometheus = prometheus else {
201- fatalError ( " Lingering Summary " )
202- }
203- let newSummary = PromSummary ( self . name, self . help, self . capacity, self . quantiles, prometheus)
195+ let newSummary = PromSummary ( self . name, self . help, self . capacity, self . quantiles)
204196 self . subSummaries [ labels] = newSummary
205197 return newSummary
206198 }
0 commit comments