Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package ghc-prometheus for openSUSE:Factory checked in at 2022-02-11 23:09:28 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/ghc-prometheus (Old) and /work/SRC/openSUSE:Factory/.ghc-prometheus.new.1956 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ghc-prometheus" Fri Feb 11 23:09:28 2022 rev:2 rq:953513 version:2.2.3 Changes: -------- --- /work/SRC/openSUSE:Factory/ghc-prometheus/ghc-prometheus.changes 2021-05-05 20:40:44.666721895 +0200 +++ /work/SRC/openSUSE:Factory/.ghc-prometheus.new.1956/ghc-prometheus.changes 2022-02-11 23:11:25.815296644 +0100 @@ -1,0 +2,6 @@ +Wed Jan 12 16:45:06 UTC 2022 - Peter Simons <[email protected]> + +- Update prometheus to version 2.2.3. + Upstream does not provide a change log file. + +------------------------------------------------------------------- Old: ---- prometheus-2.2.2.tar.gz New: ---- prometheus-2.2.3.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ghc-prometheus.spec ++++++ --- /var/tmp/diff_new_pack.M2tN9k/_old 2022-02-11 23:11:26.155297627 +0100 +++ /var/tmp/diff_new_pack.M2tN9k/_new 2022-02-11 23:11:26.163297651 +0100 @@ -1,7 +1,7 @@ # # spec file for package ghc-prometheus # -# Copyright (c) 2021 SUSE LLC +# Copyright (c) 2022 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -18,7 +18,7 @@ %global pkg_name prometheus Name: ghc-%{pkg_name} -Version: 2.2.2 +Version: 2.2.3 Release: 0 Summary: Prometheus Haskell Client License: BSD-3-Clause ++++++ prometheus-2.2.2.tar.gz -> prometheus-2.2.3.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prometheus-2.2.2/README.md new/prometheus-2.2.3/README.md --- old/prometheus-2.2.2/README.md 2020-07-20 19:38:36.000000000 +0200 +++ new/prometheus-2.2.3/README.md 2022-01-12 17:42:24.000000000 +0100 @@ -69,4 +69,4 @@ - [ ] Encode name and labels on register. - [x] Implement ReaderT for Concurrent Registry. - [x] Library documentation and example. -- [ ] [Name and label validation](http://prometheus.io/docs/concepts/data_model/#metric-names-and-labels) +- [x] [Name and label validation](http://prometheus.io/docs/concepts/data_model/#metric-names-and-labels) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prometheus-2.2.2/prometheus.cabal new/prometheus-2.2.3/prometheus.cabal --- old/prometheus-2.2.2/prometheus.cabal 2020-08-02 02:13:00.000000000 +0200 +++ new/prometheus-2.2.3/prometheus.cabal 2022-01-12 17:42:24.000000000 +0100 @@ -1,5 +1,5 @@ name: prometheus -version: 2.2.2 +version: 2.2.3 synopsis: Prometheus Haskell Client homepage: http://github.com/bitnomial/prometheus bug-reports: http://github.com/bitnomial/prometheus/issues @@ -84,7 +84,7 @@ build-depends: base >= 4.9 && < 5 , atomic-primops >= 0.8 && < 0.9 - , bytestring >= 0.10 && < 0.11 + , bytestring >= 0.10 && < 0.12 , containers >= 0.5 && < 0.7 , http-client >= 0.4 && < 0.8 , http-client-tls >= 0.3 && < 0.4 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/prometheus-2.2.2/src/System/Metrics/Prometheus/MetricId.hs new/prometheus-2.2.3/src/System/Metrics/Prometheus/MetricId.hs --- old/prometheus-2.2.2/src/System/Metrics/Prometheus/MetricId.hs 2020-07-20 19:38:36.000000000 +0200 +++ new/prometheus-2.2.3/src/System/Metrics/Prometheus/MetricId.hs 2022-01-12 17:42:24.000000000 +0100 @@ -1,17 +1,25 @@ +{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} module System.Metrics.Prometheus.MetricId where +import Data.Char (isDigit) +import Data.Bifunctor (first) import Data.Map (Map) import qualified Data.Map as Map import Data.Monoid (Monoid) import Data.Semigroup (Semigroup) -import Data.String (IsString) +import Data.String (IsString(..)) import Data.Text (Text) +import qualified Data.Text as Text import Prelude hiding (null) +-- | Construct with 'makeName' to ensure that names use only valid characters +newtype Name = Name { unName :: Text } deriving (Show, Eq, Ord, Monoid, Semigroup) + +instance IsString Name where + fromString = makeName . Text.pack -newtype Name = Name { unName :: Text } deriving (Show, Eq, Ord, IsString, Monoid, Semigroup) newtype Labels = Labels { unLabels :: Map Text Text } deriving (Show, Eq, Ord, Monoid, Semigroup) @@ -23,11 +31,11 @@ addLabel :: Text -> Text -> Labels -> Labels -addLabel key val = Labels . Map.insert key val . unLabels +addLabel key val = Labels . Map.insert (makeValid key) val . unLabels fromList :: [(Text, Text)] -> Labels -fromList = Labels . Map.fromList +fromList = Labels . Map.fromList . map (first makeValid) toList :: Labels -> [(Text, Text)] @@ -36,3 +44,22 @@ null :: Labels -> Bool null = Map.null . unLabels + + +-- | Make the input match the regex @[a-zA-Z_][a-zA-Z0-9_]@ which +-- defines valid metric and label names, according to +-- <https://prometheus.io/docs/concepts/data_model/#metric-names-and-labels> +-- Replace invalid characters with @_@ and add a leading @_@ if the +-- first character is only valid as a later character. +makeValid :: Text -> Text +makeValid "" = "_" +makeValid txt = prefix_ <> Text.map (\c -> if allowedChar c then c else '_' ) txt + where + prefix_ = if isDigit (Text.head txt) then "_" else "" + allowedChar :: Char -> Bool + allowedChar c = (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || isDigit c || c == '_' + + +-- | Construct a 'Name', replacing disallowed characters. +makeName :: Text -> Name +makeName = Name . makeValid
