graphql-engine-1.0.0: GraphQL API over Postgres
Safe HaskellNone
LanguageHaskell2010

Hasura.Tracing

Synopsis

Documentation

type TracingMetadata = [(Text, Text)] Source #

Any additional human-readable key-value pairs relevant to the execution of a block of code.

newtype Reporter Source #

Constructors

Reporter 

Fields

class Monad m => HasReporter m where Source #

A type class for monads which support some way to report execution traces.

See instance Tracing.HasReporter (AppM impl) in HasuraPro.App.

Minimal complete definition

Nothing

Methods

askReporter :: m Reporter Source #

Get the current tracer

Instances

Instances details
HasReporter m => HasReporter (MetadataStorageT m) Source # 
Instance details

Defined in Hasura.Metadata.Class

Monad m => HasReporter (PGMetadataStorageAppT m) Source # 
Instance details

Defined in Hasura.App

HasReporter m => HasReporter (ExceptT e m) Source # 
Instance details

Defined in Hasura.Tracing

HasReporter m => HasReporter (ReaderT r m) Source # 
Instance details

Defined in Hasura.Tracing

data TraceContext Source #

A trace context records the current active trace, the active span within that trace, and the span's parent, unless the current span is the root.

Constructors

TraceContext 

Fields

newtype TraceT m a Source #

The TraceT monad transformer adds the ability to keep track of the current trace context.

Instances

Instances details
MonadTrans TraceT Source # 
Instance details

Defined in Hasura.Tracing

Methods

lift :: Monad m => m a -> TraceT m a #

MonadReader r m => MonadReader r (TraceT m) Source # 
Instance details

Defined in Hasura.Tracing

Methods

ask :: TraceT m r #

local :: (r -> r) -> TraceT m a -> TraceT m a #

reader :: (r -> a) -> TraceT m a #

MonadError e m => MonadError e (TraceT m) Source # 
Instance details

Defined in Hasura.Tracing

Methods

throwError :: e -> TraceT m a #

catchError :: TraceT m a -> (e -> TraceT m a) -> TraceT m a #

MonadBaseControl b m => MonadBaseControl b (TraceT m) Source # 
Instance details

Defined in Hasura.Tracing

Associated Types

type StM (TraceT m) a

Methods

liftBaseWith :: (RunInBase (TraceT m) b -> b a) -> TraceT m a

restoreM :: StM (TraceT m) a -> TraceT m a

MonadBase b m => MonadBase b (TraceT m) Source # 
Instance details

Defined in Hasura.Tracing

Methods

liftBase :: b α -> TraceT m α

TableInfoRM b m => TableInfoRM b (TraceT m) Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache

TableCoreInfoRM b m => TableCoreInfoRM b (TraceT m) Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache

Monad m => Monad (TraceT m) Source # 
Instance details

Defined in Hasura.Tracing

Methods

(>>=) :: TraceT m a -> (a -> TraceT m b) -> TraceT m b #

(>>) :: TraceT m a -> TraceT m b -> TraceT m b #

return :: a -> TraceT m a #

Functor m => Functor (TraceT m) Source # 
Instance details

Defined in Hasura.Tracing

Methods

fmap :: (a -> b) -> TraceT m a -> TraceT m b #

(<$) :: a -> TraceT m b -> TraceT m a #

MonadFix m => MonadFix (TraceT m) Source # 
Instance details

Defined in Hasura.Tracing

Methods

mfix :: (a -> TraceT m a) -> TraceT m a #

Applicative m => Applicative (TraceT m) Source # 
Instance details

Defined in Hasura.Tracing

Methods

pure :: a -> TraceT m a #

(<*>) :: TraceT m (a -> b) -> TraceT m a -> TraceT m b #

liftA2 :: (a -> b -> c) -> TraceT m a -> TraceT m b -> TraceT m c #

(*>) :: TraceT m a -> TraceT m b -> TraceT m b #

(<*) :: TraceT m a -> TraceT m b -> TraceT m a #

MonadIO m => MonadIO (TraceT m) Source # 
Instance details

Defined in Hasura.Tracing

Methods

liftIO :: IO a -> TraceT m a #

MonadThrow m => MonadThrow (TraceT m) Source # 
Instance details

