Skip to content

Commit 31c7aa4

Browse files
jjuliamolinmeta-codesync[bot]
authored andcommitted
log db properties to glean_database_stats
Summary: When landed, we can adjust the fact count alert D87927971 Reviewed By: malanka Differential Revision: D87868792 fbshipit-source-id: 48da22373f3b95413f9389479ae466c71b62789d
1 parent ee27941 commit 31c7aa4

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

glean/db/Glean/Database/Backup.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ doBackup env@Env{..} repo prefix site =
278278
dataSize
279279
locator
280280
excluded
281+
(metaProperties meta)
281282
say logInfo "finished"
282283
atomically $ do
283284
void $ Catalog.modifyMeta envCatalog repo $ \meta -> return meta

glean/db/Glean/Database/Logger.hs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ module Glean.Database.Logger (
1111
logDBStatistics
1212
) where
1313

14+
import Data.Aeson (encode)
15+
import Data.HashMap.Strict (HashMap)
1416
import Data.Text (Text)
17+
import Data.Text.Lazy (toStrict)
18+
import Data.Text.Lazy.Encoding (decodeUtf8)
1519

1620
import qualified Glean.Database.Types as Database
1721
import qualified Glean.Types as Thrift
@@ -29,6 +33,7 @@ logDBStatistics
2933
-> Int -- ^ Number of bytes backed up
3034
-> Text -- ^ Backup locator
3135
-> Bool -- ^ The db has exclude property
36+
-> HashMap Text Text -- ^ Database properties
3237
-> IO ()
3338
logDBStatistics
3439
env
@@ -37,18 +42,21 @@ logDBStatistics
3742
maybeOwnershipStats
3843
size
3944
locator
40-
excluded = do
45+
excluded
46+
properties = do
4147
let preamble = mconcat
4248
[ Logger.SetRepoName repo_name
4349
, Logger.SetRepoHash repo_hash
4450
]
4551

4652
-- We shoehorn a summary row into the format for query rows
47-
let summary = mconcat
53+
let propertiesJson = toStrict $ decodeUtf8 $ encode properties
54+
summary = mconcat
4855
[ Logger.SetPredicateSize size -- # bytes uploaded
4956
, Logger.SetPredicateCount factCount -- # total facts
5057
, Logger.SetUploadDestination locator
5158
, Logger.SetHasExcludeProperty excluded
59+
, Logger.SetDatabaseProperties propertiesJson
5260
]
5361
factCount = fromIntegral $ sum [predicateStats_count p| (_, p) <- preds]
5462

glean/db/Glean/Logger/Database.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ data GleanDatabaseLog
3131
| SetCount Int
3232
| SetSize Int
3333
| SetHasExcludeProperty Bool
34+
| SetDatabaseProperties Text
3435

3536
instance Semigroup GleanDatabaseLog where
3637
a <> b = GleanDatabaseLogAnd a b

0 commit comments

Comments
 (0)