-
Notifications
You must be signed in to change notification settings - Fork 3
New metrics automation #118
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
base: main
Are you sure you want to change the base?
Changes from 18 commits
941fb19
5fbe9dd
f2cb3be
fb21e06
1f8ca7a
17597be
2ef97fc
01b8694
412034a
d26ab4e
1a5d7e0
55e622b
52d8d86
464660c
6fcd947
c2fad97
a12dd12
f649efe
ab66342
090176a
9c382b1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -264,6 +264,27 @@ function verifyMetricsDependencies() { | |||
requireDockerDaemon(); | ||||
} | ||||
|
||||
/** | ||||
* Ensures all dependencies required for generating metrics documentation from source code are installed. | ||||
* | ||||
* Checks for the presence of `make`, Python 3.10 or newer, Git, and at least one C++ compiler (`gcc` or `clang`). | ||||
* Exits the process with an error message if any dependency is missing. | ||||
*/ | ||||
function verifyMetricsExtractorDependencies() { | ||||
requireCmd('make', 'Your OS package manager'); | ||||
requirePython(); | ||||
requireCmd('git', 'Install Git: https://git-scm.com/downloads'); | ||||
try { | ||||
execSync('gcc --version', { stdio: 'ignore' }); | ||||
} catch { | ||||
try { | ||||
execSync('clang --version', { stdio: 'ignore' }); | ||||
} catch { | ||||
fail('A C++ compiler (gcc or clang) is required for tree-sitter compilation.'); | ||||
} | ||||
} | ||||
} | ||||
|
||||
// -------------------------------------------------------------------- | ||||
// Main CLI Definition | ||||
// -------------------------------------------------------------------- | ||||
|
@@ -394,9 +415,19 @@ const commonOptions = { | |||
function runClusterDocs(mode, tag, options) { | ||||
const script = path.join(__dirname, '../cli-utils/generate-cluster-docs.sh'); | ||||
const args = [mode, tag, options.dockerRepo, options.consoleTag, options.consoleDockerRepo]; | ||||
console.log(`⏳ Running ${script} with arguments: ${args.join(' ')}`); | ||||
|
||||
console.log(`🚀 Starting cluster (${mode}/${tag})...`); | ||||
|
||||
const startTime = Date.now(); | ||||
const r = spawnSync('bash', [script, ...args], { stdio: 'inherit', shell: true }); | ||||
if (r.status !== 0) process.exit(r.status); | ||||
const duration = ((Date.now() - startTime) / 1000).toFixed(1); | ||||
|
||||
if (r.status !== 0) { | ||||
console.error(`❌ Script failed with exit code ${r.status}`); | ||||
process.exit(r.status); | ||||
} else { | ||||
console.log(`✅ Completed ${mode} docs generation (${duration}s)`); | ||||
} | ||||
} | ||||
|
||||
// helper to diff two autogenerated directories | ||||
|
@@ -429,7 +460,51 @@ function diffDirs(kind, oldTag, newTag) { | |||
|
||||
automation | ||||
.command('metrics-docs') | ||||
.description('Generate JSON and AsciiDoc documentation for Redpanda metrics') | ||||
.description('Generate JSON and AsciiDoc documentation for Redpanda metrics from source code') | ||||
.requiredOption('-r, --redpanda-repo <path>', 'Path to the Redpanda repository root directory') | ||||
.option('--json-output <path>', 'Custom path for JSON output file', 'autogenerated/metrics.json') | ||||
.option('--internal-asciidoc <path>', 'Custom path for internal metrics AsciiDoc file', 'autogenerated/internal_metrics_reference.adoc') | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like these new options for specify paths. We don't typically use underscores in Asciidoc filenames. Please replace with hyphens. |
||||
.option('--external-asciidoc <path>', 'Custom path for external/public metrics AsciiDoc file', 'autogenerated/public_metrics_reference.adoc') | ||||
.action((options) => { | ||||
console.log(`🎯 Starting enhanced metrics extraction from source code`); | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||
|
||||
verifyMetricsExtractorDependencies(); | ||||
|
||||
// Verify Redpanda repository path exists | ||||
if (!fs.existsSync(options.redpandaRepo)) { | ||||
console.error(`❌ Redpanda repository path does not exist: ${options.redpandaRepo}`); | ||||
process.exit(1); | ||||
} | ||||
|
||||
console.log(`⏳ Extracting metrics from ${options.redpandaRepo}...`); | ||||
|
||||
const startTime = Date.now(); | ||||
const result = spawnSync('python3', [ | ||||
path.join(__dirname, '../tools/metrics-extractor/metrics_extractor.py'), | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since you have a Makefile, we should execute |
||||
'--redpanda-repo', options.redpandaRepo, | ||||
'--json-output', options.jsonOutput, | ||||
'--internal-asciidoc', options.internalAsciidoc, | ||||
'--external-asciidoc', options.externalAsciidoc | ||||
], { stdio: 'inherit' }); | ||||
|
||||
const duration = ((Date.now() - startTime) / 1000).toFixed(1); | ||||
|
||||
if (result.status !== 0) { | ||||
console.error(`❌ Metrics extraction failed with exit code ${result.status}`); | ||||
process.exit(result.status); | ||||
} | ||||
|
||||
console.log(`✅ Enhanced metrics extraction completed! (${duration}s)`); | ||||
console.log(`📄 Generated files:`); | ||||
console.log(` JSON: ${options.jsonOutput}`); | ||||
console.log(` Internal metrics: ${options.internalAsciidoc}`); | ||||
console.log(` Public metrics: ${options.externalAsciidoc}`); | ||||
process.exit(0); | ||||
}); | ||||
|
||||
automation | ||||
.command('metrics-docs-legacy') | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would just remove the legacy implementation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We're using semver versioning, so we can always install a previous version to try it again. |
||||
.description('Generate JSON and AsciiDoc documentation for Redpanda metrics using Docker cluster (legacy)') | ||||
.requiredOption('-t, --tag <tag>', 'Redpanda version to use when starting Redpanda in Docker') | ||||
.option( | ||||
'--docker-repo <repo>', | ||||
|
@@ -448,6 +523,8 @@ automation | |||
) | ||||
.option('--diff <oldTag>', 'Also diff autogenerated metrics from <oldTag> → <tag>') | ||||
.action((options) => { | ||||
console.log(`🎯 Starting legacy metrics docs generation for ${options.tag}`); | ||||
|
||||
verifyMetricsDependencies(); | ||||
|
||||
const newTag = options.tag; | ||||
|
@@ -456,18 +533,20 @@ automation | |||
if (oldTag) { | ||||
const oldDir = path.join('autogenerated', oldTag, 'metrics'); | ||||
if (!fs.existsSync(oldDir)) { | ||||
console.log(`⏳ Generating metrics docs for old tag ${oldTag}…`); | ||||
console.log(`⏳ Generating metrics docs for old tag ${oldTag}...`); | ||||
runClusterDocs('metrics', oldTag, options); | ||||
} | ||||
} | ||||
|
||||
console.log(`⏳ Generating metrics docs for new tag ${newTag}…`); | ||||
console.log(`⏳ Generating metrics docs for new tag ${newTag}...`); | ||||
runClusterDocs('metrics', newTag, options); | ||||
|
||||
if (oldTag) { | ||||
console.log(`🔄 Diffing ${oldTag} → ${newTag}...`); | ||||
diffDirs('metrics', oldTag, newTag); | ||||
} | ||||
|
||||
console.log(`✅ Legacy metrics docs generation completed!`); | ||||
process.exit(0); | ||||
}); | ||||
|
||||
|
@@ -713,6 +792,41 @@ automation | |||
process.exit(0); | ||||
}); | ||||
|
||||
automation | ||||
.command('source-metrics-docs') | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure why this is a separate command. This should be called There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please also keep support for specifying paths for the output |
||||
.description('Generate metrics documentation from Redpanda source code using tree-sitter') | ||||
.option('--tag <tag>', 'Git tag or branch to extract from', 'dev') | ||||
.option('--diff <oldTag>', 'Also diff autogenerated metrics from <oldTag> → <tag>') | ||||
.action((options) => { | ||||
verifyMetricsExtractorDependencies(); | ||||
|
||||
const newTag = options.tag; | ||||
const oldTag = options.diff; | ||||
const cwd = path.resolve(__dirname, '../tools/metrics-extractor'); | ||||
const make = (tag) => { | ||||
console.log(`⏳ Building source-based metrics docs for ${tag}…`); | ||||
const r = spawnSync('make', ['build', `TAG=${tag}`], { cwd, stdio: 'inherit' }); | ||||
if (r.error) { | ||||
console.error(`❌ ${r.error.message}`); | ||||
process.exit(1); | ||||
} | ||||
if (r.status !== 0) process.exit(r.status); | ||||
}; | ||||
|
||||
if (oldTag) { | ||||
const oldDir = path.join('autogenerated', oldTag, 'source-metrics'); | ||||
if (!fs.existsSync(oldDir)) make(oldTag); | ||||
} | ||||
|
||||
make(newTag); | ||||
|
||||
if (oldTag) { | ||||
diffDirs('source-metrics', oldTag, newTag); | ||||
} | ||||
|
||||
process.exit(0); | ||||
}); | ||||
Comment on lines
+795
to
+828
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Well-implemented command following established patterns This However, having both 🤖 Prompt for AI Agents
|
||||
|
||||
automation | ||||
.command('rpk-docs') | ||||
.description('Generate AsciiDoc documentation for rpk CLI commands') | ||||
|
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 is this required? For the
property-docs
command, we require a tag and use that to clone and check out the repo.Please give this command the same signature as
property-docs
. It should support thediff
option.