diff --git a/lib/Servant/Ekg/Internal.hs b/lib/Servant/Ekg/Internal.hs index 4d5236e..be2422a 100644 --- a/lib/Servant/Ekg/Internal.hs +++ b/lib/Servant/Ekg/Internal.hs @@ -13,7 +13,7 @@ import Data.Monoid import Data.Text (Text) import qualified Data.Text as T import qualified Data.Text.Encoding as T -import Data.Time.Clock +import GHC.Clock (getMonotonicTime) import GHC.Generics (Generic) import Network.HTTP.Types (Method, Status (..)) import Network.Wai (Middleware, responseStatus) @@ -58,12 +58,14 @@ countResponseCodes (c2XX, c4XX, c5XX, cXXX) application request respond = responseTimeDistribution :: Distribution.Distribution -> Middleware responseTimeDistribution dist application request respond = - bracket getCurrentTime stop $ const $ application request respond + bracket getMonotonicTime stop $ const $ application request respond where stop t1 = do - t2 <- getCurrentTime - let dt = diffUTCTime t2 t1 - Distribution.add dist $ fromRational $ (*1000) $ toRational dt + t2 <- getMonotonicTime + let + dt = t2 - t1 + milliseconds = dt * 1000 + Distribution.add dist milliseconds initializeMeters :: Store -> APIEndpoint -> IO Meters initializeMeters store APIEndpoint{..} = do diff --git a/servant-ekg.cabal b/servant-ekg.cabal index e9402bb..4cb5d8b 100644 --- a/servant-ekg.cabal +++ b/servant-ekg.cabal @@ -31,7 +31,6 @@ library , hashable >=1.2.7.0 && <1.4 , servant >=0.14 && <0.19 , text >=1.2.3.0 && <1.3 - , time >=1.6.0.1 && <1.12 , unordered-containers >=0.2.9.0 && <0.3 , wai >=3.2.0 && <3.3