2021-08-06 00:07:17 +03:00
|
|
|
module Hasura.Server.Metrics
|
2021-09-24 01:56:37 +03:00
|
|
|
( ServerMetricsSpec (..),
|
|
|
|
ServerMetrics (..),
|
|
|
|
createServerMetrics,
|
|
|
|
)
|
|
|
|
where
|
2021-08-06 00:07:17 +03:00
|
|
|
|
2021-09-24 01:56:37 +03:00
|
|
|
import Data.Kind (Type)
|
|
|
|
import GHC.TypeLits (Symbol)
|
|
|
|
import Hasura.Prelude
|
|
|
|
import System.Metrics
|
|
|
|
import System.Metrics.Distribution (Distribution)
|
|
|
|
import System.Metrics.Gauge (Gauge)
|
2021-08-06 00:07:17 +03:00
|
|
|
|
|
|
|
-- | A specification of the metrics tracked by the server.
|
|
|
|
--
|
|
|
|
-- The use of the "unit" type () for the "tag structure" type parameter of a
|
|
|
|
-- metric indicates that we prohibit that metric from being annotated with
|
|
|
|
-- tags.
|
2021-09-24 01:56:37 +03:00
|
|
|
data
|
|
|
|
ServerMetricsSpec ::
|
|
|
|
Symbol -> -- Metric name
|
|
|
|
MetricType -> -- Metric type, e.g. Counter, Gauge
|
|
|
|
Type -> -- Tag structure
|
|
|
|
Type
|
2021-08-06 00:07:17 +03:00
|
|
|
where
|
|
|
|
-- | Current Number of active Warp threads
|
2021-09-24 01:56:37 +03:00
|
|
|
WarpThreads ::
|
|
|
|
ServerMetricsSpec
|
|
|
|
"warp_threads"
|
|
|
|
'GaugeType
|
|
|
|
()
|
2021-08-06 00:07:17 +03:00
|
|
|
-- | Current number of active websocket connections
|
2021-09-24 01:56:37 +03:00
|
|
|
WebsocketConnections ::
|
|
|
|
ServerMetricsSpec
|
|
|
|
"websocket_connections"
|
|
|
|
'GaugeType
|
|
|
|
()
|
2021-08-06 00:07:17 +03:00
|
|
|
-- | Current number of active subscriptions
|
2021-09-24 01:56:37 +03:00
|
|
|
ActiveSubscriptions ::
|
|
|
|
ServerMetricsSpec
|
|
|
|
"active_subscriptions"
|
|
|
|
'GaugeType
|
|
|
|
()
|
2021-08-06 00:07:17 +03:00
|
|
|
-- | Total Number of events fetched from last 'Event Trigger Fetch'
|
2021-09-24 01:56:37 +03:00
|
|
|
NumEventsFetchedPerBatch ::
|
|
|
|
ServerMetricsSpec
|
|
|
|
"events_fetched_per_batch"
|
|
|
|
'DistributionType
|
|
|
|
()
|
2021-08-06 00:07:17 +03:00
|
|
|
-- | Current number of Event trigger's HTTP workers in process
|
2021-09-24 01:56:37 +03:00
|
|
|
NumEventHTTPWorkers ::
|
|
|
|
ServerMetricsSpec
|
|
|
|
"num_event_trigger_http_workers"
|
|
|
|
'GaugeType
|
|
|
|
()
|
2021-08-06 00:07:17 +03:00
|
|
|
-- | Time (in seconds) between the 'Event Trigger Fetch' from DB and the
|
|
|
|
-- processing of the event
|
2021-09-24 01:56:37 +03:00
|
|
|
EventQueueTime ::
|
|
|
|
ServerMetricsSpec
|
|
|
|
"event_queue_time"
|
|
|
|
'DistributionType
|
|
|
|
()
|
2022-03-09 01:59:28 +03:00
|
|
|
-- | The current schema cache metadata resource version
|
|
|
|
SchemaCacheMetadataResourceVersion ::
|
|
|
|
ServerMetricsSpec
|
|
|
|
"schema_cache_metadata_resource_version"
|
|
|
|
'GaugeType
|
|
|
|
()
|
2022-08-25 18:50:39 +03:00
|
|
|
-- | Current number active live queries
|
|
|
|
ActiveLiveQueries ::
|
|
|
|
ServerMetricsSpec
|
|
|
|
"active_livequeries"
|
|
|
|
'GaugeType
|
|
|
|
()
|
|
|
|
-- | Current number of streaming subscriptions
|
|
|
|
ActiveStreaming ::
|
|
|
|
ServerMetricsSpec
|
|
|
|
"active_streaming_subscriptions"
|
|
|
|
'GaugeType
|
|
|
|
()
|
2022-11-21 10:47:45 +03:00
|
|
|
-- | Latency of fetching a batch of events
|
2022-11-16 20:10:59 +03:00
|
|
|
EventFetchTimePerBatch ::
|
|
|
|
ServerMetricsSpec
|
|
|
|
"events_fetch_time_per_batch"
|
|
|
|
'DistributionType
|
|
|
|
()
|
|
|
|
-- | The time (in seconds) between when a event is picked for delivery to the
|
|
|
|
-- time its status is updated in the DB
|
2022-11-21 10:47:45 +03:00
|
|
|
EventWebhookProcessingTime ::
|
2022-11-16 20:10:59 +03:00
|
|
|
ServerMetricsSpec
|
2022-11-21 10:47:45 +03:00
|
|
|
"event_webhook_processing_time"
|
2022-11-16 20:10:59 +03:00
|
|
|
'DistributionType
|
|
|
|
()
|
2022-12-06 18:09:18 +03:00
|
|
|
-- | The time taken for an event to be delivered since it's been created (if
|
|
|
|
-- first attempt) or retried (after first attempt)
|
|
|
|
EventProcessingTime ::
|
|
|
|
ServerMetricsSpec
|
|
|
|
"event_processing_time"
|
|
|
|
'DistributionType
|
|
|
|
()
|
2021-08-06 00:07:17 +03:00
|
|
|
|
|
|
|
-- | Mutable references for the server metrics. See `ServerMetricsSpec` for a
|
|
|
|
-- description of each metric.
|
2021-09-24 01:56:37 +03:00
|
|
|
data ServerMetrics = ServerMetrics
|
server: revert changes to created_at column of 'hdb_catalog.event_log'
This PR reverts the following two commits:
1. https://github.com/hasura/graphql-engine-mono/pull/8287
2. https://github.com/hasura/graphql-engine-mono/pull/8467
We are undoing a migration that was done on `hdb_catalog.event_log` table which was done in d4ae6a517da63f2f43567dc16fda135b3cd1d7e6 . And as such, users who were using event triggers on that version will come across the error:
```json
{"detail":{"info":{"code":"not-supported","error":"Expected source catalog version <= 3, but the current version is 4","path":"$"},"kind":"catalog_migrate"},"level":"error","timestamp":"2023-03-28T10:17:24.289+0530","type":"startup"}
{"code":"not-supported","error":"Expected source catalog version <= 3, but the current version is 4","path":"$"}
```
To fix these errors please run the following SQL on the source where event triggers were created on:
```
UPDATE hdb_catalog.hdb_source_catalog_version SET version = 3, upgraded_on= NOW();
ALTER table hdb_catalog.event_log ALTER COLUMN created_at SET DEFAULT NOW();
ALTER table hdb_catalog.event_invocation_logs ALTER COLUMN created_at SET DEFAULT NOW();
```
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8534
GitOrigin-RevId: b6bbcce0163c8beed80619d3cea056e643b8c180
2023-03-29 13:31:56 +03:00
|
|
|
{ smWarpThreads :: !Gauge,
|
|
|
|
smWebsocketConnections :: !Gauge,
|
|
|
|
smActiveSubscriptions :: !Gauge,
|
|
|
|
smNumEventsFetchedPerBatch :: !Distribution,
|
|
|
|
smNumEventHTTPWorkers :: !Gauge,
|
|
|
|
smEventQueueTime :: !Distribution,
|
|
|
|
smSchemaCacheMetadataResourceVersion :: !Gauge,
|
|
|
|
smActiveLiveQueries :: !Gauge,
|
|
|
|
smActiveStreamingSubscriptions :: !Gauge,
|
|
|
|
smEventFetchTimePerBatch :: !Distribution,
|
|
|
|
smEventWebhookProcessingTime :: !Distribution,
|
|
|
|
smEventProcessingTime :: !Distribution
|
2021-08-06 00:07:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
createServerMetrics :: Store ServerMetricsSpec -> IO ServerMetrics
|
|
|
|
createServerMetrics store = do
|
|
|
|
smWarpThreads <- createGauge WarpThreads () store
|
|
|
|
smWebsocketConnections <- createGauge WebsocketConnections () store
|
|
|
|
smActiveSubscriptions <- createGauge ActiveSubscriptions () store
|
|
|
|
smNumEventsFetchedPerBatch <- createDistribution NumEventsFetchedPerBatch () store
|
|
|
|
smNumEventHTTPWorkers <- createGauge NumEventHTTPWorkers () store
|
|
|
|
smEventQueueTime <- createDistribution EventQueueTime () store
|
2022-03-09 01:59:28 +03:00
|
|
|
smSchemaCacheMetadataResourceVersion <- createGauge SchemaCacheMetadataResourceVersion () store
|
2022-08-25 18:50:39 +03:00
|
|
|
smActiveLiveQueries <- createGauge ActiveLiveQueries () store
|
|
|
|
smActiveStreamingSubscriptions <- createGauge ActiveStreaming () store
|
2022-11-16 20:10:59 +03:00
|
|
|
smEventFetchTimePerBatch <- createDistribution EventFetchTimePerBatch () store
|
2022-11-21 10:47:45 +03:00
|
|
|
smEventWebhookProcessingTime <- createDistribution EventWebhookProcessingTime () store
|
2022-12-06 18:09:18 +03:00
|
|
|
smEventProcessingTime <- createDistribution EventProcessingTime () store
|
2021-09-24 01:56:37 +03:00
|
|
|
pure ServerMetrics {..}
|