Skip to content

Commit 5e3e2d5

Browse files
committed
fix MetricNameDescriptor deprecation
Signed-off-by: Melissa Kilby <[email protected]>
1 parent 9b648c6 commit 5e3e2d5

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

Sources/Prometheus/MetricDescriptor.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ public struct MetricNameDescriptor {
2828
public let metricName: String
2929

3030
/// The required suffix describing the metric's unit (e.g., `total`).
31-
public let unitName: String
31+
public let unitName: String?
3232

3333
/// The required help text for the metric. If a non-empty string is provided, it will be emitted as a `# HELP` line in the exposition format.
34-
public let helpText: String
34+
public let helpText: String?
3535

3636
/// Creates a new ``MetricNameDescriptor`` that defines the components of a fully qualified Prometheus metric name.
3737
///

Sources/Prometheus/PrometheusCollectorRegistry.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ public final class PrometheusCollectorRegistry: Sendable {
239239
/// - Parameter descriptor: An ``MetricNameDescriptor`` that provides the fully qualified name for the metric.
240240
/// - Returns: A ``Counter`` that is registered with this ``PrometheusCollectorRegistry``
241241
public func makeCounter(descriptor: MetricNameDescriptor) -> Counter {
242-
return self._makeCounter(name: descriptor.name, labels: [], help: descriptor.helpText)
242+
return self._makeCounter(name: descriptor.name, labels: [], help: descriptor.helpText ?? "")
243243
}
244244

245245
/// Creates a new ``Counter`` collector or returns the already existing one with the same name.
@@ -283,7 +283,7 @@ public final class PrometheusCollectorRegistry: Sendable {
283283
/// what’s actually being measured in a Prometheus metric.
284284
/// - Returns: A ``Counter`` that is registered with this ``PrometheusCollectorRegistry``
285285
public func makeCounter(descriptor: MetricNameDescriptor, labels: [(String, String)]) -> Counter {
286-
return self._makeCounter(name: descriptor.name, labels: labels, help: descriptor.helpText)
286+
return self._makeCounter(name: descriptor.name, labels: labels, help: descriptor.helpText ?? "")
287287
}
288288

289289
/// Creates a new ``Gauge`` collector or returns the already existing one with the same name.
@@ -321,7 +321,7 @@ public final class PrometheusCollectorRegistry: Sendable {
321321
/// - Parameter descriptor: An ``MetricNameDescriptor`` that provides the fully qualified name for the metric.
322322
/// - Returns: A ``Gauge`` that is registered with this ``PrometheusCollectorRegistry``
323323
public func makeGauge(descriptor: MetricNameDescriptor) -> Gauge {
324-
return self._makeGauge(name: descriptor.name, labels: [], help: descriptor.helpText)
324+
return self._makeGauge(name: descriptor.name, labels: [], help: descriptor.helpText ?? "")
325325
}
326326

327327
/// Creates a new ``Gauge`` collector or returns the already existing one with the same name.
@@ -365,7 +365,7 @@ public final class PrometheusCollectorRegistry: Sendable {
365365
/// what’s actually being measured in a Prometheus metric.
366366
/// - Returns: A ``Gauge`` that is registered with this ``PrometheusCollectorRegistry``
367367
public func makeGauge(descriptor: MetricNameDescriptor, labels: [(String, String)]) -> Gauge {
368-
return self._makeGauge(name: descriptor.name, labels: labels, help: descriptor.helpText)
368+
return self._makeGauge(name: descriptor.name, labels: labels, help: descriptor.helpText ?? "")
369369
}
370370

371371
/// Creates a new ``DurationHistogram`` collector or returns the already existing one with the same name.
@@ -410,7 +410,7 @@ public final class PrometheusCollectorRegistry: Sendable {
410410
name: descriptor.name,
411411
labels: [],
412412
buckets: buckets,
413-
help: descriptor.helpText
413+
help: descriptor.helpText ?? ""
414414
)
415415
}
416416

@@ -485,7 +485,7 @@ public final class PrometheusCollectorRegistry: Sendable {
485485
name: descriptor.name,
486486
labels: labels,
487487
buckets: buckets,
488-
help: descriptor.helpText
488+
help: descriptor.helpText ?? ""
489489
)
490490
}
491491

@@ -531,7 +531,7 @@ public final class PrometheusCollectorRegistry: Sendable {
531531
name: descriptor.name,
532532
labels: [],
533533
buckets: buckets,
534-
help: descriptor.helpText
534+
help: descriptor.helpText ?? ""
535535
)
536536
}
537537

@@ -606,7 +606,7 @@ public final class PrometheusCollectorRegistry: Sendable {
606606
name: descriptor.name,
607607
labels: labels,
608608
buckets: buckets,
609-
help: descriptor.helpText
609+
help: descriptor.helpText ?? ""
610610
)
611611
}
612612

0 commit comments

Comments
 (0)