Skip to content

Commit fb9f489

Browse files
incertumktoso
andauthored
new: add optional HELP line support (#130)
Co-authored-by: Konrad `ktoso` Malawski <[email protected]>
1 parent b546409 commit fb9f489

File tree

6 files changed

+658
-198
lines changed

6 files changed

+658
-198
lines changed

Sources/Prometheus/MetricDescriptor.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ 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.
34+
/// If the parameter is omitted or an empty string is passed, the `# HELP` line will not be generated for this metric.
3435
public let helpText: String?
3536

3637
/// Creates a new ``MetricNameDescriptor`` that defines the components of a fully qualified Prometheus metric name.
@@ -39,7 +40,8 @@ public struct MetricNameDescriptor {
3940
/// - Parameter subsystem: An optional subsystem to group related metrics within a namespace.
4041
/// - Parameter metricName: The required, descriptive base name of the metric.
4142
/// - Parameter unitName: An optional suffix describing the metric's unit (e.g., `total`).
42-
/// - Parameter helpText: Optional descriptive text for the metric.
43+
/// - 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.
44+
/// If the parameter is omitted or an empty string is passed, the `# HELP` line will not be generated for this metric.
4345
public init(
4446
namespace: String? = nil,
4547
subsystem: String? = nil,
@@ -55,7 +57,7 @@ public struct MetricNameDescriptor {
5557
self.helpText = helpText
5658
}
5759

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

0 commit comments

Comments
 (0)