Defined in Hasura.Tracing

Methods

throwM :: Exception e => e -> TraceT m a #

MonadCatch m => MonadCatch (TraceT m) Source # 
Instance details

Defined in Hasura.Tracing

Methods

catch :: Exception e => TraceT m a -> (e -> TraceT m a) -> TraceT m a #

MonadMask m => MonadMask (TraceT m) Source # 
Instance details

Defined in Hasura.Tracing

Methods

mask :: ((forall a. TraceT m a -> TraceT m a) -> TraceT m b) -> TraceT m b #

uninterruptibleMask :: ((forall a. TraceT m a -> TraceT m a) -> TraceT m b) -> TraceT m b #

generalBracket :: TraceT m a -> (a -> ExitCase b -> TraceT m c) -> (a -> TraceT m b) -> TraceT m (b, c) #

HasHttpManagerM m => HasHttpManagerM (TraceT m) Source # 
Instance details

Defined in Hasura.Tracing

Methods

askHttpManager :: TraceT m Manager Source #

MonadIO m => MonadTrace (TraceT m) Source #

If the underlying monad can report trace data, then TraceT will collect it and hand it off to that reporter.

Instance details

Defined in Hasura.Tracing

UserInfoM m => UserInfoM (TraceT m) Source # 
Instance details

Defined in Hasura.Session

MonadTx m => MonadTx (TraceT m) Source # 
Instance details

Defined in Hasura.Backends.Postgres.Connection.MonadTx

Methods

liftTx :: TxE QErr a -> TraceT m a Source #

MonadResolveSource m => MonadResolveSource (TraceT m) Source # 
Instance details

Defined in Hasura.RQL.Types.Source

MetadataM m => MetadataM (TraceT m) Source # 
Instance details

Defined in Hasura.RQL.Types.Metadata

CacheRM m => CacheRM (TraceT m) Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache

SourceM m => SourceM (TraceT m) Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache

CacheRWM m => CacheRWM (TraceT m) Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache.Build

MonadMetadataStorageQueryAPI m => MonadMetadataStorageQueryAPI (TraceT m) Source # 
Instance details

Defined in Hasura.Metadata.Class

MonadMetadataStorage m => MonadMetadataStorage (TraceT m) Source # 
Instance details

Defined in Hasura.Metadata.Class

Methods

fetchMetadataResourceVersion :: TraceT m MetadataResourceVersion Source #

fetchMetadata :: TraceT m (Metadata, MetadataResourceVersion) Source #

fetchMetadataNotifications :: MetadataResourceVersion -> InstanceId -> TraceT m [(MetadataResourceVersion, CacheInvalidations)] Source #

setMetadata :: MetadataResourceVersion -> Metadata -> TraceT m MetadataResourceVersion Source #

notifySchemaCacheSync :: MetadataResourceVersion -> InstanceId -> CacheInvalidations -> TraceT m () Source #

getCatalogState :: TraceT m CatalogState Source #

setCatalogState :: CatalogStateType -> Value -> TraceT m () Source #

getMetadataDbUid :: TraceT m MetadataDbId Source #

checkMetadataStorageHealth :: TraceT m () Source #

getDeprivedCronTriggerStats :: [TriggerName] -> TraceT m [CronTriggerStats] Source #

getScheduledEventsForDelivery :: TraceT m ([CronEvent], [OneOffScheduledEvent]) Source #

insertCronEvents :: [CronEventSeed] -> TraceT m () Source #

insertOneOffScheduledEvent :: OneOffEvent -> TraceT m EventId Source #

insertScheduledEventInvocation :: Invocation 'ScheduledType -> ScheduledEventType -> TraceT m () Source #

setScheduledEventOp :: ScheduledEventId -> ScheduledEventOp -> ScheduledEventType -> TraceT m () Source #

unlockScheduledEvents :: ScheduledEventType -> [ScheduledEventId] -> TraceT m Int Source #

unlockAllLockedScheduledEvents :: TraceT m () Source #

clearFutureCronEvents :: ClearCronEvents -> TraceT m () Source #

getOneOffScheduledEvents :: ScheduledEventPagination -> [ScheduledEventStatus] -> TraceT m (WithTotalCount [OneOffScheduledEvent]) Source #

