mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 01:12:56 +03:00
PLAT-75: Log uncompressed_response_size
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5827 GitOrigin-RevId: c98e5075f38737d9eb9cf467a62032ca5984304e
This commit is contained in:
parent
3fd5ea3965
commit
82f129ff7c
@ -61,6 +61,7 @@ import Control.Monad.Trans.Managed (ManagedT (..), allocate_)
|
||||
import Control.Retry qualified as Retry
|
||||
import Data.Aeson qualified as A
|
||||
import Data.ByteString.Char8 qualified as BC
|
||||
import Data.ByteString.Lazy qualified as BL
|
||||
import Data.ByteString.Lazy.Char8 qualified as BLC
|
||||
import Data.Environment qualified as Env
|
||||
import Data.FileEmbed (makeRelativeToProject)
|
||||
@ -1028,10 +1029,10 @@ instance (MonadIO m) => HttpLog (PGMetadataStorageAppT m) where
|
||||
mkHttpLog $
|
||||
mkHttpErrorLogContext userInfoM loggingSettings reqId waiReq req qErr Nothing Nothing headers
|
||||
|
||||
logHttpSuccess logger loggingSettings userInfoM reqId waiReq reqBody _response compressedResponse qTime cType headers (CommonHttpLogMetadata rb batchQueryOpLogs, ()) =
|
||||
logHttpSuccess logger loggingSettings userInfoM reqId waiReq reqBody response compressedResponse qTime cType headers (CommonHttpLogMetadata rb batchQueryOpLogs, ()) =
|
||||
unLogger logger $
|
||||
mkHttpLog $
|
||||
mkHttpAccessLogContext userInfoM loggingSettings reqId waiReq reqBody compressedResponse qTime cType headers rb batchQueryOpLogs
|
||||
mkHttpAccessLogContext userInfoM loggingSettings reqId waiReq reqBody (BL.length response) compressedResponse qTime cType headers rb batchQueryOpLogs
|
||||
|
||||
instance (Monad m) => MonadExecuteQuery (PGMetadataStorageAppT m) where
|
||||
cacheLookup _ _ _ _ = pure ([], Nothing)
|
||||
|
@ -381,6 +381,8 @@ data OperationLog = OperationLog
|
||||
{ olRequestId :: !RequestId,
|
||||
olUserVars :: !(Maybe SessionVariables),
|
||||
olResponseSize :: !(Maybe Int64),
|
||||
-- | Response size before compression
|
||||
olUncompressedResponseSize :: !Int64,
|
||||
-- | Request IO wait time, i.e. time spent reading the full request from the socket.
|
||||
olRequestReadTime :: !(Maybe Seconds),
|
||||
-- | Service time, not including request IO wait time.
|
||||
@ -455,6 +457,8 @@ mkHttpAccessLogContext ::
|
||||
RequestId ->
|
||||
Wai.Request ->
|
||||
(BL.ByteString, Maybe Value) ->
|
||||
-- | Size of response body, before compression
|
||||
Int64 ->
|
||||
BL.ByteString ->
|
||||
Maybe (DiffTime, DiffTime) ->
|
||||
Maybe CompressionType ->
|
||||
@ -462,7 +466,7 @@ mkHttpAccessLogContext ::
|
||||
RequestMode ->
|
||||
Maybe (GH.GQLBatchedReqs GQLBatchQueryOperationLog) ->
|
||||
HttpLogContext
|
||||
mkHttpAccessLogContext userInfoM loggingSettings reqId req (_, parsedReq) res mTiming compressTypeM headers batching queryLogMetadata =
|
||||
mkHttpAccessLogContext userInfoM loggingSettings reqId req (_, parsedReq) uncompressedResponseSize res mTiming compressTypeM headers batching queryLogMetadata =
|
||||
let http =
|
||||
HttpInfoLog
|
||||
{ hlStatus = status,
|
||||
@ -478,6 +482,7 @@ mkHttpAccessLogContext userInfoM loggingSettings reqId req (_, parsedReq) res mT
|
||||
{ olRequestId = reqId,
|
||||
olUserVars = _uiSession <$> userInfoM,
|
||||
olResponseSize = respSize,
|
||||
olUncompressedResponseSize = uncompressedResponseSize,
|
||||
olRequestReadTime = Seconds . fst <$> mTiming,
|
||||
olQueryExecutionTime = Seconds . snd <$> mTiming,
|
||||
olRequestMode = batching,
|
||||
@ -535,11 +540,13 @@ mkHttpErrorLogContext userInfoM loggingSettings reqId waiReq (reqBody, parsedReq
|
||||
hlCompression = compressTypeM,
|
||||
hlHeaders = headers
|
||||
}
|
||||
responseSize = BL.length $ encode err
|
||||
op =
|
||||
OperationLog
|
||||
{ olRequestId = reqId,
|
||||
olUserVars = _uiSession <$> userInfoM,
|
||||
olResponseSize = Just $ BL.length $ encode err,
|
||||
olResponseSize = Just responseSize,
|
||||
olUncompressedResponseSize = responseSize,
|
||||
olRequestReadTime = Seconds . fst <$> mTiming,
|
||||
olQueryExecutionTime = Seconds . snd <$> mTiming,
|
||||
olQuery = if (isQueryIncludedInLogs (hlPath http) loggingSettings) then parsedReq else Nothing,
|
||||
|
Loading…
Reference in New Issue
Block a user