hs-opentelemetry-exporter-in-memory 0.0.1.2 → 0.0.1.3
raw patch · 4 files changed
+52/−43 lines, 4 filesdep ~hs-opentelemetry-apisetup-changed
Dependency ranges changed: hs-opentelemetry-api
Files
- Setup.hs +2/−0
- hs-opentelemetry-exporter-in-memory.cabal +14/−14
- src/OpenTelemetry/Exporter/InMemory.hs +35/−29
- test/Spec.hs +1/−0
Setup.hs view
@@ -1,2 +1,4 @@ import Distribution.Simple++ main = defaultMain
hs-opentelemetry-exporter-in-memory.cabal view
@@ -1,20 +1,20 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.34.4.+-- This file has been generated from package.yaml by hpack version 0.35.2. -- -- see: https://github.com/sol/hpack -name: hs-opentelemetry-exporter-in-memory-version: 0.0.1.2-description: Please see the README on GitHub at <https://github.com/iand675/hs-opentelemetry/tree/main/exporters/in-memory#readme>-homepage: https://github.com/iand675/hs-opentelemetry#readme-bug-reports: https://github.com/iand675/hs-opentelemetry/issues-author: Ian Duncan-maintainer: ian@iankduncan.com-copyright: 2021 Ian Duncan-license: BSD3-license-file: LICENSE-build-type: Simple+name: hs-opentelemetry-exporter-in-memory+version: 0.0.1.3+description: Please see the README on GitHub at <https://github.com/iand675/hs-opentelemetry/tree/main/exporters/in-memory#readme>+homepage: https://github.com/iand675/hs-opentelemetry#readme+bug-reports: https://github.com/iand675/hs-opentelemetry/issues+author: Ian Duncan+maintainer: ian@iankduncan.com+copyright: 2021 Ian Duncan+license: BSD3+license-file: LICENSE+build-type: Simple extra-source-files: README.md ChangeLog.md@@ -34,7 +34,7 @@ build-depends: async , base >=4.7 && <5- , hs-opentelemetry-api ==0.0.3.*+ , hs-opentelemetry-api >=0.0.3 && <0.2 , unagi-chan default-language: Haskell2010 @@ -49,7 +49,7 @@ build-depends: async , base >=4.7 && <5- , hs-opentelemetry-api ==0.0.3.*+ , hs-opentelemetry-api >=0.0.3 && <0.2 , hs-opentelemetry-exporter-in-memory , unagi-chan default-language: Haskell2010
src/OpenTelemetry/Exporter/InMemory.hs view
@@ -1,43 +1,49 @@-module OpenTelemetry.Exporter.InMemory - ( inMemoryChannelExporter- , inMemoryListExporter- , module Control.Concurrent.Chan.Unagi- ) where+module OpenTelemetry.Exporter.InMemory (+ inMemoryChannelExporter,+ inMemoryListExporter,+ module Control.Concurrent.Chan.Unagi,+) where import Control.Concurrent.Async import Control.Concurrent.Chan.Unagi import Control.Monad.IO.Class import Data.IORef-import OpenTelemetry.Trace.Core import OpenTelemetry.Processor+import OpenTelemetry.Trace.Core --- | Access exported spans via a concurrently accessible channel that produces spans. --- The spans are exported in the order that the spans end.-inMemoryChannelExporter :: MonadIO m => m (Processor, OutChan ImmutableSpan)++{- | Access exported spans via a concurrently accessible channel that produces spans.+ The spans are exported in the order that the spans end.+-}+inMemoryChannelExporter :: (MonadIO m) => m (Processor, OutChan ImmutableSpan) inMemoryChannelExporter = liftIO $ do (inChan, outChan) <- newChan- let processor = Processor - { processorOnStart = \_ _ -> pure () - , processorOnEnd = \ref -> do- writeChan inChan =<< readIORef ref- , processorShutdown = do- async $ pure ShutdownSuccess- , processorForceFlush = pure ()- }+ let processor =+ Processor+ { processorOnStart = \_ _ -> pure ()+ , processorOnEnd = \ref -> do+ writeChan inChan =<< readIORef ref+ , processorShutdown = do+ async $ pure ShutdownSuccess+ , processorForceFlush = pure ()+ } pure (processor, outChan) --- | Access exported spans via a mutable reference to a list of spans. The spans--- are not guaranteed to be exported in a particular order.-inMemoryListExporter :: MonadIO m => m (Processor, IORef [ImmutableSpan])++{- | Access exported spans via a mutable reference to a list of spans. The spans+ are not guaranteed to be exported in a particular order.+-}+inMemoryListExporter :: (MonadIO m) => m (Processor, IORef [ImmutableSpan]) inMemoryListExporter = liftIO $ do listRef <- newIORef []- let processor = Processor - { processorOnStart = \_ _ -> pure () - , processorOnEnd = \ref -> do- s <- readIORef ref- atomicModifyIORef listRef (\l -> (s : l, ()))- , processorShutdown = do- async $ pure ShutdownSuccess- , processorForceFlush = pure ()- }+ let processor =+ Processor+ { processorOnStart = \_ _ -> pure ()+ , processorOnEnd = \ref -> do+ s <- readIORef ref+ atomicModifyIORef listRef (\l -> (s : l, ()))+ , processorShutdown = do+ async $ pure ShutdownSuccess+ , processorForceFlush = pure ()+ } pure (processor, listRef)
test/Spec.hs view
@@ -1,2 +1,3 @@+ main :: IO () main = putStrLn "Test suite not yet implemented"