getCronEvents :: TriggerName -> ScheduledEventPagination -> [ScheduledEventStatus] -> TraceT m (WithTotalCount [CronEvent]) Source #

getInvocations :: GetInvocationsBy -> ScheduledEventPagination -> TraceT m (WithTotalCount [ScheduledEventInvocation]) Source #

deleteScheduledEvent :: ScheduledEventId -> ScheduledEventType -> TraceT m () Source #

insertAction :: ActionName -> SessionVariables -> [Header] -> Value -> TraceT m ActionId Source #

fetchUndeliveredActionEvents :: TraceT m [ActionLogItem] Source #

setActionStatus :: ActionId -> AsyncActionStatus -> TraceT m () Source #

fetchActionResponse :: ActionId -> TraceT m ActionLogResponse Source #

clearActionData :: ActionName -> TraceT m () Source #

setProcessingActionLogsToPending :: LockedActionIdArray -> TraceT m () Source #

HasResourceLimits m => HasResourceLimits (TraceT m) Source # 
Instance details

Defined in Hasura.Server.Limits

MonadQueryLog m => MonadQueryLog (TraceT m) Source # 
Instance details

Defined in Hasura.GraphQL.Logging

MonadQueryTags m => MonadQueryTags (TraceT m) Source # 
Instance details

Defined in Hasura.GraphQL.Execute.Backend

HttpLog m => HttpLog (TraceT m) Source # 
Instance details

Defined in Hasura.Server.Logging

Associated Types

type ExtraHttpLogMetadata (TraceT m) Source #

(MonadIO m, MonadBaseControl IO m) => UserAuthentication (TraceT (PGMetadataStorageAppT m)) Source # 
Instance details

Defined in Hasura.App

Methods

resolveUserInfo :: Logger Hasura -> Manager -> [Header] -> AuthMode -> Maybe ReqsText -> TraceT (PGMetadataStorageAppT m) (Either QErr (UserInfo, Maybe UTCTime, [Header])) Source #

MonadGQLExecutionCheck m => MonadGQLExecutionCheck (TraceT m) Source # 
Instance details

Defined in Hasura.GraphQL.Execute.Common

MonadExecuteQuery m => MonadExecuteQuery (TraceT m) Source # 
Instance details

Defined in Hasura.GraphQL.Transport.HTTP

ConsoleRenderer m => ConsoleRenderer (TraceT m) Source # 
Instance details

Defined in Hasura.Server.App

Methods

renderConsole :: Text -> AuthMode -> Bool -> Maybe Text -> TraceT m (Either String Text) Source #

MonadMetadataApiAuthorization m => MonadMetadataApiAuthorization (TraceT m) Source # 
Instance details

Defined in Hasura.Server.App

MFunctor TraceT Source # 
Instance details

Defined in Hasura.Tracing

Methods

hoist :: forall m n (b :: k). Monad m => (forall a. m a -> n a) -> TraceT m b -> TraceT n b

type ExtraHttpLogMetadata (TraceT m) Source # 
Instance details

Defined in Hasura.Server.Logging

type StM (TraceT m) a Source # 
Instance details

Defined in Hasura.Tracing

type StM (TraceT m) a = StM (ReaderT (TraceContext, Reporter) (WriterT TracingMetadata m)) a

runTraceT :: (HasReporter m, MonadIO m) => Text -> TraceT m a -> m a Source #

Run an action in the TraceT monad transformer. runTraceT delimits a new trace with its root span, and the arguments specify a name and metadata for that span.

runTraceTWith :: MonadIO m => TraceContext -> Reporter -> Text -> TraceT m a -> m a Source #

runTraceTInContext :: (MonadIO m, HasReporter m) => TraceContext -> Text -> TraceT m a -> m a Source #

Run an action in the TraceT monad transformer in an existing context.

runTraceTWithReporter :: MonadIO m => Reporter -> Text -> TraceT m a -> m a Source #

Run an action in the TraceT monad transformer in an existing context.

class Monad m => MonadTrace m where Source #

Monads which support tracing. TraceT is the standard example.

Methods

trace :: Text -> m a -> m a Source #

Trace the execution of a block of code, attaching a human-readable name.

