Skip to content

Commit b186af2

Browse files
committed
new: add optional HELP line support
Signed-off-by: Melissa Kilby <[email protected]>
1 parent b546409 commit b186af2

File tree

6 files changed

+525
-198
lines changed

6 files changed

+525
-198
lines changed

Sources/Prometheus/MetricDescriptor.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public struct MetricNameDescriptor {
3030
/// An optional suffix describing the metric's unit (e.g., `total`).
3131
public let unitName: String?
3232

33-
/// Optional descriptive text for the metric.
33+
/// Optional help text for the metric. If a non-empty string is provided, it will be emitted as a `# HELP` line in the exposition format. If the parameter is omitted or an empty string is passed, the `# HELP` line will not be generated for this metric.
3434
public let helpText: String?
3535

3636
/// Creates a new ``MetricNameDescriptor`` that defines the components of a fully qualified Prometheus metric name.
@@ -39,7 +39,7 @@ public struct MetricNameDescriptor {
3939
/// - Parameter subsystem: An optional subsystem to group related metrics within a namespace.
4040
/// - Parameter metricName: The required, descriptive base name of the metric.
4141
/// - Parameter unitName: An optional suffix describing the metric's unit (e.g., `total`).
42-
/// - Parameter helpText: Optional descriptive text for the metric.
42+
/// - Parameter helpText: Optional help text for the metric. If a non-empty string is provided, it will be emitted as a `# HELP` line in the exposition format. If the parameter is omitted or an empty string is passed, the `# HELP` line will not be generated for this metric.
4343
public init(
4444
namespace: String? = nil,
4545
subsystem: String? = nil,
@@ -55,7 +55,7 @@ public struct MetricNameDescriptor {
5555
self.helpText = helpText
5656
}
5757

58-
/// The fully qualified metric name, joining non-empty components with underscores.
58+
/// The fully qualified metric name, joining non-empty components with underscores (e.g. `namespace_subsytem_metricName_unitName`).
5959
public var name: String {
6060
[namespace, subsystem, metricName, unitName]
6161
.compactMap { $0?.isEmpty == false ? $0 : nil }

0 commit comments

Comments
 (0)