packages feed

hs-opentelemetry-instrumentation-auto 0.1.0.0 → 0.1.0.1

raw patch · 3 files changed

+28/−14 lines, 3 filesPVP: minor bump suggested

API additions: PVP suggests at least a minor version bump

API changes (from Hackage documentation)

+ AutoInstrument.Internal.Config: instance Toml.Schema.FromValue.FromValue AutoInstrument.Internal.Config.TargetCon
+ AutoInstrument.Internal.Config: instance Toml.Schema.FromValue.FromValue AutoInstrument.Internal.Config.TargetType

Files

CHANGELOG.md view
@@ -1,5 +1,9 @@ # Revision history for auto-instrument +## 0.1.0.1 -- 2024-03-31++* Improved messaging for TOML parsing failures+ ## 0.1.0.0 -- YYYY-mm-dd  * First version. Released on an unsuspecting world.
hs-opentelemetry-instrumentation-auto.cabal view
@@ -1,6 +1,6 @@ cabal-version:      3.0 name:               hs-opentelemetry-instrumentation-auto-version:            0.1.0.0+version:            0.1.0.1 synopsis:           Plugin for instrumenting an application description:        A GHC plugin that auto-instruments an application for emitting open telementry tracing. license:            BSD-3-Clause@@ -17,6 +17,10 @@ tested-with:   GHC == 9.4.8   GHC == 9.6.2+bug-reports: https://github.com/aaronallen8455/opentelemetry-auto/issues+source-repository head+    type: git+    location: https://github.com/aaronallen8455/opentelemetry-auto  common warnings     ghc-options: -Wall
src/AutoInstrument/Internal/Config.hs view
@@ -18,6 +18,7 @@ import           Data.Maybe import           Data.Set (Set) import qualified Data.Set as S+import qualified Data.Text as T import qualified Data.Text.IO as T import           Data.Time import qualified System.Directory as Dir@@ -25,6 +26,7 @@ import qualified Text.Parsec as P import qualified Text.Parsec.Error as P import qualified Text.Parsec.String as P+import qualified Toml.Schema as Toml import qualified Toml.Schema.FromValue as Toml import qualified Toml @@ -101,19 +103,23 @@   fromValue = Toml.parseTableFromValue $ do     tag <- Toml.reqKey "type"     case tag of-      "constructor" -> do-        value <- Toml.reqKey "value"-        case P.parse (skipSpaces *> targetParser <* P.eof) "" value of-          Right target -> pure $ Constructor target-          Left err -> fail $ showParsecError err-      "constraints" -> do-        value <- Toml.reqKey "value"-        let parsePred v =-              case P.parse (skipSpaces *> targetParser <* P.eof) "" v of-                Right target -> pure target-                Left err -> fail $ showParsecError err-        Constraints . S.fromList <$> traverse parsePred value-      _ -> fail $ "Unrecognized targed type: " <> tag+      ConstructorType -> Constructor <$> Toml.reqKey "value"+      ConstraintsType -> Constraints . S.fromList <$> Toml.reqKey "value"++data TargetType = ConstructorType | ConstraintsType++instance Toml.FromValue TargetType where+  fromValue (Toml.Text' _ tag)+    | tag == "constructor" = pure ConstructorType+    | tag == "constraints" = pure ConstraintsType+  fromValue v = Toml.failAt (Toml.valueAnn v) "must be 'constructor' or 'constraints'"++instance Toml.FromValue TargetCon where+  fromValue (Toml.Text' a v) =+    case P.parse (skipSpaces *> targetParser <* P.eof) "" (T.unpack v) of+      Right target -> pure target+      Left err -> Toml.failAt a (showParsecError err)+  fromValue v = Toml.typeError "string" v  -- | Doesn't show the source location showParsecError :: P.ParseError -> String