@@ -93,6 +93,18 @@ public final class PrometheusCollectorRegistry: Sendable {
93
93
}
94
94
}
95
95
96
+ /// Creates a new ``Counter`` collector or returns the already existing one with the same name,
97
+ /// based on the provided descriptor.
98
+ ///
99
+ /// When the ``PrometheusCollectorRegistry/emit(into:)`` is called, metrics from the
100
+ /// created ``Counter`` will be part of the export.
101
+ ///
102
+ /// - Parameter descriptor: An ``MetricNameDescriptor`` that provides the fully qualified name for the metric.
103
+ /// - Returns: A ``Counter`` that is registered with this ``PrometheusCollectorRegistry``
104
+ public func makeCounter( descriptor: MetricNameDescriptor ) -> Counter {
105
+ return self . makeCounter ( name: descriptor. name)
106
+ }
107
+
96
108
/// Creates a new ``Counter`` collector or returns the already existing one with the same name.
97
109
///
98
110
/// When the ``PrometheusCollectorRegistry/emit(into:)`` is called, metrics from the
@@ -150,6 +162,20 @@ public final class PrometheusCollectorRegistry: Sendable {
150
162
}
151
163
}
152
164
165
+ /// Creates a new ``Counter`` collector or returns the already existing one with the same name,
166
+ /// based on the provided descriptor.
167
+ ///
168
+ /// When the ``PrometheusCollectorRegistry/emit(into:)`` is called, metrics from the
169
+ /// created ``Counter`` will be part of the export.
170
+ ///
171
+ /// - Parameter descriptor: An ``MetricNameDescriptor`` that provides the fully qualified name for the metric.
172
+ /// - Parameter labels: Labels are sets of key-value pairs that allow us to characterize and organize
173
+ /// what’s actually being measured in a Prometheus metric.
174
+ /// - Returns: A ``Counter`` that is registered with this ``PrometheusCollectorRegistry``
175
+ public func makeCounter( descriptor: MetricNameDescriptor , labels: [ ( String , String ) ] ) -> Counter {
176
+ return self . makeCounter ( name: descriptor. name, labels: labels)
177
+ }
178
+
153
179
/// Creates a new ``Gauge`` collector or returns the already existing one with the same name.
154
180
///
155
181
/// When the ``PrometheusCollectorRegistry/emit(into:)`` is called, metrics from the
@@ -178,6 +204,18 @@ public final class PrometheusCollectorRegistry: Sendable {
178
204
}
179
205
}
180
206
207
+ /// Creates a new ``Gauge`` collector or returns the already existing one with the same name,
208
+ /// based on the provided descriptor.
209
+ ///
210
+ /// When the ``PrometheusCollectorRegistry/emit(into:)`` is called, metrics from the
211
+ /// created ``Gauge`` will be part of the export.
212
+ ///
213
+ /// - Parameter descriptor: An ``MetricNameDescriptor`` that provides the fully qualified name for the metric.
214
+ /// - Returns: A ``Gauge`` that is registered with this ``PrometheusCollectorRegistry``
215
+ public func makeGauge( descriptor: MetricNameDescriptor ) -> Gauge {
216
+ return self . makeGauge ( name: descriptor. name)
217
+ }
218
+
181
219
/// Creates a new ``Gauge`` collector or returns the already existing one with the same name.
182
220
///
183
221
/// When the ``PrometheusCollectorRegistry/emit(into:)`` is called, metrics from the
@@ -235,6 +273,20 @@ public final class PrometheusCollectorRegistry: Sendable {
235
273
}
236
274
}
237
275
276
+ /// Creates a new ``Gauge`` collector or returns the already existing one with the same name and labels,
277
+ /// based on the provided descriptor.
278
+ ///
279
+ /// When the ``PrometheusCollectorRegistry/emit(into:)`` is called, metrics from the
280
+ /// created ``Gauge`` will be part of the export.
281
+ ///
282
+ /// - Parameter descriptor: An ``MetricNameDescriptor`` that provides the fully qualified name for the metric.
283
+ /// - Parameter labels: Labels are sets of key-value pairs that allow us to characterize and organize
284
+ /// what’s actually being measured in a Prometheus metric.
285
+ /// - Returns: A ``Gauge`` that is registered with this ``PrometheusCollectorRegistry``
286
+ public func makeGauge( descriptor: MetricNameDescriptor , labels: [ ( String , String ) ] ) -> Gauge {
287
+ return self . makeGauge ( name: descriptor. name, labels: labels)
288
+ }
289
+
238
290
/// Creates a new ``DurationHistogram`` collector or returns the already existing one with the same name.
239
291
///
240
292
/// When the ``PrometheusCollectorRegistry/emit(into:)`` is called, metrics from the
@@ -264,6 +316,19 @@ public final class PrometheusCollectorRegistry: Sendable {
264
316
}
265
317
}
266
318
319
+ /// Creates a new ``DurationHistogram`` collector or returns the already existing one with the same name,
320
+ /// based on the provided descriptor.
321
+ ///
322
+ /// When the ``PrometheusCollectorRegistry/emit(into:)`` is called, metrics from the
323
+ /// created ``DurationHistogram`` will be part of the export.
324
+ ///
325
+ /// - Parameter descriptor: An ``MetricNameDescriptor`` that provides the fully qualified name for the metric.
326
+ /// - Parameter buckets: Define the buckets that shall be used within the ``DurationHistogram``
327
+ /// - Returns: A ``DurationHistogram`` that is registered with this ``PrometheusCollectorRegistry``
328
+ public func makeDurationHistogram( descriptor: MetricNameDescriptor , buckets: [ Duration ] ) -> DurationHistogram {
329
+ return self . makeDurationHistogram ( name: descriptor. name, buckets: buckets)
330
+ }
331
+
267
332
/// Creates a new ``DurationHistogram`` collector or returns the already existing one with the same name.
268
333
///
269
334
/// When the ``PrometheusCollectorRegistry/emit(into:)`` is called, metrics from the
@@ -338,6 +403,25 @@ public final class PrometheusCollectorRegistry: Sendable {
338
403
}
339
404
}
340
405
406
+ /// Creates a new ``DurationHistogram`` collector or returns the already existing one with the same name and labels,
407
+ /// based on the provided descriptor.
408
+ ///
409
+ /// When the ``PrometheusCollectorRegistry/emit(into:)`` is called, metrics from the
410
+ /// created ``DurationHistogram`` will be part of the export.
411
+ ///
412
+ /// - Parameter descriptor: An ``MetricNameDescriptor`` that provides the fully qualified name for the metric.
413
+ /// - Parameter labels: Labels are sets of key-value pairs that allow us to characterize and organize
414
+ /// what’s actually being measured in a Prometheus metric.
415
+ /// - Parameter buckets: Define the buckets that shall be used within the ``DurationHistogram``
416
+ /// - Returns: A ``DurationHistogram`` that is registered with this ``PrometheusCollectorRegistry``
417
+ public func makeDurationHistogram(
418
+ descriptor: MetricNameDescriptor ,
419
+ labels: [ ( String , String ) ] ,
420
+ buckets: [ Duration ]
421
+ ) -> DurationHistogram {
422
+ return self . makeDurationHistogram ( name: descriptor. name, labels: labels, buckets: buckets)
423
+ }
424
+
341
425
/// Creates a new ``ValueHistogram`` collector or returns the already existing one with the same name.
342
426
///
343
427
/// When the ``PrometheusCollectorRegistry/emit(into:)`` is called, metrics from the
@@ -362,6 +446,19 @@ public final class PrometheusCollectorRegistry: Sendable {
362
446
}
363
447
}
364
448
449
+ /// Creates a new ``ValueHistogram`` collector or returns the already existing one with the same name,
450
+ /// based on the provided descriptor.
451
+ ///
452
+ /// When the ``PrometheusCollectorRegistry/emit(into:)`` is called, metrics from the
453
+ /// created ``ValueHistogram`` will be part of the export.
454
+ ///
455
+ /// - Parameter descriptor: An ``MetricNameDescriptor`` that provides the fully qualified name for the metric.
456
+ /// - Parameter buckets: Define the buckets that shall be used within the ``ValueHistogram``
457
+ /// - Returns: A ``ValueHistogram`` that is registered with this ``PrometheusCollectorRegistry``
458
+ public func makeValueHistogram( descriptor: MetricNameDescriptor , buckets: [ Double ] ) -> ValueHistogram {
459
+ return self . makeValueHistogram ( name: descriptor. name, buckets: buckets)
460
+ }
461
+
365
462
/// Creates a new ``ValueHistogram`` collector or returns the already existing one with the same name.
366
463
///
367
464
/// When the ``PrometheusCollectorRegistry/emit(into:)`` is called, metrics from the
@@ -408,6 +505,27 @@ public final class PrometheusCollectorRegistry: Sendable {
408
505
}
409
506
}
410
507
508
+ /// Creates a new ``ValueHistogram`` collector or returns the already existing one with the same name and labels,
509
+ /// based on the provided descriptor.
510
+ ///
511
+ /// When the ``PrometheusCollectorRegistry/emit(into:)`` is called, metrics from the
512
+ /// created ``ValueHistogram`` will be part of the export.
513
+ ///
514
+ /// - Parameter descriptor: An ``MetricNameDescriptor`` that provides the fully qualified name for the metric.
515
+ /// - Parameter labels: Labels are sets of key-value pairs that allow us to characterize and organize
516
+ /// what’s actually being measured in a Prometheus metric.
517
+ /// - Parameter buckets: Define the buckets that shall be used within the ``ValueHistogram``
518
+ /// - Returns: A ``ValueHistogram`` that is registered with this ``PrometheusCollectorRegistry``
519
+ public func makeValueHistogram(
520
+ descriptor: MetricNameDescriptor ,
521
+ labels: [ ( String , String ) ] ,
522
+ buckets: [ Double ]
523
+ ) -> ValueHistogram {
524
+ return self . makeValueHistogram ( name: descriptor. name, labels: labels, buckets: buckets)
525
+ }
526
+
527
+ // MARK: - Histogram
528
+
411
529
// MARK: Destroying Metrics
412
530
413
531
/// Unregisters a ``Counter`` from the ``PrometheusCollectorRegistry``. This means that the provided ``Counter``
0 commit comments