Skip to content

Commit

Permalink
Track record staleness
Browse files Browse the repository at this point in the history
  • Loading branch information
codyborn committed Dec 16, 2024
1 parent 56fcc61 commit 939223e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 6 deletions.
20 changes: 20 additions & 0 deletions bin/stacks/dashboard-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,26 @@ export class DashboardStack extends cdk.NestedStack {
stat: 'Sum',
},
},
{
height: 6,
width: 12,
y: 68,
x: 0,
type: 'metric',
properties: {
metrics: _.flatMap(SUPPORTED_CHAINS, (chainId) => [
['Uniswap', `NotificationRecordStaleness-chain-${chainId}`, 'Service', `UniswapXService`],
['.', '.', '.', `.`, { stat: 'p99' }],
['.', '.', '.', `.`, { stat: 'p50' }],
['.', '.', '.', `.`, { stat: 'Average' }],
]),
view: 'timeSeries',
region,
title: 'DutchV2 Notification Record Staleness',
period: 300,
stat: 'p90',
},
},
{
height: 1,
width: 24,
Expand Down
2 changes: 1 addition & 1 deletion bin/stacks/lambda-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export class LambdaStack extends cdk.NestedStack {

const notificationConfig = {
startingPosition: aws_lambda.StartingPosition.TRIM_HORIZON,
batchSize: 10,
batchSize: 1,
retryAttempts: 0,
bisectBatchOnError: true,
reportBatchItemFailures: true,
Expand Down
15 changes: 10 additions & 5 deletions lib/handlers/order-notification/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,20 @@ export class OrderNotificationHandler extends DynamoStreamLambdaHandler<Containe
const order = CosignedV2DutchOrder.parse(newOrder.encodedOrder, newOrder.chainId)
const decayStartTime = order.info.cosignerData.decayStartTime
const currentTime = Math.floor(Date.now() / 1000) // Convert to seconds
const timeDifference = Number(decayStartTime) - currentTime
const decayTimeDifference = Number(decayStartTime) - currentTime
if (record.dynamodb && record.dynamodb.ApproximateCreationDateTime) {
const recordTimeDifference = record.dynamodb.ApproximateCreationDateTime - currentTime
const staleRecordMetricName = `NotificationRecordStaleness-chain-${newOrder.chainId.toString()}`
metrics.putMetric(staleRecordMetricName, recordTimeDifference)
}

// GPA currentlys sets mainnet decay start to 24 secs into the future
if (newOrder.chainId == ChainId.MAINNET && timeDifference > DUTCHV2_ORDER_LATENCY_THRESHOLD_SEC) {
// GPA currently sets mainnet decay start to 24 secs into the future
if (newOrder.chainId == ChainId.MAINNET && decayTimeDifference > DUTCHV2_ORDER_LATENCY_THRESHOLD_SEC) {
const staleOrderMetricName = `NotificationStaleOrder-chain-${newOrder.chainId.toString()}`
metrics.putMetric(staleOrderMetricName, 1, Unit.Count)
}
const staleOrderMetricName = `NotificationOrderStaleness-chain-${newOrder.chainId.toString()}`
metrics.putMetric(staleOrderMetricName, timeDifference)
const orderStalenessMetricName = `NotificationOrderStaleness-chain-${newOrder.chainId.toString()}`
metrics.putMetric(orderStalenessMetricName, decayTimeDifference)
}

const registeredEndpoints = await webhookProvider.getEndpoints({
Expand Down

0 comments on commit 939223e

Please sign in to comment.