Skip to content

Commit 8d77473

Browse files
Log latency of amendRefLinesIfMismatch
Summary: As titled Reviewed By: donsbot Differential Revision: D78560881 fbshipit-source-id: c19953c9497c01eac49411339e135c8c622d7236
1 parent 92d8c30 commit 8d77473

1 file changed

Lines changed: 28 additions & 17 deletions

File tree

glean/glass/Glean/Glass/Handler/Documents.hs

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -273,26 +273,37 @@ fetchSymbolsAndAttributesGlean
273273
match <- fromMaybe False <$> contentMatch revision1 revision2
274274
if match
275275
then return res -- revision match, no need to amend
276-
else do
277-
-- obtain line mapping from source diff
278-
diffResult <- backendRunHaxl be env $
279-
withRepo (snd (NonEmpty.head (gleanDBs be))) $ do
280-
getFileLineDiff sourceControl repo path revision1 revision2
281-
let mapping = parseGitDiff diffResult
282-
-- apply line mapping to references and definitions
283-
return res {
284-
refs = applyLineMappingToRefs mapping (refs res),
285-
defs = applyLineMappingToDefs mapping (defs res)
286-
}
276+
else
277+
let op = do
278+
-- obtain line mapping from source diff
279+
diffResult <- backendRunHaxl be env $
280+
withRepo (snd (NonEmpty.head (gleanDBs be))) $ do
281+
getFileLineDiff sourceControl repo path revision1 revision2
282+
let mapping = parseGitDiff diffResult
283+
-- apply line mapping to references and definitions
284+
return res {
285+
refs = applyLineMappingToRefs mapping (refs res),
286+
defs = applyLineMappingToDefs mapping (defs res)
287+
}
288+
in do
289+
(t, result) <- elapsedTime op
290+
let metricName = "glass.amend_lines.latency_ms"
291+
Stats.addStatValueType metricName (toDiffMillis t) Stats.Avg
292+
return result
287293

288294
contentMatch myrev wantedrev
289295
| myrev == wantedrev = return (Just True)
290-
| otherwise =
291-
backendRunHaxl be env $
292-
withRepo (snd (NonEmpty.head (gleanDBs be))) $ do
293-
wanted <- getFileContentHash sourceControl repo path wantedrev
294-
mine <- getFileContentHash sourceControl repo path myrev
295-
return $ (==) <$> wanted <*> mine
296+
| otherwise = let
297+
op = backendRunHaxl be env $
298+
withRepo (snd (NonEmpty.head (gleanDBs be))) $ do
299+
wanted <- getFileContentHash sourceControl repo path wantedrev
300+
mine <- getFileContentHash sourceControl repo path myrev
301+
return $ (==) <$> wanted <*> mine
302+
in do (t, result) <- elapsedTime op
303+
let metricName = "glass.content_match.latency_ms"
304+
Stats.addStatValueType metricName (toDiffMillis t) Stats.Avg
305+
return result
306+
296307

297308
shouldFetchContentHash :: RequestOptions -> Bool
298309
shouldFetchContentHash opts =

0 commit comments

Comments
 (0)