Safe Haskell | None |
---|---|
Language | Haskell2010 |
Send anonymized metrics to the telemetry server regarding usage of various features of Hasura.
The general workflow for telemetry is as follows:
- We generate metrics for each backend in the graphql-engine code and send it to
telemetryUrl
. The relevant types can be found in Hasura.Server.Telemetry.Types. - The
telemetryUrl
endpoint is handled by code in: https://github.com/hasura/hasura-analytics/tree/hge-upgrade, specifically manager/main.go and manager/analytics.go. This server endpoint receives the telemetry payload and sends it to another graphql-engine which runs locally and is backed by a postgres database. The database schema for the telemetry endpoint can also be found in the same repo under hge/migrations/. - The information from the postgres db can be viewed in Metabase: https://metabase.telemetry.hasura.io/browse/2/schema/public.
For more information about telemetry in general, visit the user-facing docs on the topic: https://hasura.io/docs/latest/graphql/core/guides/telemetry.
Synopsis
- data TelemetryLog = TelemetryLog {
- _tlLogLevel :: !LogLevel
- _tlType :: !Text
- _tlMessage :: !Text
- _tlHttpError :: !(Maybe TelemetryHttpError)
- data TelemetryHttpError = TelemetryHttpError {
- tlheStatus :: !(Maybe Status)
- tlheUrl :: !Text
- tlheHttpException :: !(Maybe HttpException)
- tlheResponse :: !(Maybe Text)
- mkHttpError :: Text -> Maybe (Response ByteString) -> Maybe HttpException -> TelemetryHttpError
- mkTelemetryLog :: Text -> Text -> Maybe TelemetryHttpError -> TelemetryLog
- telemetryUrl :: Text
- runTelemetry :: Logger Hasura -> Manager -> IO SchemaCache -> MetadataDbId -> InstanceId -> PGVersion -> IO void
- mkTelemetryPayload :: forall (b :: BackendType). HasTag b => MetadataDbId -> InstanceId -> Version -> PGVersion -> Maybe CI -> ServiceTimingMetrics -> RemoteSchemaMap -> ActionCache -> SourceInfo b -> TelemetryPayload
- computeMetrics :: forall (b :: BackendType). SourceInfo b -> Maybe ServiceTimingMetrics -> Maybe RemoteSchemaMap -> Maybe ActionCache -> Metrics
- computeActionsMetrics :: ActionCache -> ActionMetric
- versionToTopic :: Version -> Topic
Logging and error handling
data TelemetryLog Source #
Logging related
TelemetryLog | |
|
data TelemetryHttpError Source #
TelemetryHttpError | |
|
mkHttpError :: Text -> Maybe (Response ByteString) -> Maybe HttpException -> TelemetryHttpError Source #
mkTelemetryLog :: Text -> Text -> Maybe TelemetryHttpError -> TelemetryLog Source #
Endpoint
telemetryUrl :: Text Source #
Execution
:: Logger Hasura | |
-> Manager | |
-> IO SchemaCache | an action that always returns the latest schema cache |
-> MetadataDbId | |
-> InstanceId | |
-> PGVersion | |
-> IO void |
An infinite loop that sends updated telemetry data (Metrics
) every 24
hours. The send time depends on when the server was started and will
naturally drift.
Generate metrics
mkTelemetryPayload :: forall (b :: BackendType). HasTag b => MetadataDbId -> InstanceId -> Version -> PGVersion -> Maybe CI -> ServiceTimingMetrics -> RemoteSchemaMap -> ActionCache -> SourceInfo b -> TelemetryPayload Source #
Generate a telemetry payload for a specific source by computing their relevant metrics. Additional information that may not be relevant to a particular source such as service timing, remote schemas and actions, will be reported only with the default source.
computeMetrics :: forall (b :: BackendType). SourceInfo b -> Maybe ServiceTimingMetrics -> Maybe RemoteSchemaMap -> Maybe ActionCache -> Metrics Source #
Compute the relevant metrics for a specific source.
computeActionsMetrics :: ActionCache -> ActionMetric Source #
Compute the relevant metrics for actions from the action cache.
versionToTopic :: Version -> Topic Source #
Decide which topic (telemetry table) we should use based on the version.