@@ -236,65 +236,67 @@ private struct StringCodingKey: CodingKey {
236236
237237
238238/// Helper for dimensions
239- private struct DimensionLabels : MetricLabels {
239+ public struct DimensionLabels : MetricLabels {
240240 let dimensions : [ ( String , String ) ]
241241
242- init ( ) {
242+ public init ( ) {
243243 self . dimensions = [ ]
244244 }
245245
246- init ( _ dimensions: [ ( String , String ) ] ) {
246+ public init ( _ dimensions: [ ( String , String ) ] ) {
247247 self . dimensions = dimensions
248248 }
249249
250- func encode( to encoder: Encoder ) throws {
250+ public func encode( to encoder: Encoder ) throws {
251251 var container = encoder. container ( keyedBy: StringCodingKey . self)
252252 try self . dimensions. forEach {
253253 try container. encode ( $0. 1 , forKey: . init( $0. 0 ) )
254254 }
255255 }
256256
257- func hash( into hasher: inout Hasher ) {
257+ public func hash( into hasher: inout Hasher ) {
258258 hasher. combine ( dimensions. map { " \( $0. 0 ) - \( $0. 1 ) " } )
259259 }
260260
261261 fileprivate var identifiers : String {
262262 return dimensions. map { $0. 0 } . joined ( separator: " - " )
263263 }
264264
265- static func == ( lhs: DimensionLabels , rhs: DimensionLabels ) -> Bool {
265+ public static func == ( lhs: DimensionLabels , rhs: DimensionLabels ) -> Bool {
266266 return lhs. dimensions. map { " \( $0. 0 ) - \( $0. 1 ) " } == rhs. dimensions. map { " \( $0. 0 ) - \( $0. 1 ) " }
267267 }
268268}
269269
270270/// Helper for dimensions
271- private struct DimensionHistogramLabels : HistogramLabels {
271+ /// swift-metrics api doesn't allow setting buckets explicitly.
272+ /// If default buckets don't fit, this Labels implementation is a nice default to create Prometheus metric types wtih
273+ public struct DimensionHistogramLabels : HistogramLabels {
272274 /// Bucket
273- var le : String
275+ public var le : String
274276 /// Dimensions
275277 let dimensions : [ ( String , String ) ]
276278
277279 /// Empty init
278- init ( ) {
280+ public init ( ) {
279281 self . le = " "
280282 self . dimensions = [ ]
281283 }
282284
283285 /// Init with dimensions
284- init ( _ dimensions: [ ( String , String ) ] ) {
286+ public init ( _ dimensions: [ ( String , String ) ] ) {
285287 self . le = " "
286288 self . dimensions = dimensions
287289 }
288290
289- func encode( to encoder: Encoder ) throws {
291+ public func encode( to encoder: Encoder ) throws {
290292 var container = encoder. container ( keyedBy: StringCodingKey . self)
291293 try self . dimensions. forEach {
292294 try container. encode ( $0. 1 , forKey: . init( $0. 0 ) )
293295 }
294296 try container. encode ( le, forKey: . init( " le " ) )
295297 }
296298
297- func hash( into hasher: inout Hasher ) {
299+ public func hash( into hasher: inout Hasher ) {
298300 hasher. combine ( dimensions. map { " \( $0. 0 ) - \( $0. 1 ) " } )
299301 hasher. combine ( le)
300302 }
@@ -303,39 +305,39 @@ private struct DimensionHistogramLabels: HistogramLabels {
303305 return dimensions. map { $0. 0 } . joined ( separator: " - " )
304306 }
305307
306- static func == ( lhs: DimensionHistogramLabels , rhs: DimensionHistogramLabels ) -> Bool {
308+ public static func == ( lhs: DimensionHistogramLabels , rhs: DimensionHistogramLabels ) -> Bool {
307309 return lhs. dimensions. map { " \( $0. 0 ) - \( $0. 1 ) " } == rhs. dimensions. map { " \( $0. 0 ) - \( $0. 1 ) " } && rhs. le == lhs. le
308310 }
309311}
310312
311313/// Helper for dimensions
312- private struct DimensionSummaryLabels : SummaryLabels {
314+ public struct DimensionSummaryLabels : SummaryLabels {
313315 /// Quantile
314- var quantile : String
316+ public var quantile : String
315317 /// Dimensions
316318 let dimensions : [ ( String , String ) ]
317319
318320 /// Empty init
319- init ( ) {
321+ public init ( ) {
320322 self . quantile = " "
321323 self . dimensions = [ ]
322324 }
323325
324326 /// Init with dimensions
325- init ( _ dimensions: [ ( String , String ) ] ) {
327+ public init ( _ dimensions: [ ( String , String ) ] ) {
326328 self . quantile = " "
327329 self . dimensions = dimensions
328330 }
329331
330- func encode( to encoder: Encoder ) throws {
332+ public func encode( to encoder: Encoder ) throws {
331333 var container = encoder. container ( keyedBy: StringCodingKey . self)
332334 try self . dimensions. forEach {
333335 try container. encode ( $0. 1 , forKey: . init( $0. 0 ) )
334336 }
335337 try container. encode ( quantile, forKey: . init( " quantile " ) )
336338 }
337339
338- func hash( into hasher: inout Hasher ) {
340+ public func hash( into hasher: inout Hasher ) {
339341 hasher. combine ( dimensions. map { " \( $0. 0 ) - \( $0. 1 ) " } )
340342 hasher. combine ( quantile)
341343 }
@@ -344,7 +346,7 @@ private struct DimensionSummaryLabels: SummaryLabels {
344346 return dimensions. map { $0. 0 } . joined ( separator: " - " )
345347 }
346348
347- static func == ( lhs: DimensionSummaryLabels , rhs: DimensionSummaryLabels ) -> Bool {
349+ public static func == ( lhs: DimensionSummaryLabels , rhs: DimensionSummaryLabels ) -> Bool {
348350 return lhs. dimensions. map { " \( $0. 0 ) - \( $0. 1 ) " } == rhs. dimensions. map { " \( $0. 0 ) - \( $0. 1 ) " } && rhs. quantile == lhs. quantile
349351 }
350352}
0 commit comments