Merge branch 'staging' into mainnet-beta
This commit is contained in:
@@ -38,6 +38,7 @@ enum METRIC_TYPES {
|
|||||||
endpoint_response_times_histogram = 'endpoint_response_times_histogram',
|
endpoint_response_times_histogram = 'endpoint_response_times_histogram',
|
||||||
endpoint_response_status = 'endpoint_response_status',
|
endpoint_response_status = 'endpoint_response_status',
|
||||||
gpa_fetch_duration = 'gpa_fetch_duration',
|
gpa_fetch_duration = 'gpa_fetch_duration',
|
||||||
|
last_ws_message_received_ts = 'last_ws_message_received_ts',
|
||||||
health_status = 'health_status',
|
health_status = 'health_status',
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,6 +110,20 @@ healthStatusGauge.addCallback((obs: ObservableResult) => {
|
|||||||
obs.observe(healthStatus, {});
|
obs.observe(healthStatus, {});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let lastWsMsgReceivedTs = 0;
|
||||||
|
const setLastReceivedWsMsgTs = (ts: number) => {
|
||||||
|
lastWsMsgReceivedTs = ts;
|
||||||
|
};
|
||||||
|
const lastWsReceivedTsGauge = meter.createObservableGauge(
|
||||||
|
METRIC_TYPES.last_ws_message_received_ts,
|
||||||
|
{
|
||||||
|
description: 'Timestamp of last received websocket message',
|
||||||
|
}
|
||||||
|
);
|
||||||
|
lastWsReceivedTsGauge.addCallback((obs: ObservableResult) => {
|
||||||
|
obs.observe(lastWsMsgReceivedTs, {});
|
||||||
|
});
|
||||||
|
|
||||||
const endpointResponseTimeHistogram = meter.createHistogram(
|
const endpointResponseTimeHistogram = meter.createHistogram(
|
||||||
METRIC_TYPES.endpoint_response_times_histogram,
|
METRIC_TYPES.endpoint_response_times_histogram,
|
||||||
{
|
{
|
||||||
@@ -202,4 +217,5 @@ export {
|
|||||||
gpaFetchDurationHistogram,
|
gpaFetchDurationHistogram,
|
||||||
responseStatusCounter,
|
responseStatusCounter,
|
||||||
handleHealthCheck,
|
handleHealthCheck,
|
||||||
|
setLastReceivedWsMsgTs,
|
||||||
};
|
};
|
||||||
|
|||||||
22
src/index.ts
22
src/index.ts
@@ -28,12 +28,18 @@ import {
|
|||||||
initialize,
|
initialize,
|
||||||
isVariant,
|
isVariant,
|
||||||
OrderSubscriber,
|
OrderSubscriber,
|
||||||
|
UserAccount,
|
||||||
|
Order,
|
||||||
} from '@drift-labs/sdk';
|
} from '@drift-labs/sdk';
|
||||||
|
|
||||||
import { logger, setLogLevel } from './utils/logger';
|
import { logger, setLogLevel } from './utils/logger';
|
||||||
|
|
||||||
import * as http from 'http';
|
import * as http from 'http';
|
||||||
import { gpaFetchDurationHistogram, handleHealthCheck } from './core/metrics';
|
import {
|
||||||
|
gpaFetchDurationHistogram,
|
||||||
|
handleHealthCheck,
|
||||||
|
setLastReceivedWsMsgTs,
|
||||||
|
} from './core/metrics';
|
||||||
import { handleResponseTime } from './core/middleware';
|
import { handleResponseTime } from './core/middleware';
|
||||||
import {
|
import {
|
||||||
SubscriberLookup,
|
SubscriberLookup,
|
||||||
@@ -252,6 +258,20 @@ const main = async () => {
|
|||||||
driftClient,
|
driftClient,
|
||||||
subscriptionConfig,
|
subscriptionConfig,
|
||||||
});
|
});
|
||||||
|
orderSubscriber.eventEmitter.on(
|
||||||
|
'onUpdate',
|
||||||
|
(
|
||||||
|
_account: UserAccount,
|
||||||
|
_updatedOrders: Order[],
|
||||||
|
_pubkey: PublicKey,
|
||||||
|
_slot: number,
|
||||||
|
dataType: 'raw' | 'decoded'
|
||||||
|
) => {
|
||||||
|
if (dataType === 'decoded') {
|
||||||
|
setLastReceivedWsMsgTs(Date.now());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
dlobProvider = getDLOBProviderFromOrderSubscriber(orderSubscriber);
|
dlobProvider = getDLOBProviderFromOrderSubscriber(orderSubscriber);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user