Skip to content

Commit

Permalink
feat: log schema cache load time
Browse files Browse the repository at this point in the history
  • Loading branch information
steve-chavez committed Feb 21, 2024
1 parent 1a141c1 commit 3a3601c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- #2887, Add Preference `max-affected` to limit affected resources - @taimoorzaeem
- #3171, Add an ability to dump config via admin API - @skywriter
- #3061, Apply all function settings as transaction-scoped settings - @taimoorzaeem
- #3171, Log schema cache stats to stderr - @steve-chavez
- #3171, #3046, Log schema cache stats to stderr - @steve-chavez
- #3210, Dump schema cache through admin API - @taimoorzaeem

### Fixed
Expand Down
3 changes: 2 additions & 1 deletion src/PostgREST/AppState.hs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,8 @@ loadSchemaCache appState observer = do
Right sCache -> do
putSchemaCache appState $ Just sCache
observer $ SchemaCacheQueriedObs resultTime
observer $ SchemaCacheLoadedObs sCache
(t, _) <- timeItT $ observer $ SchemaCacheSummaryObs sCache
observer $ SchemaCacheLoadedObs t
return SCLoaded

-- | Current database connection status data ConnectionStatus
Expand Down
7 changes: 5 additions & 2 deletions src/PostgREST/Observation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ data Observation
| SchemaCacheFatalErrorObs SQL.UsageError Text
| SchemaCacheNormalErrorObs SQL.UsageError
| SchemaCacheQueriedObs Double
| SchemaCacheLoadedObs SchemaCache
| SchemaCacheSummaryObs SchemaCache
| SchemaCacheLoadedObs Double
| ConnectionRetryObs Int
| ConnectionPgVersionErrorObs SQL.UsageError
| DBListenerStart Text
Expand Down Expand Up @@ -70,8 +71,10 @@ observationMessage = \case
"An error ocurred when loading the schema cache. " <> jsonMessage usageErr
SchemaCacheQueriedObs resultTime ->
"Schema cache queried in " <> showMillis resultTime <> " milliseconds"
SchemaCacheLoadedObs sCache ->
SchemaCacheSummaryObs sCache ->
"Schema cache loaded " <> showSummary sCache
SchemaCacheLoadedObs resultTime ->
"Schema cache loaded in " <> showMillis resultTime <> " milliseconds"
ConnectionRetryObs delay ->
"Attempting to reconnect to the database in " <> (show delay::Text) <> " seconds..."
ConnectionPgVersionErrorObs usageErr ->
Expand Down

0 comments on commit 3a3601c

Please sign in to comment.