packages feed

opentracing-wai 0.1.0.0 → 0.2.0

raw patch · 3 files changed

+60/−5 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Network.Wai.Middleware.OpenTracing: defaultOperationName :: OperationName
+ Network.Wai.Middleware.OpenTracing: type OperationName = Request -> Text
+ Network.Wai.Middleware.OpenTracing: withOperationName :: HasCarrier Headers p => Tracer -> Propagation p -> OperationName -> TracedApplication -> Application

Files

CHANGELOG.md view
@@ -1,3 +1,13 @@-* 0.1.0.0 (2012-04-20)+* 0.2.0 (2021-06-03) -After years of friendly reminders, a zero version gets finally released =]+  - Drop support for GHC 8.0 (#35)+  - Add support for GHC 9.0 (#36)+  - Replace the unmaintained `thrift` package with `pinch` (#34)+  - wai: Better default operation name, and allow customising it (#33, #37)++  The major version is bumped because the packages won't compile with GHC 8.0+  anymore.++* 0.1.0.0 (2021-04-20)++  After years of friendly reminders, a zero version gets finally released =]
Network/Wai/Middleware/OpenTracing.hs view
@@ -5,13 +5,17 @@  module Network.Wai.Middleware.OpenTracing     ( TracedApplication+    , OperationName     , opentracing+    , withOperationName+    , defaultOperationName     ) where  import           Control.Lens            (over, set, view) import           Data.Maybe import           Data.Semigroup+import           Data.Text               (Text) import qualified Data.Text               as Text import           Data.Text.Encoding      (decodeUtf8) import           Network.Wai@@ -21,17 +25,52 @@ import           Prelude                 hiding (span)  +-- | A 'TracedApplication' is a WAI 'Application' with an 'ActiveSpan`.+--+-- Expanded:+--+-- @+-- type TracedApplication =+--     ActiveSpan -> Request -> (Response -> IO ResponseReceived) -> IO ResponseReceived+-- @ type TracedApplication = ActiveSpan -> Application +-- | The operation name is, basically, the name of the span.+--+-- This is typically determined from the request in some way, see+-- 'defaultOperationName'.+--+-- @since 0.2.0+type OperationName = Request -> Text++-- | Middleware to enable tracing for a WAI application.+--+-- This uses the 'defaultOperationName'. opentracing     :: HasCarrier Headers p     => Tracer     -> Propagation        p     -> TracedApplication     -> Application-opentracing t p app req respond = do+opentracing t p app req respond =+    withOperationName t p defaultOperationName app req respond++-- | Customise the tracing middleware with an 'OperationName'.+--+-- It is intended to import this module qualified for legibility+-- (@OpenTracing.withOperationName@).+--+-- @since 0.2.0+withOperationName+    :: HasCarrier Headers p+    => Tracer+    -> Propagation        p+    -> OperationName+    -> TracedApplication+    -> Application+withOperationName t p opname app req respond = do     let ctx = Propagation.extract p (requestHeaders req)-    let opt = let name = Text.intercalate "/" (pathInfo req)+    let opt = let name = opname req                   refs = (\x -> set refPropagated x mempty)                        . maybeToList . fmap ChildOf $ ctx                in set spanOptSampled (view ctxSampled <$> ctx)@@ -51,3 +90,9 @@     url = "http" <> if isSecure req then "s" else mempty <> "://"        <> fromMaybe "localhost" (requestHeaderHost req)        <> rawPathInfo req <> rawQueryString req++-- | The default 'OperationName' is the @pathInfo@ of the request.+--+-- @since 0.2.0+defaultOperationName :: OperationName+defaultOperationName req = Text.cons '/' (Text.intercalate "/" (pathInfo req))
opentracing-wai.cabal view
@@ -1,7 +1,7 @@ cabal-version: 2.2  name:           opentracing-wai-version:        0.1.0.0+version:        0.2.0 synopsis:       Middleware adding OpenTracing tracing for WAI applications homepage:       https://github.com/kim/opentracing bug-reports:    https://github.com/kim/opentracing/issues