packages feed

katip-elasticsearch 0.5.1.1 → 0.6.0.0

raw patch · 6 files changed

+47/−36 lines, 6 filesdep +safe-exceptionsdep −enclosed-exceptionsdep ~asyncdep ~bloodhounddep ~http-clientPVP ok

version bump matches the API change (PVP)

Dependencies added: safe-exceptions

Dependencies removed: enclosed-exceptions

Dependency ranges changed: async, bloodhound, http-client, http-types, katip, retry, scientific, stm, stm-chans, text, time, transformers, unordered-containers, uuid

API changes (from Hackage documentation)

- Katip.Scribes.ElasticSearch: mkEsScribe :: forall v. (ESVersion v, MonadIO (BH v IO)) => EsScribeCfg v -> BHEnv v -> IndexName v -> MappingName v -> Severity -> Verbosity -> IO Scribe
+ Katip.Scribes.ElasticSearch: mkEsScribe :: forall v. (ESVersion v, MonadIO (BH v IO)) => EsScribeCfg v -> BHEnv v -> IndexName v -> MappingName v -> PermitFunc -> Verbosity -> IO Scribe
- Katip.Scribes.ElasticSearch.Internal: mkEsScribe :: forall v. (ESVersion v, MonadIO (BH v IO)) => EsScribeCfg v -> BHEnv v -> IndexName v -> MappingName v -> Severity -> Verbosity -> IO Scribe
+ Katip.Scribes.ElasticSearch.Internal: mkEsScribe :: forall v. (ESVersion v, MonadIO (BH v IO)) => EsScribeCfg v -> BHEnv v -> IndexName v -> MappingName v -> PermitFunc -> Verbosity -> IO Scribe

Files

