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 batch execution via inspector. #361

Merged
merged 1 commit into from
Mar 18, 2024
Merged

Conversation

Laimiux
Copy link
Collaborator

@Laimiux Laimiux commented Mar 18, 2024

What

I'm adding onBatchStarted and onBatchFinished to the Inspector interface. This will enable us to debug how well event batching works.

@carrotkite
Copy link

1 Warning
⚠️ No coverage data found for com/instacart/formula/plugin/Inspector

JaCoCo Code Coverage 83.65% ✅

Class Covered Meta Status
com/instacart/formula/internal/ListInspector 0% 0%
com/instacart/formula/plugin/Inspector No coverage data found : -% No coverage data found : -% 🃏
com/instacart/formula/FormulaRuntime 94% 0%

Generated by 🚫 Danger


private val actionInput = ActionDelegateFormula.Input(
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simplifying this test class, no need to delegate to another formula for this.

@Laimiux Laimiux force-pushed the laimonas/log-batch-execution branch from 5859e5a to d4a0dc3 Compare March 18, 2024 16:17
// Inspect!
for (inspector in listOf(localInspector, globalInspector)) {
// Filtering out logs before "batch-started"
val events = inspector.events.dropWhile { !it.contains("batch-started") }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I wonder if we should pass batchStartedEventPrefix as TestInspector field - to decipher this hidden "batch-started" dependency?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While for this use case, it's a small lift, generally, this pattern would be hard to manage when verifying multiple events such as evaluate-started, state-change, etc. In my opinion, it's just easier to have a single TestInspector` with all the cases managed there (with no customizations across tests).

"evaluate-finished: com.instacart.formula.types.IncrementActionFormula",
"evaluate-finished: null",
"formula-run-finished",
"batch-finished",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here with "batch-finished"

) : StatelessFormula<Unit, Int>() {
) : Formula<Unit, Int, Int>() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it need to be stateful now?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we increment integer state as part of the batched event.

@Laimiux Laimiux merged commit d106b81 into master Mar 18, 2024
3 checks passed
@Laimiux Laimiux deleted the laimonas/log-batch-execution branch March 18, 2024 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants