-
Notifications
You must be signed in to change notification settings - Fork 7
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
feat: ucan stream consumer w3 accum store/add size #146
Conversation
View stack outputs
|
stacks/upload-db-stack.js
Outdated
/** | ||
* This table tracks w3 wider metrics. | ||
*/ | ||
const w3MetricsTable = new Table(stack, 'w3-metrics', w3MetricsTableProps) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does the table have w3-
prefix? The others do not...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be admin-metrics
instead to signify it's not user facing?
test/upload-api.test.js
Outdated
|
||
// Get metrics before upload | ||
const beforeOperationW3Metrics = await getW3Metrics(t) | ||
const beforeW3AccumulatedSize = beforeOperationW3Metrics.find(row => row.name === W3_METRICS_NAMES.STORE_ADD_ACCUM_SIZE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please can we have a separate test('POST / updates metrics')
for example?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to do what you suggested and should have documented decision in PR description!
This is the integration tests and therefore we write real CAR files (a new one per PR/commit) that will live in S3/R2. Adding more individual tests will lead into more and more files that we will need to pay for storage + egress just for testing.
Probably I can suggest renaming this file to integration.test.js
and make test names more appropriate to include everything. Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ohhh ok, yeah renaming will be fine!
*/ | ||
export async function updateAccumulatedSize (ucanInvocations, ctx) { | ||
const invocationsWithStoreAdd = ucanInvocations.filter( | ||
inv => inv.value.att.find(a => a.can === STORE_ADD) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we consider also store/remove
into this calculation? Or, perhaps better - collect a separate metric that for store/remove-accumulated-size
(followup PR)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, follow up PR with your suggestion. The goal of this PR is to get a "this is the way we should do things". Then follow up PRs with consumers for each metrics will be just follow same pattern
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in tracking #117
test/upload-api.test.js
Outdated
const afterOperationW3Metrics = await getW3Metrics(t) | ||
const afterW3AccumulatedSize = afterOperationW3Metrics.find(row => row.name === W3_METRICS_NAMES.STORE_ADD_ACCUM_SIZE) | ||
|
||
return afterW3AccumulatedSize?.value > beforeW3AccumulatedSize.value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please can we test the real value after storing multiple times?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Goal here was to create a balance to get to a point where we do not have flaky tests. When this integration tests run in the PR scope is actually fine. However, they also run in staging. Making such assumption in staging can be problematic because of parallel engineer testing something in staging or when we hook up other tests in staging that write stuff there (for example, for w3infra)...
We can make a conditional more explicit. If is staging, just accept >
and if it is PR expect real value different.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did this in commit
ucan-invocation/constants.js
Outdated
|
||
// Metrics | ||
export const W3_METRICS_NAMES = { | ||
STORE_ADD_ACCUM_SIZE: `${STORE_ADD}-accumulated-size` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Meaning is basically the same but I would have gone for total
over accumulated
for succinctness - just wondering if there was a different reason?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed to total everywhere
ucan-invocation/tables/w3-metrics.js
Outdated
* | ||
* @param {Capabilities} operationsInv | ||
*/ | ||
incrementAccumulatedSize: async (operationsInv) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should either be specific to store add i.e. incrementStoreAddAccumulatedSize
or take the key as a param.
ed164c6
to
02d4ee1
Compare
02d4ee1
to
bc58362
Compare
stacks/upload-db-stack.js
Outdated
/** | ||
* This table tracks w3 wider metrics. | ||
*/ | ||
const adminMetricsTable = new Table(stack, 'metrics', adminMetricsTableProps) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const adminMetricsTable = new Table(stack, 'metrics', adminMetricsTableProps) | |
const adminMetricsTable = new Table(stack, 'admin-metrics', adminMetricsTableProps) |
test/integration.test.js
Outdated
|
||
// Get metrics before upload | ||
const beforeOperationMetrics = await getMetrics(t) | ||
const beforeAccumulatedSize = beforeOperationMetrics.find(row => row.name === METRICS_NAMES.STORE_ADD_ACCUM_SIZE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const beforeAccumulatedSize = beforeOperationMetrics.find(row => row.name === METRICS_NAMES.STORE_ADD_ACCUM_SIZE) | |
const beforeAccumulatedSize = beforeOperationMetrics.find(row => row.name === METRICS_NAMES.STORE_ADD_TOTAL_SIZE) |
test/integration.test.js
Outdated
|
||
// If staging accept more broad condition given multiple parallel tests can happen there | ||
if (stage === 'staging') { | ||
return afterAccumulatedSize?.value > beforeAccumulatedSize.value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return afterAccumulatedSize?.value > beforeAccumulatedSize.value | |
return afterAccumulatedSize?.value >= beforeAccumulatedSize.value + carSize |
test/integration.test.js
Outdated
// Check metrics were updated | ||
beforeAccumulatedSize && await pWaitFor(async () => { | ||
const afterOperationMetrics = await getMetrics(t) | ||
const afterAccumulatedSize = afterOperationMetrics.find(row => row.name === METRICS_NAMES.STORE_ADD_ACCUM_SIZE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const afterAccumulatedSize = afterOperationMetrics.find(row => row.name === METRICS_NAMES.STORE_ADD_ACCUM_SIZE) | |
const afterTotalSize = afterOperationMetrics.find(row => row.name === METRICS_NAMES.STORE_ADD_ACCUM_SIZE) |
@alanshaw addresses last comments, also renaming lambda consumer to include |
Adds a consumer to UCAN stream kinesis where total size of store/add operations is tracked in the system. To achieve this tracking, we simply consume UCAN stream, filter
store/add
operations and update a DynamoDB table row incrementing previous value in batches.This PR adds only one metric consumer. Follow up PRs for remaining systsem metrics will follow same pattern as what we decide here.
It includes:
Note that:
See DynamoDB Tables content after integration tests ran:
Closes #145