currentContext :: m TraceContext Source #

Ask for the current tracing context, so that we can provide it to any downstream services, e.g. in HTTP headers.

currentReporter :: m Reporter Source #

Ask for the current tracing reporter

attachMetadata :: TracingMetadata -> m () Source #

Log some metadata to be attached to the current span

Instances

Instances details
MonadIO m => MonadTrace (TraceT m) Source #

If the underlying monad can report trace data, then TraceT will collect it and hand it off to that reporter.

Instance details

Defined in Hasura.Tracing

MonadTrace m => MonadTrace (AgentClientT m) Source # 
Instance details

Defined in Hasura.Backends.DataConnector.Agent.Client

MonadTrace m => MonadTrace (MetadataT m) Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache.Build

MonadTrace m => MonadTrace (MetadataStorageT m) Source # 
Instance details

Defined in Hasura.Metadata.Class

MonadTrace m => MonadTrace (RunT m) Source # 
Instance details

Defined in Hasura.RQL.Types.Run

MonadTrace m => MonadTrace (CacheRWT m) Source # 
Instance details

Defined in Hasura.RQL.DDL.Schema.Cache

MonadTrace m => MonadTrace (ExceptT e m) Source # 
Instance details

Defined in Hasura.Tracing

MonadTrace m => MonadTrace (ReaderT r m) Source # 
Instance details

Defined in Hasura.Tracing

MonadTrace m => MonadTrace (StateT e m) Source # 
Instance details

Defined in Hasura.Tracing

MonadTrace m => MonadTrace (TxET e m) Source # 
Instance details

Defined in Hasura.Backends.Postgres.Connection.MonadTx

Methods

trace :: Text -> TxET e m a -> TxET e m a Source #

currentContext :: TxET e m TraceContext Source #

currentReporter :: TxET e m Reporter Source #

attachMetadata :: TracingMetadata -> TxET e m () Source #

interpTraceT :: MonadTrace n => (m (a, TracingMetadata) -> n (b, TracingMetadata)) -> TraceT m a -> n b Source #

Reinterpret a TraceT action in another MonadTrace. This can be useful when you need to reorganize a monad transformer stack, for example, to embed an action in some monadic computation, while preserving tracing metadata and context.

For example, we use this function in various places in BackendExecute, where we receive an action to execute in some concrete monad transformer stack. See the various implementations of runQuery for examples. Ideally, the input computation's type would be sufficiently polymorphic that we would not need to reorder monads inthe transformer stack. However, the monad transformer stacks must be concrete, because their types are defined by an associated type family ExecutionMonad. Hence, we need to use this function to peel off the outermost TraceT constructor, and embed the computation in some other MonadTrace.

A second example is related to caching. The cacheLookup function returns an action in a concrete transformer stack, again because we are constrained by the usage of a type class. We need to reinterpret the TraceT component of this concrete stack in some other abstract monad transformer stack, using this function.

Laws:

interpTraceT id (hoist f (TraceT x)) = interpTraceT f (TraceT x)

word64ToHex :: Word64 -> Text Source #

Encode Word64 to 16 character hex string

hexToWord64 :: Text -> Maybe Word64 Source #

Decode 16 character hex string to Word64

injectHttpContext :: TraceContext -> [Header] Source #

Inject the trace context as a set of HTTP headers.

extractHttpContext :: [Header] -> IO (Maybe TraceContext) Source #

Extract the trace and parent span headers from a HTTP request and create a new TraceContext. The new context will contain a fresh span ID, and the provided span ID will be assigned as the immediate parent span.

injectEventContext :: TraceContext -> Value Source #

Inject the trace context as a JSON value, appropriate for storing in (e.g.) an event trigger payload.

extractEventContext :: Value -> IO (Maybe TraceContext) Source #

Extract a trace context from an event trigger payload.

tracedHttpRequest Source #

Arguments

:: MonadTrace m 
=> Request

http request that needs to be made

-> (Request -> m a)

a function that takes the traced request and executes it

-> m a 

Perform HTTP request which supports Trace headers using a HTTP.Request value

TODO REFACTOR: - inline performRequest so that we can be sure a trace is always logged - Inline try here since we always use that at call sites