Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Track record staleness #499

Merged
merged 3 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
codyborn marked this conversation as resolved.
Show resolved Hide resolved
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
Loading