about summary refs log tree commit diff
path: root/users/Profpatsch/whatcd-resolver/src
diff options
context:
space:
mode:
authorProfpatsch <mail@profpatsch.de>2023-09-29T17·04+0200
committerclbot <clbot@tvl.fyi>2023-09-29T17·25+0000
commitacfc49efc22b443896b42cba17b42ef234ff4f82 (patch)
treec051a20f2c6c4de21508c8c66828849feae53ed4 /users/Profpatsch/whatcd-resolver/src
parent0dcc72a31c3dbadc2e70d2634582e50df4ca877b (diff)
feat(users/Profpatsch/MonadPostgres): trace db queries r/6674
Experiment of how to instrument a lib I’m using to trace instead of
log.

Now that we added MonadTracer to Transaction, we can drop the unlifted `inSpanT`.

Change-Id: Iea891a58cfb33a0837978611456c33aefcccf0d7
Reviewed-on: https://cl.tvl.fyi/c/depot/+/9491
Autosubmit: Profpatsch <mail@profpatsch.de>
Tested-by: BuildkiteCI
Reviewed-by: Profpatsch <mail@profpatsch.de>
Diffstat (limited to 'users/Profpatsch/whatcd-resolver/src')
-rw-r--r--users/Profpatsch/whatcd-resolver/src/WhatcdResolver.hs15
1 files changed, 1 insertions, 14 deletions
diff --git a/users/Profpatsch/whatcd-resolver/src/WhatcdResolver.hs b/users/Profpatsch/whatcd-resolver/src/WhatcdResolver.hs
index c105de9affe7..5498cb235fd6 100644
--- a/users/Profpatsch/whatcd-resolver/src/WhatcdResolver.hs
+++ b/users/Profpatsch/whatcd-resolver/src/WhatcdResolver.hs
@@ -41,7 +41,6 @@ import Network.HTTP.Types qualified as Http
 import Network.Wai qualified as Wai
 import Network.Wai.Handler.Warp qualified as Warp
 import OpenTelemetry.Trace qualified as Otel hiding (getTracer, inSpan)
-import OpenTelemetry.Trace qualified as OtelTrace
 import OpenTelemetry.Trace.Monad qualified as Otel
 import PossehlAnalyticsPrelude
 import Postgres.Decoder qualified as Dec
@@ -918,7 +917,7 @@ migrate ::
     Otel.MonadTracer m
   ) =>
   Transaction m (Label "numberOfRowsAffected" Natural)
-migrate = inSpanT "Database Migration" $ do
+migrate = inSpan "Database Migration" $ do
   execute_
     [sql|
     CREATE SCHEMA IF NOT EXISTS redacted;
@@ -1048,18 +1047,6 @@ getBestTorrents = do
 inSpan :: (MonadUnliftIO m, Otel.MonadTracer m) => Text -> m a -> m a
 inSpan name = Otel.inSpan name Otel.defaultSpanArguments
 
-inSpanT :: (Otel.MonadTracer m, MonadUnliftIO m) => Text -> Transaction m b -> Transaction m b
-inSpanT name transaction = do
-  tracer <- lift @Transaction $ Otel.getTracer
-  -- I don’t want to implement MonadTracer for Transaction,
-  -- so I’m unlifting it via IO, that should work :P
-  withRunInIO $ \runInIO -> do
-    OtelTrace.inSpan
-      tracer
-      name
-      Otel.defaultSpanArguments
-      (runInIO transaction)
-
 hush :: Either a1 a2 -> Maybe a2
 hush (Left _) = Nothing
 hush (Right a) = Just a