swift-server / swift-prometheus

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

Sanitize Dimensions #68

Closed 0xTim closed 2 years ago

0xTim commented 2 years ago

Sanitize dimensions to avoid scraping from breaking. Resolves #65 and #38

Checklist

Motivation and Context

If dimensions aren't sanitized then Prometheus breaks with errors like

error while linting: text format parsing error in line 9: expected '=' after label name, found '-'

Description

Run dimensions through a sanitizer. Uses a new DimensionsSanitizer as uppercase ASCII is allowed. (It looks like regular labels should allow uppercase as well but I didn't want to change that).

Also split out sanitiser types into their own files