Skip to content

Commit e6965ad

Browse files
authored
recon-framework: backwards compat with trace-dispatcher and contra-tracer (#13)
1 parent 0d31e25 commit e6965ad

2 files changed

Lines changed: 23 additions & 3 deletions

File tree

hermod-recon-framework/app/Hermod/ReCon.hs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
{-# LANGUAGE CPP #-}
2+
3+
#if !MIN_VERSION_trace_dispatcher(2,13,0)
4+
{-# LANGUAGE PackageImports #-}
5+
#endif
6+
17
module Main(main) where
28

39
import Cardano.Logging
@@ -42,6 +48,12 @@ import qualified System.Metrics as EKG
4248

4349
import Streaming
4450

51+
#if !MIN_VERSION_trace_dispatcher(2,13,0) && !MIN_VERSION_contra_tracer(0,2,0)
52+
import "contra-tracer" Control.Tracer (Tracer(..))
53+
#elif !MIN_VERSION_trace_dispatcher(2,13,0) && MIN_VERSION_contra_tracer(0,2,0)
54+
import "contra-tracer" Control.Tracer (mkTracer)
55+
#endif
56+
4557

4658
check :: OnMissingKey -> Bool -> Word -> Trace IO App.TraceMessage -> Formula TemporalEvent Text -> [TemporalEvent] -> IO ()
4759
check omk greppable idx {- Formula index -} tr phi events =
@@ -117,7 +129,15 @@ setupTraceDispatcher optTraceDispatcherConfigFile = do
117129
configureTracers configReflection cfg [tr]
118130
configureTracers configReflection cfg [prometheusSimpleTr]
119131
for_ (prometheusSimple cfg) $ \ps -> do
120-
runPrometheusSimple (mkTracer (traceWith prometheusSimpleTr)) ekgStore ps >>= link
132+
let
133+
134+
#if !MIN_VERSION_contra_tracer(0,2,0)
135+
t = Tracer (traceWith prometheusSimpleTr)
136+
#else
137+
t = mkTracer (traceWith prometheusSimpleTr)
138+
#endif
139+
140+
runPrometheusSimple t ekgStore ps >>= link
121141
pure tr
122142
where
123143
defaultTraceConfig :: TraceConfig

hermod-recon-framework/hermod-recon-framework.cabal

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ library
114114
, mtl
115115
, text
116116
, directory
117-
, trace-dispatcher ^>= 2.13
117+
, trace-dispatcher
118118
, serialise
119119
, bytestring
120120
, time
@@ -160,7 +160,7 @@ executable hermod-recon
160160
, ekg-core
161161
, network
162162
, hostname
163-
, contra-tracer ^>=0.2.1
163+
, contra-tracer
164164

165165

166166
-- Directories containing source files.

0 commit comments

Comments
 (0)