Skip to content

Call NFPlugin.cleanup() at the end of the meter workflow#243

Open
drnpkr wants to merge 1 commit into
nfstream:masterfrom
drnpkr:fix/nfplugin-cleanup
Open

Call NFPlugin.cleanup() at the end of the meter workflow#243
drnpkr wants to merge 1 commit into
nfstream:masterfrom
drnpkr:fix/nfplugin-cleanup

Conversation

@drnpkr

@drnpkr drnpkr commented Jun 8, 2026

Copy link
Copy Markdown
Member

Problem

NFPlugin.cleanup() is documented ("Method called for plugin cleanup") but is never actually invoked anywhere in the package. Plugins that buffer state across flows — time-window/bin aggregators, file writers, batched exporters — have no hook to flush their final buffered state, so that data is silently lost at the end of a capture.

Fix

Invoke udp.cleanup() for each plugin in meter_workflow, right after meter_cleanup() has expired the remaining cached flows (so every on_expire hook has already run) and before the meter signals completion via channel.put(None).

Test

Adds test_plugin_cleanup: a plugin counts its on_expire calls and writes the total from cleanup(). The test asserts the marker file exists (i.e. cleanup() was actually called) and that the count equals the number of flows (i.e. it ran after all flows expired).

NFPlugin.cleanup() is documented ('Method called for plugin cleanup') but
was never actually invoked anywhere in the package. Plugins that buffer
state across flows (e.g. time-window aggregators) therefore had no hook to
flush their final entries, silently losing them at end of capture.

Invoke udp.cleanup() for each plugin in meter_workflow, right after
meter_cleanup() expires the remaining cached flows (so all on_expire hooks
have already run) and before signalling completion.

Add test_plugin_cleanup: asserts cleanup() runs after all flows expire.
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.

1 participant