packages feed

ekg-elasticsearch 0.3.1.1 → 0.4.0.0

raw patch · 4 files changed

+32/−18 lines, 4 filesdep +data-default-classdep +reqdep −wreqdep ~basedep ~timePVP ok

version bump matches the API change (PVP)

Dependencies added: data-default-class, req

Dependencies removed: wreq

Dependency ranges changed: base, time

API changes (from Hackage documentation)

- System.Metrics.Json: instance Network.Wreq.Internal.Types.Postable System.Metrics.Json.BulkRequest
+ System.Metrics.Json: bulkRequestBody :: BulkRequest -> ByteString

Files

CHANGES.md view
@@ -1,7 +1,13 @@+## 0.4.0.0 (2017-12-20)++ * Use req instead of wreq. Thanks to David Smith+ * Relax constraints to work with GHC-8.2.x / LTS-10.x. Thanks to Kris Jenkins+ * Better formatting or README. Thanks to Brady Ouren+  ## 0.3.1.1 (2017-07-13)    * Error handling. Thanks to Kris Jenkins. -## 0.2.0.0 (2017-04-13)+## 0.3.0.0 (2017-04-13)   * Initial release.
System/Metrics/Json.hs view
@@ -15,6 +15,7 @@       -- ** Conversion functions     , sampleToJson     , valueToJson+    , bulkRequestBody        -- ** Generated Lenses     , beat, timestamp, beatTags, ekg, rtt@@ -37,8 +38,6 @@ import           Data.Time.Clock.POSIX       (POSIXTime) import           GHC.Generics                (Generic) -import           Network.HTTP.Client         (RequestBody (..), requestBody)-import           Network.Wreq.Types import qualified System.Metrics              as Metrics import qualified System.Metrics.Distribution as Distribution @@ -125,11 +124,11 @@ -- | Make a bulk submission to elasticsearch newtype BulkRequest = BulkRequest [(CreateBulk, BeatEvent)] -instance Postable BulkRequest where-  postPayload (BulkRequest docs) req = return $ req { requestBody = RequestBodyLBS body}-    where-      body = (<> "\n") . LBS.intercalate "\n" . concatMap encodeBoth $ docs-      encodeBoth (cb, be) = [A.encode cb, A.encode be]+bulkRequestBody :: BulkRequest -> LBS.ByteString+bulkRequestBody (BulkRequest docs) =+  (<> "\n") . LBS.intercalate "\n" . concatMap encodeBoth $ docs+  where+    encodeBoth (cb, be) = [A.encode cb, A.encode be]  -------------------------------------------------------------------------------- -- | Generate the nested json for a 'Mertics.Sample'
System/Remote/Monitoring/ElasticSearch.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE CPP                 #-}+{-# LANGUAGE DataKinds           #-} {-# LANGUAGE OverloadedStrings   #-} {-# LANGUAGE RecordWildCards     #-} {-# LANGUAGE ScopedTypeVariables #-}@@ -29,6 +30,7 @@ import           Control.Exception     (catch) import           Control.Lens import           Control.Monad         (forever, void)+import           Data.Default.Class    (def) import qualified Data.HashMap.Strict   as M import           Data.Int              (Int64) import           Data.Monoid           ((<>))@@ -39,8 +41,9 @@ import           Data.Time.Clock.POSIX (getPOSIXTime) import           Data.Time.Format      (defaultTimeLocale, formatTime) import           Network.HostName      (getHostName)-import           Network.HTTP.Client   (HttpException)-import           Network.Wreq          as Wreq+import           Network.HTTP.Req      (HttpException, POST (..),+                                        ReqBodyLbs (..), Scheme (Http), runReq)+import qualified Network.HTTP.Req      as Req import qualified System.Metrics        as Metrics  import           System.Metrics.Json@@ -157,8 +160,8 @@  -------------------------------------------------------------------------------- -- | Construct the correct URL to send metrics too from '_host' and '_port'-elasticURL :: ESOptions -> String-elasticURL eo = "http://" ++ (eo ^. host.unpacked) ++ ":" ++ show (eo ^. port) ++ "/_bulk"+elasticURL :: ESOptions -> Req.Url 'Http+elasticURL eo = Req.http . T.pack $ (eo ^. host.unpacked) <> ":" ++ show (eo ^. port) <> "/_bulk"  -- | Construct the index to send to --@@ -193,5 +196,10 @@ flushSample store eo = do   createBulk <- mkIndex eo   bulkEvts <- sampleBeatEvents store eo-  (void $ Wreq.post (elasticURL eo) $ BulkRequest $ (createBulk, ) <$> bulkEvts) `catch`-    (_onError eo)+  let body = ReqBodyLbs . bulkRequestBody . BulkRequest $ (createBulk, ) <$> bulkEvts+  (void . runReq def $ Req.req POST+    (elasticURL eo)+    body+    Req.ignoreResponse+    mempty)+    `catch` _onError eo
ekg-elasticsearch.cabal view
@@ -1,5 +1,5 @@ name:                ekg-elasticsearch-version:             0.3.1.1+version:             0.4.0.0 synopsis:            Push metrics to elasticsearch description:   This library lets you push system metrics to a elasticsearch server.@@ -19,17 +19,18 @@     System.Remote.Monitoring.ElasticSearch     System.Metrics.Json -  build-depends: base >= 4.5 && < 4.10+  build-depends: base >= 4.5 && < 4.11                , bytestring < 1.0+               , data-default-class                , ekg-core >= 0.1 && < 1.0                , aeson >= 1.0                , hostname >= 1.0                , http-client >= 0.5                , lens >= 4.15.1+               , req >= 1.0                , text < 1.3-               , time < 1.7+               , time < 1.9                , unordered-containers < 0.3-               , wreq    default-language:    Haskell2010