Skip to content

Commit

Permalink
Log RequestOptions for all requests
Browse files Browse the repository at this point in the history
Summary:
We were previously only logging the `RequestOptions` for
documentSymbols requests, this adds logging of `RequestOptions` for
all request types.

Reviewed By: phlalx

Differential Revision: D56190618

fbshipit-source-id: 1a8132ee8bb6a485d4bc5d4609a3fe6099bdf348
  • Loading branch information
Simon Marlow authored and facebook-github-bot committed Apr 17, 2024
1 parent 7e3a6d6 commit 646c27e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion glean/glass/Glean/Glass/Handler.hs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ runRepoFile
-> RequestOptions
-> IO t
runRepoFile sym fn env@Glass.Env{..} req opts =
withRepoFile sym env opts (req, opts) repo file $ \gleanDBs dbInfo mlang ->
withRepoFile sym env opts req repo file $ \gleanDBs dbInfo mlang ->
fn sourceControl (Glass.repoMapping env) dbInfo req opts
GleanBackend{..}
snapshotBackend
Expand Down
9 changes: 5 additions & 4 deletions glean/glass/Glean/Glass/Handler/Utils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ withGleanDBs
withGleanDBs method env@Glass.Env{..} opts req repo dbNames fn = do
dbInfo <- readTVarIO latestGleanRepos
dbs <- getSpecificGleanDBs tracer sourceControl dbInfo (dbChooser repo opts) dbNames
withLog method env req $ \log ->
withLog method env opts req $ \log ->
withLogDB dbs log $
fn dbs dbInfo

Expand All @@ -179,7 +179,7 @@ withRequest
withRequest method env@Glass.Env{..} req opts fn = do
dbInfo <- readTVarIO latestGleanRepos
withStrictErrorHandling dbInfo opts $
withLog method env req $
withLog method env opts req $
fn dbInfo

-- | Run an action that provides a repo and maybe a language, log it
Expand Down Expand Up @@ -268,15 +268,16 @@ withLog
:: (LogRequest req, LogError req, LogResult res)
=> Text
-> Glass.Env
-> RequestOptions
-> req
-> (GleanGlassLogger -> IO (res, GleanGlassLogger, Maybe ErrorLogger))
-> IO (res, Maybe ErrorLogger)
withLog cmd env req action = do
withLog cmd env opts req action = do
(res, _) <- loggingAction
(runLog env cmd)
logResult
(do
(res, log, merr) <- action $ logRequest req
(res, log, merr) <- action $ logRequest req <> logRequest opts
forM_ merr $ \e -> runErrorLog env cmd (e <> logError req)
return ((res, merr), log))
return res
Expand Down
3 changes: 0 additions & 3 deletions glean/glass/Glean/Glass/Logging.hs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@ instance ActionLog GleanGlassLogger where
class LogRequest a where
logRequest :: a -> GleanGlassLogger

instance LogRequest (DocumentSymbolsRequest, RequestOptions) where
logRequest (d, r) = logRequest d <> logRequest r

instance LogRequest a => LogRequest (Maybe a) where
logRequest = maybe mempty logRequest

Expand Down

0 comments on commit 646c27e

Please sign in to comment.