core-telemetry 0.2.6.1 → 0.2.7.0
raw patch · 2 files changed
+32/−3 lines, 2 filesdep ~core-programPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: core-program
API changes (from Hackage documentation)
+ Core.Telemetry.Observability: setSpanName :: Label -> Program τ ()
Files
core-telemetry.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack name: core-telemetry-version: 0.2.6.1+version: 0.2.7.0 synopsis: Advanced telemetry description: This is part of a library to help build command-line programs, both tools and longer-running daemons.@@ -52,7 +52,7 @@ base >=4.11 && <5 , bytestring , core-data >=0.3.8.0- , core-program >=0.6.0.0+ , core-program >=0.6.1 , core-text >=0.3.7.1 , exceptions , http-streams
lib/Core/Telemetry/Observability.hs view
@@ -152,6 +152,7 @@ Label, encloseSpan, setStartTime,+ setSpanName, -- * Creating telemetry MetricValue,@@ -417,7 +418,7 @@ Begin a span. You need to call this from within the context of a trace, which is established-either by calling `beginTrace` or `usingTrace` somewhere above this point in+either by calling 'beginTrace' or 'usingTrace' somewhere above this point in the program. You can nest spans as you make your way through your program, which means each@@ -426,6 +427,10 @@ of events and to display them as a nested tree correspoding to your program flow. +By convention the name of a span is the name of the function (method, handler,+action, ...) you've just entered. Additional metadata can be added to the span+using the 'telemetry' function.+ The current time will be noted when entering the 'Program' this span encloses, and its duration recorded when the sub @Program@ exits. Start time, duration, the unique identifier of the span (generated for you), the identifier of the@@ -740,6 +745,8 @@ span are recorded automatically when calling 'encloseSpan'. Observabilty tools are designed to be used live; traces and spans should be created in real time in your code.++@since 0.1.6 -} setStartTime :: Time -> Program τ () setStartTime time = do@@ -751,6 +758,28 @@ modifyMVar_ v (\datum -> pure datum{spanTimeFrom = time})++{- |+Override the name of the current span.++Under normal circumstances this shouldn't be necessary. The label specified+when you call 'encloseSpan' will be used to name the span when it is sent to+the telemetry channel. If, however, the span you are in was created+automatically and the circumstances you find yourself in require a different+name, you can use this function to change it.++@since 0.2.7+-}+setSpanName :: Label -> Program τ ()+setSpanName label = do+ context <- getContext++ liftIO $ do+ -- get the map out+ let v = currentDatumFrom context+ modifyMVar_+ v+ (\datum -> pure datum{spanNameFrom = label}) {- | Reset the accumulated metadata metrics to the emtpy set.