swift-server / swift-prometheus

Prometheus client library for Swift
https://swiftpackageindex.com/swift-server/swift-prometheus
Apache License 2.0
145 stars 31 forks source link

Add dimension name sanitizer #65

Closed vojtarylko closed 2 years ago

vojtarylko commented 2 years ago

Feature Request

Add dimension name sanitizer along already existing LabelSanitizer.

Motivation Behind Feature

Dimension names are limited by Prometheus:

may contain ASCII letters, numbers, as well as underscores. They must match the regex [a-zA-Z_][a-zA-Z0-9_]*

names beginning with __ are reserved for internal use.

Note: Dimension values may contain any Unicode characters. Note: The metric name (sanitized by LabelSanitizer) follows different rules ([a-zA-Z_:][a-zA-Z0-9_:]*).

The reasoning behind this feature is same as in the https://github.com/MrLotU/SwiftPrometheus/issues/29.

ktoso commented 2 years ago

Would you send in a PR for this @vojtarylko ? Thanks!