Skip to content

Commit

Permalink
Formatting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
evanlauer1 committed May 28, 2024
1 parent 9523dad commit 36fd483
Show file tree
Hide file tree
Showing 19 changed files with 2,440 additions and 2,437 deletions.
19 changes: 10 additions & 9 deletions api/src/OpenTelemetry/Trace/Core.hs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ createSpanWithoutCallStack t ctxt n args@SpanArguments {..} = liftIO $ do
(H.unions [additionalInfo, attrs, attributes])
, spanLinks =
let limitedLinks = fromMaybe 128 (linkCountLimit $ tracerProviderSpanLimits $ tracerProvider t)
in frozenBoundedCollection limitedLinks $ fmap freezeLink links
in frozenBoundedCollection limitedLinks $ fmap freezeLink links
, spanEvents = emptyAppendOnlyBoundedCollection $ fromMaybe 128 (eventCountLimit $ tracerProviderSpanLimits $ tracerProvider t)
, spanStatus = Unset
, spanStart = st
Expand Down Expand Up @@ -316,13 +316,14 @@ callerAttributes = case getCallStack callStack of


srcAttributes :: (String, SrcLoc) -> H.HashMap Text Attribute
srcAttributes (fn, loc) = H.fromList
[ ("code.function", toAttribute $ T.pack fn)
, ("code.namespace", toAttribute $ T.pack $ srcLocModule loc)
, ("code.filepath", toAttribute $ T.pack $ srcLocFile loc)
, ("code.lineno", toAttribute $ srcLocStartLine loc)
, ("code.package", toAttribute $ T.pack $ srcLocPackage loc)
]
srcAttributes (fn, loc) =
H.fromList
[ ("code.function", toAttribute $ T.pack fn)
, ("code.namespace", toAttribute $ T.pack $ srcLocModule loc)
, ("code.filepath", toAttribute $ T.pack $ srcLocFile loc)
, ("code.lineno", toAttribute $ srcLocStartLine loc)
, ("code.package", toAttribute $ T.pack $ srcLocPackage loc)
]


