@@ -14,7 +14,7 @@ public class PrometheusClient {
1414 ///
1515 /// - Returns: Newline seperated string with metrics for all Metric Trackers of this Prometheus instance
1616 public func getMetrics( _ done: @escaping ( String ) -> Void ) {
17- // prometheusQueue.async(flags: .barrier) {
17+ prometheusQueue. async ( flags: . barrier) {
1818 var list = [ String] ( )
1919 self . metrics. forEach { metric in
2020 metric. getMetric { str in
@@ -25,7 +25,7 @@ public class PrometheusClient {
2525 }
2626 }
2727 }
28- // }
28+ }
2929 }
3030
3131 // MARK: - Counter
@@ -48,7 +48,9 @@ public class PrometheusClient {
4848 withLabelType labelType: U . Type ) -> Counter < T , U >
4949 {
5050 let counter = Counter < T , U > ( name, helpText, initialValue, self )
51- self . metrics. append ( counter)
51+ prometheusQueue. async ( flags: . barrier) {
52+ self . metrics. append ( counter)
53+ }
5254 return counter
5355 }
5456
@@ -90,7 +92,9 @@ public class PrometheusClient {
9092 withLabelType labelType: U . Type ) -> Gauge < T , U >
9193 {
9294 let gauge = Gauge < T , U > ( name, helpText, initialValue, self )
93- self . metrics. append ( gauge)
95+ prometheusQueue. async ( flags: . barrier) {
96+ self . metrics. append ( gauge)
97+ }
9498 return gauge
9599 }
96100
@@ -132,7 +136,9 @@ public class PrometheusClient {
132136 labels: U . Type ) -> Histogram < T , U >
133137 {
134138 let histogram = Histogram < T , U > ( name, helpText, U ( ) , buckets, self )
135- self . metrics. append ( histogram)
139+ prometheusQueue. async ( flags: . barrier) {
140+ self . metrics. append ( histogram)
141+ }
136142 return histogram
137143 }
138144
@@ -174,7 +180,9 @@ public class PrometheusClient {
174180 labels: U . Type ) -> Summary < T , U >
175181 {
176182 let summary = Summary < T , U > ( name, helpText, U ( ) , quantiles, self )
177- metrics. append ( summary)
183+ prometheusQueue. async ( flags: . barrier) {
184+ self . metrics. append ( summary)
185+ }
178186 return summary
179187 }
180188
@@ -212,7 +220,9 @@ public class PrometheusClient {
212220 labelType: U . Type ) -> Info < U >
213221 {
214222 let info = Info < U > ( name, helpText, self )
215- self . metrics. append ( info)
223+ prometheusQueue. async ( flags: . barrier) {
224+ self . metrics. append ( info)
225+ }
216226 return info
217227 }
218228}
0 commit comments