changelog.md view
@@ -1,3 +1,14 @@+0.6.0.0+=======+* Update to katip-0.8.0.0 `PermitFunc` convention. To update, for+  example, if you were passing `InfoS` to `mkEsScribe` to filter+  severities, instead you should pass `(permitItem InfoS)`.+* Update examples to add necessary type signature for the default+  scribe config.+* Bugfix: the default error retry policy was much more rapid than+  documented.+* Internally switch to safe-exceptions from encolosed-exceptions.+ 0.5.1.1 ======= * Loosen katip dep
examples/example.hs view
@@ -18,15 +18,16 @@ main = do   mgr <- newManager defaultManagerSettings   let bhe = mkBHEnv (Server "http://localhost:9200") mgr+  -- You may need to specify the version in a type signature when customizing your index settings+  let _customizedExample =  defaultEsScribeCfgV5 { essIndexSettings = IndexSettings (ShardCount 1) (ReplicaCount 0)} :: EsScribeCfg ESV5   esScribe <- mkEsScribe     -- Reasonable for production     defaultEsScribeCfgV5     -- Reasonable for single-node in development-    -- defaultEsScribeCfgV5 { essIndexSettings = IndexSettings (ShardCound 1) (ReplicaCount 0)}     bhe     (IndexName "all-indices-prefixed-with")     (MappingName "application-logs")-    DebugS+    (permitItem DebugS)     V3   let mkLogEnv = registerScribe "es" esScribe defaultScribeSettings =<< initLogEnv "MyApp" "production"   bracket mkLogEnv closeScribes $ \le -> runKatipT le $ do
katip-elasticsearch.cabal view
@@ -1,7 +1,7 @@ name:                katip-elasticsearch synopsis:            ElasticSearch scribe for the Katip logging framework. description:         See README.md for more details.-version:             0.5.1.1+version:             0.6.0.0 license:             BSD3 license-file:        LICENSE author:              Ozgun Ataman, Michael Xavier@@ -35,23 +35,23 @@     Katip.Scribes.ElasticSearch.Internal   build-depends:       base >=4.6 && <5-    , katip >= 0.2.0.0 && < 0.8-    , bloodhound >= 0.13.0.0 && < 0.17-    , uuid >= 1.3.12 && < 1.4+    , katip >= 0.8.0.0+    , bloodhound >= 0.13.0.0+    , uuid >= 1.3.12     , aeson >=0.6-    , stm >= 2.4.3 && < 2.6-    , stm-chans >= 3.0.0.2 && < 3.1-    , async >= 2.0.1.0 && < 3.0-    , enclosed-exceptions >= 1.0.0 && < 1.1-    , http-client >= 0.3 && < 0.6-    , text >= 0.11 && < 1.3-    , retry >= 0.7 && < 0.8+    , stm >= 2.4.3+    , stm-chans >= 3.0.0.2+    , async >= 2.0.1.0+    , safe-exceptions >= 0.1.0.0+    , http-client >= 0.3+    , text >= 0.11+    , retry >= 0.7     , exceptions-    , scientific >= 0.3.0.0 && < 0.4-    , unordered-containers >= 0.1.0.0 && < 0.3-    , transformers >= 0.2 && < 0.6-    , http-types >= 0.8 && < 0.13-    , time >= 1 && < 1.9+    , scientific >= 0.3.0.0+    , unordered-containers >= 0.1.0.0+    , transformers >= 0.2+    , http-types >= 0.8+    , time >= 1     , bytestring     , semigroups   hs-source-dirs:      src
src/Katip/Scribes/ElasticSearch.hs view
@@ -22,7 +22,7 @@ --     -- Reasonable for production --     defaultEsScribeCfgV5 --     -- Reasonable for single-node in development---     -- defaultEsScribeCfgV5 { essIndexSettings = IndexSettings (ShardCound 1) (ReplicaCount 0)}+--     -- defaultEsScribeCfgV5 { essIndexSettings = IndexSettings (ShardCound 1) (ReplicaCount 0)} :: EsScribeCfg ESV5 --     bhe --       (IndexName "all-indices-prefixed-with") --       (MappingName "application-logs")
src/Katip/Scribes/ElasticSearch/Internal.hs view
@@ -16,8 +16,7 @@ import           Control.Concurrent import           Control.Concurrent.Async import           Control.Concurrent.STM.TBMQueue-import           Control.Exception.Base-import           Control.Exception.Enclosed+import qualified Control.Exception.Safe                  as EX import           Control.Monad import           Control.Monad.Catch import           Control.Monad.IO.Class@@ -28,7 +27,7 @@                                                           recovering) import           Data.Aeson import           Data.ByteString.Lazy                    (ByteString)-import           Data.List.NonEmpty                      (NonEmpty(..))+import           Data.List.NonEmpty                      (NonEmpty (..)) import           Data.Monoid                             ((<>)) import           Data.Text                               (Text) import qualified Data.Text                               as T@@ -85,7 +84,7 @@ -- --     * defaultManagerSettings -----     * exponential backoff with 25ms base delay up to 5 retries+--     * exponential backoff with 25ms base delay up to 5 retries, for a total cumulative delay of 775ms -- --     * Queue size of 1000 --@@ -96,7 +95,7 @@ --     * DailyIndexSharding defaultEsScribeCfg' :: ESVersion v => proxy v -> EsScribeCfg v defaultEsScribeCfg' prx = EsScribeCfg {-      essRetryPolicy     = exponentialBackoff 25 <> limitRetries 5+      essRetryPolicy     = exponentialBackoff 25000 <> limitRetries 5     , essQueueSize       = EsQueueSize 1000     , essPoolSize        = EsPoolSize 2     , essAnnotateTypes   = False@@ -269,10 +268,10 @@     -> IndexName v     -- ^ Treated as a prefix if index sharding is enabled     -> MappingName v-    -> Severity+    -> PermitFunc     -> Verbosity     -> IO Scribe-mkEsScribe cfg@EsScribeCfg {..} env ix mapping sev verb = do+mkEsScribe cfg@EsScribeCfg {..} env ix mapping permit verb = do   q <- newTBMQueueIO $ unEsQueueSize essQueueSize   endSig <- newEmptyMVar @@ -282,21 +281,21 @@          -- create or update          res <- putTemplate prx tpl tplName          unless (statusIsSuccessful (responseStatus res)) $-           liftIO $ throwIO (CouldNotPutTemplate res)+           liftIO $ EX.throwIO (CouldNotPutTemplate res)        else do          ixExists <- indexExists prx ix          if ixExists             then do               res <- updateIndexSettings prx (toUpdatabaleIndexSettings prx essIndexSettings) ix               unless (statusIsSuccessful (responseStatus res)) $-                liftIO $ throwIO (CouldNotUpdateIndexSettings res)+                liftIO $ EX.throwIO (CouldNotUpdateIndexSettings res)             else do               r1 <- createIndex prx essIndexSettings ix               unless (statusIsSuccessful (responseStatus r1)) $-                liftIO $ throwIO (CouldNotCreateIndex r1)+                liftIO $ EX.throwIO (CouldNotCreateIndex r1)               r2 <- putMapping prx ix mapping base               unless (statusIsSuccessful (responseStatus r2)) $-                liftIO $ throwIO (CouldNotCreateMapping r2)+                liftIO $ EX.throwIO (CouldNotCreateMapping r2)    workers <- replicateM (unEsPoolSize essPoolSize) $ async $     startWorker cfg env mapping q@@ -308,10 +307,10 @@     putMVar endSig ()    let finalizer = putMVar endSig () >> takeMVar endSig-  return (Scribe (logger q) finalizer)+  return (Scribe (logger q) finalizer permit)   where     logger :: forall a. LogItem a => TBMQueue (IndexName v, Value) -> Item a -> IO ()-    logger q i = when (_itemSeverity i >= sev) $+    logger q i =       void $ atomically $ tryWriteTBMQueue q (chooseIxn prx ix essIndexSharding i, itemJson' i)     prx :: Typeable.Proxy v     prx = Typeable.Proxy@@ -421,7 +420,7 @@       popped <- atomically $ readTBMQueue q       case popped of         Just (ixn, v) -> do-          sendLog ixn v `catchAny` eat+          sendLog ixn v `EX.catchAny` eat           go         Nothing -> return ()     prx :: Typeable.Proxy v@@ -434,8 +433,8 @@     eat _ = return ()     handler _ = Handler $ \e ->       case fromException e of-        Just (_ :: AsyncException) -> return False-        _                          -> return True+        Just (_ :: EX.SomeAsyncException) -> return False+        _                                 -> return True   -------------------------------------------------------------------------------
test/Main.hs view
@@ -161,7 +161,7 @@ setupSearch prx modScribeCfg = do     bh prx (dropESSchema prx)     mgr <- newManager defaultManagerSettings-    mkEsScribe cfg (mkBHEnv prx (svr prx) mgr) (ixn prx) (mn prx) DebugS V3+    mkEsScribe cfg (mkBHEnv prx (svr prx) mgr) (ixn prx) (mn prx) (permitItem DebugS) V3   where     cfg :: EsScribeCfg v     cfg = modScribeCfg $