@@ -487,50 +487,59 @@ instance AE.FromJSON Verbosity where
487487 <> " Unknown Verbosity: " <> show other
488488
489489data TraceOptionForwarder = TraceOptionForwarder {
490- tofConnQueueSize :: Word
491- , tofDisconnQueueSize :: Word
490+ tofQueueSize :: Word
492491 , tofVerbosity :: Verbosity
493492 , tofMaxReconnectDelay :: Word
494493} deriving stock (Eq , Ord , Show , Generic )
495494
496- -- A word regarding queue sizes:
495+ -- A word regarding queue size:
496+ --
497497-- In case of a missing forwarding service consumer, traces messages will be
498- -- buffered. This mitigates short forwarding interruptions, or delays at startup time.
498+ -- buffered. This mitigates short forwarding interruptions, or delays at startup
499+ -- time.
499500--
500- -- The queue capacity should thus correlate to the expected log lines per second given
501- -- a particular tracing configuration - to avoid unnecessarily increasing memory footprint.
501+ -- The queue capacity should thus correlate to the expected log lines per second
502+ -- given a particular tracing configuration - to avoid unnecessarily increasing
503+ -- memory footprint.
502504--
503505-- The default values here are chosen to accomodate verbose tracing output
504- -- (i.e., buffering 1min worth of trace data given ~32 messages per second). A config
505- -- that results in less than 5 msgs per second should also provide TraceOptionForwarder
506- -- queue size values considerably lower. The `disconnQueueSize` is the hard limit in that case .
506+ -- (i.e., buffering 1min worth of trace data given ~32 messages per second). A
507+ -- config that results in less than 5 msgs per second should also provide
508+ -- `TraceOptionForwarder` a queue size value considerably lower .
507509--
508- -- The queue sizes tie in with the max number of trace objects cardano-tracer requests periodically,
509- -- the default for that being 100. Here, the basic queue can hold enough traces for 10 subsequent polls
510- -- by cardano-tracer.
510+ -- The queue size ties in with the max number of trace objects cardano-tracer
511+ -- requests periodically, the default for that being 100. Here, the queue can
512+ -- hold enough traces for 10 subsequent polls by cardano-tracer.
511513instance AE. FromJSON TraceOptionForwarder where
512- parseJSON (AE. Object obj) =
513- TraceOptionForwarder
514- <$> obj AE. .:? " connQueueSize" AE. .!= 1024
515- <*> obj AE. .:? " disconnQueueSize" AE. .!= 2048
516- <*> obj AE. .:? " verbosity" AE. .!= Minimum
517- <*> obj AE. .:? " maxReconnectDelay" AE. .!= 60
514+ parseJSON (AE. Object obj) = do
515+ -- Field "queueSize" is the new field that replaces and unifies
516+ -- both "connQueueSize" and "disconnQueueSize".
517+ maybeQueueSize <- obj AE. .:? " queueSize"
518+ queueSize <- case maybeQueueSize of
519+ -- If the new field was provided we use it.
520+ (Just qs) -> return qs
521+ -- Else we look for the deprectaed fields.
522+ Nothing -> do
523+ -- We keep the same default values.
524+ connQueueSize <- obj AE. .:? " connQueueSize" AE. .!= 1024
525+ disconnQueueSize <- obj AE. .:? " disconnQueueSize" AE. .!= 2048
526+ return $ max connQueueSize disconnQueueSize
527+ verbosity <- obj AE. .:? " verbosity" AE. .!= Minimum
528+ maxReconnectDelay <- obj AE. .:? " maxReconnectDelay" AE. .!= 60
529+ return $ TraceOptionForwarder queueSize verbosity maxReconnectDelay
518530 parseJSON _ = mempty
519531
520-
521532instance AE. ToJSON TraceOptionForwarder where
522533 toJSON TraceOptionForwarder {.. } = AE. object
523534 [
524- " connQueueSize" AE. .= tofConnQueueSize,
525- " disconnQueueSize" AE. .= tofDisconnQueueSize,
535+ " queueSize" AE. .= tofQueueSize,
526536 " verbosity" AE. .= tofVerbosity,
527537 " maxReconnectDelay" AE. .= tofMaxReconnectDelay
528538 ]
529539
530540defaultForwarder :: TraceOptionForwarder
531541defaultForwarder = TraceOptionForwarder {
532- tofConnQueueSize = 1024
533- , tofDisconnQueueSize = 2048
542+ tofQueueSize = 2048
534543 , tofVerbosity = Minimum
535544 , tofMaxReconnectDelay = 60
536545}
0 commit comments