Merge branch 'staging' into mainnet-beta

This commit is contained in:
wphan
2023-12-08 10:45:36 -08:00
2 changed files with 23 additions and 0 deletions

View File

@@ -39,6 +39,7 @@ enum METRIC_TYPES {
endpoint_response_status = 'endpoint_response_status',
gpa_fetch_duration = 'gpa_fetch_duration',
last_ws_message_received_ts = 'last_ws_message_received_ts',
account_updates_per_sec = 'account_updates_per_sec',
current_system_ts = 'current_system_ts',
health_status = 'health_status',
}
@@ -125,6 +126,20 @@ lastWsReceivedTsGauge.addCallback((obs: ObservableResult) => {
obs.observe(lastWsMsgReceivedTs, {});
});
let lastAccountUpdatesPerSecond = 0;
const setAccountUpdatesPerSecond = (updatesPerSecond: number) => {
lastAccountUpdatesPerSecond = updatesPerSecond;
};
const accountUpdatesPerSecondGauge = meter.createObservableGauge(
METRIC_TYPES.account_updates_per_sec,
{
description: 'Updates per second, the last second',
}
);
accountUpdatesPerSecondGauge.addCallback((obs: ObservableResult) => {
obs.observe(lastAccountUpdatesPerSecond, {});
});
const currentSystemTsGauge = meter.createObservableGauge(
METRIC_TYPES.current_system_ts,
{
@@ -229,4 +244,5 @@ export {
responseStatusCounter,
handleHealthCheck,
setLastReceivedWsMsgTs,
setAccountUpdatesPerSecond as setLastAccountUpdatesPerSecond,
};

View File

@@ -38,6 +38,7 @@ import * as http from 'http';
import {
gpaFetchDurationHistogram,
handleHealthCheck,
setLastAccountUpdatesPerSecond,
setLastReceivedWsMsgTs,
} from './core/metrics';
import { handleResponseTime } from './core/middleware';
@@ -254,6 +255,7 @@ const main = async () => {
};
}
let updatesPerTenSecond = 0;
const orderSubscriber = new OrderSubscriber({
driftClient,
subscriptionConfig,
@@ -262,8 +264,13 @@ const main = async () => {
'updateReceived',
(_pubkey: PublicKey, _slot: number, _dataType: 'raw' | 'decoded') => {
setLastReceivedWsMsgTs(Date.now());
updatesPerTenSecond++;
}
);
setInterval(() => {
setLastAccountUpdatesPerSecond(updatesPerTenSecond / 10);
updatesPerTenSecond = 0;
}, 10_000);
dlobProvider = getDLOBProviderFromOrderSubscriber(orderSubscriber);