feat(metering-and-billing): drift-check for plugin event dimensions - #6594
Draft
gergely-kurucz-konghq wants to merge 1 commit into
Conversation
Add a tool and scheduled workflow that keep the docs' "Captured event dimensions" reference in sync with the fields the Metering & Billing plugin actually emits. - tools/mb-event-dimensions/: extract-catalog.js reads the LuaLS `--doc` export (doc.json) of kong-ee cloudevent.lua and emits the field catalog; check-drift.js compares it against a committed snapshot and the rendered data file, reporting added/removed/type-changed fields. - .github/workflows/watch-mb-cloudevent.yml: runs the check daily against a kong-ee checkout and opens a PR (plus Slack ping) when the emitted fields drift from the docs. Depends on the kong-ee cloudevent.lua LuaLS annotations (separate PR).
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds tooling + a scheduled workflow that keep the docs' "Captured event dimensions" reference (on the Metering & Billing plugin page) in sync with the fields the plugin actually emits.
What
tools/mb-event-dimensions/(Node, ESM):extract-catalog.js— reads the LuaLS--docexport (doc.json) of kong-eecloudevent.luaand emits the emitted-event field catalog (per event type, inheritance resolved).check-drift.js— compares that catalog against a committed snapshot (event-fields.snapshot.json) and the rendered data file (app/_data/plugins/metering-and-billing.yaml); prints added / removed / type-changed fields and exits non-zero on drift.README.mdwith usage + example output..github/workflows/watch-mb-cloudevent.yml— daily (schedule+workflow_dispatch+ optionalrepository_dispatch); checks out kong-ee, runs the check, and on drift bumps the snapshot, opens a PR, and pings docs maintainers via Slack.Why
The event-dimension reference is hand-authored from
cloudevent.luaand would silently drift as the plugin evolves. This turns drift into a dated alert PR instead of a stale doc.How
The plugin's emitted fields are declared as LuaLS
---@class/---@fieldannotations in kong-ee (separate PR);lua-language-server --docexports them todoc.json, which these scripts consume — a declared, stable source rather than scraping imperative code. Verified end-to-end against the annotatedcloudevent.lua(clean = exit 0; add/remove/type-change = exit 1 with a clear diff).Fixes https://konghq.atlassian.net/browse/OM-433
Dependencies / sequencing
metering-and-billing.yamldata file added there).cloudevent.luaLuaLS-annotations PR to land (source ofdoc.json).lua-language-serverrelease (installed in the workflow).Checklist