Skip to content

Commit a29e631

Browse files
author
Tim Watson
committed
Document the use of 'trace' and basic trace configuration
Explains about the tracing facilities and documents the environment variables used to configure them and the order in which they're applied when starting a new local node. Fixes haskell-distributed#104.
1 parent 6a84b59 commit a29e631

File tree

2 files changed

+35
-8
lines changed

2 files changed

+35
-8
lines changed

distributed-process/src/Control/Distributed/Process/Internal/Primitives.hs

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -900,12 +900,39 @@ reconnectPort them = do
900900
--------------------------------------------------------------------------------
901901

902902
-- | Send a message to the internal (system) trace facility. If tracing is
903-
-- enabled, this will create a custom trace event in the event log. Specifically,
904-
-- the environment variable @DISTRIBUTED_PROCESS_TRACE_FILE@ is set to a valid
905-
-- path, then trace output will be written to that file. Otherwise, if the GHC
906-
-- eventlog is enabled (i.e., you've compiled with @-eventlog@ set) and the
907-
-- relevant @+RTS@ options given, then the message will be sent to the event log.
908-
-- If neither facility is in use then trace messages will be silently dropped.
903+
-- enabled, this will create a custom trace event. Note that several Cloud Haskell
904+
-- sub-systems also generate trace events for informational/debugging purposes,
905+
-- thus traces generated this way will not be the only output seen.
906+
--
907+
-- Just as with the "Debug.Trace" module, this is a debugging/tracing facility
908+
-- for use in development, and should not be used in a production setting -
909+
-- which is why the default behaviour is to trace to the GHC eventlog. For a
910+
-- general purpose logging facility, you should consider 'say'.
911+
--
912+
-- Trace events can be written to the GHC event log, a text file, or to the
913+
-- standard system logger process (see 'say'). The default behaviour for writing
914+
-- to the eventlog requires specific intervention to work, without which traces
915+
-- are silently dropped/ignored and no output will be generated.
916+
-- The GHC eventlog documentation provides information about enabling, viewing
917+
-- and working with event traces: <http://hackage.haskell.org/trac/ghc/wiki/EventLog>.
918+
--
919+
-- When a new local node is started, the contents of the environment variable
920+
-- @DISTRIBUTED_PROCESS_TRACE_FILE@ are checked for a valid file path. If this
921+
-- exists and the file can be opened for writing, all trace output will be directed
922+
-- thence. If the environment variable is empty, the path invalid, or the file
923+
-- unavailable for writing - e.g., because another node has already started
924+
-- tracing to it - then the @DISTRIBUTED_PROCESS_TRACE_CONSOLE@ environment
925+
-- variable is checked for /any/ non-empty value. If this is set, then all trace
926+
-- output will be directed to the system logger process. If neither evironment
927+
-- variable provides a valid trace configuration, all internal traces are written
928+
-- to "Debug.Trace.traceEventIO", which writes to the GHC eventlog.
929+
--
930+
-- Users of the /simplelocalnet/ Cloud Haskell backend should also note that
931+
-- because the trace file option only supports trace output from a single node
932+
-- (so as to avoid interleaving), a file trace configured for the master node will
933+
-- prevent slaves from tracing to the file and they will fall back to using the
934+
-- console/'say' or eventlog instead.
935+
--
909936
trace :: String -> Process ()
910937
trace s = do
911938
node <- processNode <$> ask

distributed-process/src/Control/Distributed/Process/Node.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
-- | Local nodes
22
--
3-
-- TODO: Calls to 'sendBinary' and co by the node controller may stall the
4-
-- node controller.
53
module Control.Distributed.Process.Node
64
( LocalNode
75
, newLocalNode
@@ -12,6 +10,8 @@ module Control.Distributed.Process.Node
1210
, localNodeId
1311
) where
1412

13+
-- TODO: Calls to 'sendBinary' and co (by the NC) may stall the node controller.
14+
1515
#if ! MIN_VERSION_base(4,6,0)
1616
import Prelude hiding (catch)
1717
#endif

0 commit comments

Comments
 (0)