{- | Attributes are added to the end of the span argument list, so will be discarded
Expand Down Expand Up @@ -555,7 +556,7 @@ endSpan (Span s) mts = liftIO $ do
ts <- maybe getTimestamp pure mts
(alreadyFinished, frozenS) <- atomicModifyIORef' s $ \(!i) ->
let ref = i {spanEnd = spanEnd i <|> Just ts}
in (ref, (isJust $ spanEnd i, ref))
in (ref, (isJust $ spanEnd i, ref))
unless alreadyFinished $ do
eResult <- try $ mapM_ (`processorOnEnd` s) $ tracerProviderProcessors $ tracerProvider $ spanTracer frozenS
case eResult of
Expand Down
16 changes: 8 additions & 8 deletions api/src/OpenTelemetry/Util.hs
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,14 @@ data AppendOnlyBoundedCollection a = AppendOnlyBoundedCollection
instance forall a. (Show a) => Show (AppendOnlyBoundedCollection a) where
showsPrec d AppendOnlyBoundedCollection {collection = c, maxSize = m, dropped = r} =
let vec = Builder.build c :: V.Vector a
in showParen (d > 10) $
showString "AppendOnlyBoundedCollection {collection = "
. shows vec
. showString ", maxSize = "
. shows m
. showString ", dropped = "
. shows r
. showString "}"
in showParen (d > 10) $
showString "AppendOnlyBoundedCollection {collection = "
. shows vec
. showString ", maxSize = "
. shows m
. showString ", dropped = "
. shows r
. showString "}"


-- | Initialize a bounded collection that admits a maximum size
Expand Down
14 changes: 7 additions & 7 deletions exporters/otlp/src/OpenTelemetry/Exporter/OTLP.hs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE NumericUnderscores #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}

-----------------------------------------------------------------------------

Expand Down Expand Up @@ -283,13 +283,13 @@ otlpExporter conf = do
Left err@(HttpExceptionRequest req e)
| HTTPClient.host req == "localhost"
, HTTPClient.port req == 4317 || HTTPClient.port req == 4318
, ConnectionFailure _someExn <- e
-> do
pure $ Failure Nothing
, ConnectionFailure _someExn <- e ->
do
pure $ Failure Nothing
| otherwise ->
if isRetryableException e
then exponentialBackoff
else pure $ Failure $ Just $ SomeException err
if isRetryableException e
then exponentialBackoff
else pure $ Failure $ Just $ SomeException err
Left err -> do
pure $ Failure $ Just $ SomeException err
Right resp ->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE OverloadedLists #-}
{-# LANGUAGE OverloadedStrings #-}

module OpenTelemetry.Instrumentation.Conduit where

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import Control.Monad
import Control.Monad.IO.Class
import Control.Monad.Reader
import Data.Acquire.Internal
import Data.IORef
import qualified Data.HashMap.Strict as H
import Data.IORef
import Data.Maybe (fromMaybe)
import Data.Text (Text)
import qualified Data.Text as T
Expand Down Expand Up @@ -75,12 +75,12 @@ connectionLevelAttributesKey = unsafePerformIO Vault.newKey
{- | Wrap a 'SqlBackend' with appropriate tracing context and attributes
so that queries are tracked appropriately in the tracing hierarchy.
-}
wrapSqlBackend ::
MonadIO m =>
-- | Attributes that are specific to providers like MySQL, PostgreSQL, etc.
H.HashMap Text Attribute ->
SqlBackend ->
m SqlBackend
wrapSqlBackend
:: MonadIO m
=> H.HashMap Text Attribute
-- ^ Attributes that are specific to providers like MySQL, PostgreSQL, etc.
-> SqlBackend
-> m SqlBackend
wrapSqlBackend attrs conn_ = do
tp <- getGlobalTracerProvider
wrapSqlBackend' tp attrs conn_
Expand All @@ -89,12 +89,13 @@ wrapSqlBackend attrs conn_ = do
{- | Wrap a 'SqlBackend' with appropriate tracing context and attributes
so that queries are tracked appropriately in the tracing hierarchy.
-}
wrapSqlBackend' :: MonadIO m =>
TracerProvider ->
-- | Attributes that are specific to providers like MySQL, PostgreSQL, etc.
H.HashMap Text Attribute ->
SqlBackend ->
m SqlBackend
wrapSqlBackend'
:: MonadIO m
=> TracerProvider
-> H.HashMap Text Attribute
-- ^ Attributes that are specific to providers like MySQL, PostgreSQL, etc.
-> SqlBackend
-> m SqlBackend
wrapSqlBackend' tp attrs conn_ = do
let conn = Data.Maybe.fromMaybe conn_ (lookupOriginalConnection conn_)
{- A connection is acquired when the connection pool is asked for a connection. The runSqlPool function in Persistent then
Expand Down
58 changes: 29 additions & 29 deletions otlp/src/Proto/Opentelemetry/Proto/Collector/Logs/V1/LogsService.hs
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ instance Data.ProtoLens.Message ExportLogsServiceRequest where
(Data.ProtoLens.Field.field @"resourceLogs")
)
:: Data.ProtoLens.FieldDescriptor ExportLogsServiceRequest
in Data.Map.fromList
[(Data.ProtoLens.Tag 1, resourceLogs__field_descriptor)]
in Data.Map.fromList
[(Data.ProtoLens.Tag 1, resourceLogs__field_descriptor)]
unknownFields =
Lens.Family2.Unchecked.lens
_ExportLogsServiceRequest'_unknownFields
Expand All @@ -159,14 +159,14 @@ instance Data.ProtoLens.Message ExportLogsServiceRequest where
mutable'resourceLogs
)
( let missing = []
in if Prelude.null missing
then Prelude.return ()
else
Prelude.fail
( (Prelude.++)
"Missing required fields: "
(Prelude.show (missing :: [Prelude.String]))
)
in if Prelude.null missing
then Prelude.return ()
else
Prelude.fail
( (Prelude.++)
"Missing required fields: "
(Prelude.show (missing :: [Prelude.String]))
)
)
Prelude.return
( Lens.Family2.over
Expand Down Expand Up @@ -211,14 +211,14 @@ instance Data.ProtoLens.Message ExportLogsServiceRequest where
x
)
mutable'resourceLogs
in (Data.ProtoLens.Encoding.Bytes.<?>)
( do
mutable'resourceLogs <-
Data.ProtoLens.Encoding.Parser.Unsafe.unsafeLiftIO
Data.ProtoLens.Encoding.Growing.new
loop Data.ProtoLens.defMessage mutable'resourceLogs
)
"ExportLogsServiceRequest"
in (Data.ProtoLens.Encoding.Bytes.<?>)
( do
mutable'resourceLogs <-
Data.ProtoLens.Encoding.Parser.Unsafe.unsafeLiftIO
Data.ProtoLens.Encoding.Growing.new
loop Data.ProtoLens.defMessage mutable'resourceLogs
)
"ExportLogsServiceRequest"
buildMessage =
\_x ->
(Data.Monoid.<>)
Expand Down Expand Up @@ -303,14 +303,14 @@ instance Data.ProtoLens.Message ExportLogsServiceResponse where
if end
then do
( let missing = []
in if Prelude.null missing
then Prelude.return ()
else
Prelude.fail
( (Prelude.++)
"Missing required fields: "
(Prelude.show (missing :: [Prelude.String]))
)
in if Prelude.null missing
then Prelude.return ()
else
Prelude.fail
( (Prelude.++)
"Missing required fields: "
(Prelude.show (missing :: [Prelude.String]))
)
)
Prelude.return
( Lens.Family2.over
Expand All @@ -332,9 +332,9 @@ instance Data.ProtoLens.Message ExportLogsServiceResponse where
(\ !t -> (:) y t)
x
)
in (Data.ProtoLens.Encoding.Bytes.<?>)
(do loop Data.ProtoLens.defMessage)
"ExportLogsServiceResponse"
in (Data.ProtoLens.Encoding.Bytes.<?>)
(do loop Data.ProtoLens.defMessage)
"ExportLogsServiceResponse"
buildMessage =
\_x ->
Data.ProtoLens.Encoding.Wire.buildFieldSet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ instance Data.ProtoLens.Message ExportMetricsServiceRequest where
(Data.ProtoLens.Field.field @"resourceMetrics")
)
:: Data.ProtoLens.FieldDescriptor ExportMetricsServiceRequest
in Data.Map.fromList
[(Data.ProtoLens.Tag 1, resourceMetrics__field_descriptor)]
in Data.Map.fromList
[(Data.ProtoLens.Tag 1, resourceMetrics__field_descriptor)]
unknownFields =
Lens.Family2.Unchecked.lens
_ExportMetricsServiceRequest'_unknownFields
Expand Down Expand Up @@ -165,14 +165,14 @@ instance Data.ProtoLens.Message ExportMetricsServiceRequest where
mutable'resourceMetrics
)
( let missing = []
in if Prelude.null missing
then Prelude.return ()
else
Prelude.fail
( (Prelude.++)
"Missing required fields: "
(Prelude.show (missing :: [Prelude.String]))
)
in if Prelude.null missing
then Prelude.return ()
else
Prelude.fail
( (Prelude.++)
"Missing required fields: "
(Prelude.show (missing :: [Prelude.String]))
)
)
Prelude.return
( Lens.Family2.over
Expand Down Expand Up @@ -217,14 +217,14 @@ instance Data.ProtoLens.Message ExportMetricsServiceRequest where
x
)
mutable'resourceMetrics
in (Data.ProtoLens.Encoding.Bytes.<?>)
( do
mutable'resourceMetrics <-
Data.ProtoLens.Encoding.Parser.Unsafe.unsafeLiftIO
Data.ProtoLens.Encoding.Growing.new
loop Data.ProtoLens.defMessage mutable'resourceMetrics
)
"ExportMetricsServiceRequest"
in (Data.ProtoLens.Encoding.Bytes.<?>)
( do
mutable'resourceMetrics <-
Data.ProtoLens.Encoding.Parser.Unsafe.unsafeLiftIO
Data.ProtoLens.Encoding.Growing.new
loop Data.ProtoLens.defMessage mutable'resourceMetrics
)
"ExportMetricsServiceRequest"
buildMessage =
\_x ->
(Data.Monoid.<>)
Expand Down Expand Up @@ -309,14 +309,14 @@ instance Data.ProtoLens.Message ExportMetricsServiceResponse where
if end
then do
( let missing = []
in if Prelude.null missing
then Prelude.return ()
else
Prelude.fail
( (Prelude.++)
"Missing required fields: "
(Prelude.show (missing :: [Prelude.String]))
)
in if Prelude.null missing
then Prelude.return ()
else
Prelude.fail
( (Prelude.++)
"Missing required fields: "
(Prelude.show (missing :: [Prelude.String]))
)
)
Prelude.return
( Lens.Family2.over
Expand All @@ -338,9 +338,9 @@ instance Data.ProtoLens.Message ExportMetricsServiceResponse where
(\ !t -> (:) y t)
x
)
in (Data.ProtoLens.Encoding.Bytes.<?>)
(do loop Data.ProtoLens.defMessage)
"ExportMetricsServiceResponse"
in (Data.ProtoLens.Encoding.Bytes.<?>)
(do loop Data.ProtoLens.defMessage)
"ExportMetricsServiceResponse"
buildMessage =
\_x ->
Data.ProtoLens.Encoding.Wire.buildFieldSet
Expand Down
Loading

0 comments on commit 36fd483

Please sign in to comment.