diff --git a/server/src-lib/Hasura/Server/Telemetry.hs b/server/src-lib/Hasura/Server/Telemetry.hs index 6d7cd4d16f5..b38bb826252 100644 --- a/server/src-lib/Hasura/Server/Telemetry.hs +++ b/server/src-lib/Hasura/Server/Telemetry.hs @@ -58,6 +58,7 @@ data Metrics = Metrics { _mtTables :: !Int , _mtViews :: !Int + , _mtEnumTables :: !Int , _mtRelationships :: !RelationshipMetric , _mtPermissions :: !PermissionMetric , _mtEventTriggers :: !Int @@ -128,12 +129,13 @@ runTelemetry (Logger logger) manager cacheRef dbId instanceId = do computeMetrics :: SchemaCache -> Metrics computeMetrics sc = - let nTables = Map.size $ Map.filter (isNothing . _tiViewInfo) usrTbls - nViews = Map.size $ Map.filter (isJust . _tiViewInfo) usrTbls - allRels = join $ Map.elems $ Map.map relsOfTbl usrTbls + let nTables = countUserTables (isNothing . _tiViewInfo) + nViews = countUserTables (isJust . _tiViewInfo) + nEnumTables = countUserTables (isJust . _tiEnumValues) + allRels = join $ Map.elems $ Map.map relsOfTbl userTables (manualRels, autoRels) = partition riIsManual allRels relMetrics = RelationshipMetric (length manualRels) (length autoRels) - rolePerms = join $ Map.elems $ Map.map permsOfTbl usrTbls + rolePerms = join $ Map.elems $ Map.map permsOfTbl userTables nRoles = length $ nub $ fst <$> rolePerms allPerms = snd <$> rolePerms insPerms = calcPerms _permIns allPerms @@ -143,14 +145,15 @@ computeMetrics sc = permMetrics = PermissionMetric selPerms insPerms updPerms delPerms nRoles evtTriggers = Map.size $ Map.filter (not . Map.null) - $ Map.map _tiEventTriggerInfoMap usrTbls + $ Map.map _tiEventTriggerInfoMap userTables rmSchemas = Map.size $ scRemoteSchemas sc funcs = Map.size $ Map.filter (not . fiSystemDefined) $ scFunctions sc - in Metrics nTables nViews relMetrics permMetrics evtTriggers rmSchemas funcs + in Metrics nTables nViews nEnumTables relMetrics permMetrics evtTriggers rmSchemas funcs where - usrTbls = Map.filter (not . _tiSystemDefined) $ scTables sc + userTables = Map.filter (not . _tiSystemDefined) $ scTables sc + countUserTables predicate = length . filter predicate $ Map.elems userTables calcPerms :: (RolePermInfo -> Maybe a) -> [RolePermInfo] -> Int calcPerms fn perms = length $ catMaybes $ map fn perms