{-# LANGUAGE OverloadedStrings #-}

module OpenTelemetry.Lightstep.Exporter where

import Control.Monad.IO.Class
import OpenTelemetry.Common
import OpenTelemetry.Lightstep.Config
import OpenTelemetry.ZipkinExporter
import Text.Printf

createLightstepSpanExporter :: MonadIO m => LightstepConfig -> m (Exporter Span)
createLightstepSpanExporter :: LightstepConfig -> m (Exporter Span)
createLightstepSpanExporter LightstepConfig {HostName
[(Text, Text)]
Word
Text
PortNumber
lsSpanQueueSize :: LightstepConfig -> Word
lsGracefulShutdownTimeoutSeconds :: LightstepConfig -> Word
lsGlobalTags :: LightstepConfig -> [(Text, Text)]
lsServiceName :: LightstepConfig -> Text
lsToken :: LightstepConfig -> Text
lsPort :: LightstepConfig -> PortNumber
lsHostName :: LightstepConfig -> HostName
lsSpanQueueSize :: Word
lsGracefulShutdownTimeoutSeconds :: Word
lsGlobalTags :: [(Text, Text)]
lsServiceName :: Text
lsToken :: Text
lsPort :: PortNumber
lsHostName :: HostName
..} = IO (Exporter Span) -> m (Exporter Span)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO do
  let zcfg :: ZipkinConfig
zcfg =
        ZipkinConfig :: HostName -> Text -> [(Text, Text)] -> Word -> Word -> ZipkinConfig
ZipkinConfig
          { zEndpoint :: HostName
zEndpoint = HostName -> HostName -> Int -> HostName
forall r. PrintfType r => HostName -> r
printf HostName
"https://%s:%d/api/v2/spans" HostName
lsHostName (PortNumber -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral PortNumber
lsPort :: Int),
            zServiceName :: Text
zServiceName = Text
lsServiceName,
            zGlobalTags :: [(Text, Text)]
zGlobalTags =
              [ (Text
"lightstep.component", Text
lsServiceName),
                (Text
"lightstep.access_token", Text
lsToken)
              ],
            zSpanQueueSize :: Word
zSpanQueueSize = Word
lsSpanQueueSize,
            zGracefulShutdownTimeoutSeconds :: Word
zGracefulShutdownTimeoutSeconds = Word
lsGracefulShutdownTimeoutSeconds
          }
  ZipkinConfig -> IO (Exporter Span)
forall (m :: * -> *).
MonadIO m =>
ZipkinConfig -> m (Exporter Span)
createZipkinSpanExporter ZipkinConfig
zcfg