Skip to content
This repository was archived by the owner on Jan 21, 2020. It is now read-only.

Commit b18c181

Browse files
symbiont-sam-hallidayfommil
authored andcommitted
constructor for a fire-and-forget agent
1 parent f82b08b commit b18c181

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

datadog-tracing.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cabal-version: 2.2
22
name: datadog-tracing
3-
version: 1.3.1
3+
version: 1.3.2
44
synopsis: Datadog tracing client and mock agent.
55
license: BSD-3-Clause
66
license-file: LICENSE

library/Datadog/Client.hs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@ module Datadog.Client (
2525
, Trace(..)
2626
, TraceId(..)
2727
, newServantAgent
28+
, newServantAgent'
2829
) where
2930

3031
import Control.Monad (unless, void)
3132
import Control.Monad.Except (ExceptT, MonadError, MonadIO,
32-
liftEither, liftIO)
33+
liftEither, liftIO, runExceptT)
3334
import Data.Char (isAlpha, isAsciiLower, isDigit)
3435
import Data.FFunctor (FFunctor, ffmap)
3536
import Data.Int (Int64)
@@ -70,6 +71,12 @@ instance FFunctor Agent where
7071
newServantAgent :: (MonadIO m, MonadError ServantError m) => ClientEnv -> Agent m
7172
newServantAgent env = ffmap (liftClientM env) (Agent traces)
7273

74+
-- | A fire-and-forget Agent implemented by Servant.
75+
newServantAgent' :: MonadIO m => ClientEnv -> Agent m
76+
newServantAgent' env =
77+
let agent = newServantAgent env
78+
in Agent (\t -> void . runExceptT $ putTraces agent t)
79+
7380
type DDText = Refined.NonEmpty && (SizeLessThan 101)
7481

7582
newtype SpanId = SpanId (Refined NonZero Word64) deriving (Eq, Show)

0 commit comments

Comments
 (0)