@@ -42,12 +42,12 @@ public class Prometheus {
4242 ///
4343 /// - Returns: Counter instance
4444 public func createCounter< T: Numeric > (
45- forType: T . Type ,
45+ forType type : T . Type ,
4646 named name: String ,
4747 helpText: String ? = nil ,
4848 initialValue: T = 0 ) -> Counter < T , EmptyCodable >
4949 {
50- return self . createCounter ( forType: T . self , named: name, helpText: helpText, initialValue: initialValue, withLabelType: EmptyCodable . self)
50+ return self . createCounter ( forType: type , named: name, helpText: helpText, initialValue: initialValue, withLabelType: EmptyCodable . self)
5151 }
5252
5353 // MARK: - Gauge
@@ -84,12 +84,77 @@ public class Prometheus {
8484 ///
8585 /// - Returns: Gauge instance
8686 public func createGauge< T: Numeric > (
87- forType: T . Type ,
87+ forType type : T . Type ,
8888 named name: String ,
8989 helpText: String ? = nil ,
9090 initialValue: T = 0 ) -> Gauge < T , EmptyCodable >
9191 {
92- return self . createGauge ( forType: T . self, named: name, helpText: helpText, initialValue: initialValue, withLabelType: EmptyCodable . self)
92+ return self . createGauge ( forType: type, named: name, helpText: helpText, initialValue: initialValue, withLabelType: EmptyCodable . self)
93+ }
94+
95+ // MARK: - Histogram
96+
97+ /// Creates a histogram with the given values
98+ ///
99+ /// - Parameters:
100+ /// - type: The type the histogram will observe
101+ /// - name: Name of the histogram
102+ /// - helpText: Help text for the histogram. Usually a short description
103+ /// - buckets: Buckets to divide values over
104+ /// - labels: Labels to give this Histogram. Can be left out to default to no labels
105+ ///
106+ /// - Returns: Histogram instance
107+ public func createHistogram< T: Numeric , U: HistogramLabels > (
108+ forType type: T . Type ,
109+ named name: String ,
110+ helpText: String ? = nil ,
111+ buckets: [ Double ] = defaultBuckets,
112+ labels: U ) -> Histogram < T , U >
113+ {
114+ let histogram = Histogram < T , U > ( name, helpText, labels, buckets)
115+ self . metrics. append ( histogram)
116+ return histogram
117+ }
118+
119+ /// Creates a histogram with the given values
120+ ///
121+ /// - Parameters:
122+ /// - type: The type the histogram will observe
123+ /// - name: Name of the histogram
124+ /// - helpText: Help text for the histogram. Usually a short description
125+ /// - buckets: Buckets to divide values over
126+ ///
127+ /// - Returns: Histogram instance
128+ public func createHistogram< T: Numeric > (
129+ forType type: T . Type ,
130+ named name: String ,
131+ helpText: String ? = nil ,
132+ buckets: [ Double ] = defaultBuckets) -> Histogram < T , EmptyHistogramCodable >
133+ {
134+ return self . createHistogram ( forType: type, named: name, helpText: helpText, buckets: buckets, labels: EmptyHistogramCodable ( ) )
135+ }
136+
137+ // MARK: - Summary
138+
139+ public func createSummary< T: Numeric , U: SummaryLabels > (
140+ forType type: T . Type ,
141+ named name: String ,
142+ helpText: String ? = nil ,
143+ quantiles: [ Double ] = defaultQuantiles,
144+ labels: U ) -> Summary < T , U >
145+ {
146+ let summary = Summary < T , U > ( name, helpText, quantiles, labels)
147+ metrics. append ( summary)
148+ return summary
149+ }
150+
151+ public func createSummary< T: Numeric > (
152+ forType type: T . Type ,
153+ named name: String ,
154+ helpText: String ? = nil ,
155+ quantiles: [ Double ] = defaultQuantiles) -> Summary < T , EmptySummaryCodable >
156+ {
157+ return self . createSummary ( forType: type, named: name, helpText: helpText, quantiles: quantiles, labels: EmptySummaryCodable ( ) )
93158 }
94159
95160 /// Creates prometheus formatted metrics
0 commit comments