packages feed

core-telemetry 0.1.7.3 → 0.1.8.1

raw patch · 3 files changed

+33/−5 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Core.Telemetry.Observability: clearMetrics :: Program τ ()
+ Core.Telemetry.Observability: instance Core.Telemetry.Observability.Telemetry GHC.Word.Word32
+ Core.Telemetry.Observability: instance Core.Telemetry.Observability.Telemetry GHC.Word.Word64

Files

core-telemetry.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack  name:           core-telemetry-version:        0.1.7.3+version:        0.1.8.1 synopsis:       Advanced telemetry description:    This is part of a library to help build command-line programs, both tools and                 longer-running daemons.@@ -18,12 +18,12 @@                 .                 See "Core.Telemetry.Observability" to get started. category:       System-stability:      experimental+stability:      provisional homepage:       https://github.com/aesiniath/unbeliever#readme bug-reports:    https://github.com/aesiniath/unbeliever/issues author:         Andrew Cowie <istathar@gmail.com> maintainer:     Andrew Cowie <istathar@gmail.com>-copyright:      © 2021 Athae Eredh Siniath and Others+copyright:      © 2021-2022 Athae Eredh Siniath and Others license:        MIT license-file:   LICENSE build-type:     Simple
lib/Core/Telemetry/Honeycomb.hs view
@@ -186,7 +186,7 @@          meta5 = case serviceNameFrom datum of             Nothing -> meta4-            Just service -> insertKeyValue "service_name" (JsonString service) meta4+            Just service -> insertKeyValue "service.name" (JsonString service) meta4          meta6 = case durationFrom datum of             Nothing -> meta5
lib/Core/Telemetry/Observability.hs view
@@ -155,12 +155,13 @@      -- * Events     sendEvent,+    clearMetrics, ) where  import Control.Concurrent.MVar (modifyMVar_, newMVar, readMVar) import Control.Concurrent.STM (atomically) import Control.Concurrent.STM.TQueue (writeTQueue)-import Core.Data.Structures (Map, insertKeyValue)+import Core.Data.Structures (Map, emptyMap, insertKeyValue) import Core.Encoding.Json import Core.Program.Arguments import Core.Program.Context@@ -180,6 +181,7 @@ import qualified Data.Text.Lazy as U (Text) import Data.UUID (UUID, toWords) import Data.UUID.V1 (nextUUID)+import Data.Word (Word32, Word64)  {- | A telemetry value that can be sent over the wire. This is a wrapper around@@ -236,6 +238,12 @@ instance Telemetry Int64 where     metric k v = MetricValue (JsonKey k) (JsonNumber (fromIntegral v)) +instance Telemetry Word32 where+    metric k v = MetricValue (JsonKey k) (JsonNumber (fromIntegral v))++instance Telemetry Word64 where+    metric k v = MetricValue (JsonKey k) (JsonNumber (fromIntegral v))+ instance Telemetry Integer where     metric k v = MetricValue (JsonKey k) (JsonNumber (fromInteger v)) @@ -668,3 +676,23 @@         modifyMVar_             v             (\datum -> pure datum{spanTimeFrom = time})++{- |+Reset the accumulated metadata metrics to the emtpy set.++This isn't something you'd need in normal circumstances, as inheriting+contextual metrics from surrounding code is usually what you want. But if you+have a significant change of setting then clearing the attached metadata may+be appropriate; after all, observability tools visualizing a trace will show+you the context an event was encountered in.+-}+clearMetrics :: Program τ ()+clearMetrics = do+    context <- getContext++    liftIO $ do+        -- get the map out+        let v = currentDatumFrom context+        modifyMVar_+            v+            (\datum -> pure datum{attachedMetadataFrom = emptyMap})