Skip to content

feat(metering-and-billing): drift-check for plugin event dimensions - #6594

Draft
gergely-kurucz-konghq wants to merge 1 commit into
feat/OM-433-document-mb-plugin-event-dimensionsfrom
feat/OM-433-mb-event-dimensions-drift-check
Draft

feat(metering-and-billing): drift-check for plugin event dimensions#6594
gergely-kurucz-konghq wants to merge 1 commit into
feat/OM-433-document-mb-plugin-event-dimensionsfrom
feat/OM-433-mb-event-dimensions-drift-check

Conversation

@gergely-kurucz-konghq

Copy link
Copy Markdown

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 --doc export (doc.json) of kong-ee cloudevent.lua and 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.md with usage + example output.
  • .github/workflows/watch-mb-cloudevent.yml — daily (schedule + workflow_dispatch + optional repository_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.lua and 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/---@field annotations in kong-ee (separate PR); lua-language-server --doc exports them to doc.json, which these scripts consume — a declared, stable source rather than scraping imperative code. Verified end-to-end against the annotated cloudevent.lua (clean = exit 0; add/remove/type-change = exit 1 with a clear diff).

Fixes https://konghq.atlassian.net/browse/OM-433

Dependencies / sequencing

Checklist

  • Tooling verified locally (extract + drift-check against the real annotated file).
  • Tested how-to docs. — N/A (no page content changed; tooling + CI only).
  • No new docs pages (no index updates needed).
  • Merge after its base branch and the kong-ee annotations PR.

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).
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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.

2 participants