metric: embed source file in Metadata for CODEOWNERS resolution#167494
Draft
angles-n-daemons wants to merge 1 commit intocockroachdb:masterfrom
Draft
metric: embed source file in Metadata for CODEOWNERS resolution#167494angles-n-daemons wants to merge 1 commit intocockroachdb:masterfrom
angles-n-daemons wants to merge 1 commit intocockroachdb:masterfrom
Conversation
Contributor
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
|
Your pull request contains more than 1000 changes. It is strongly encouraged to split big PRs into smaller chunks. 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf. |
Member
Previously, metric ownership was determined by a separate
gen-metric-owners tool that scanned Go source files via AST to find
metric.Metadata definitions, mapped each to its owning team via
CODEOWNERS, and produced a metric_owners.yaml file. This file was
checked into the tree but had no Bazel genrule, and required a
bespoke step in both ./dev generate and check-generated-code CI.
This commit eliminates that pipeline by embedding source file
information directly in metric.Metadata at definition time. A new
source_file proto field is populated by metric.InitMetadata(), which
captures the caller's file via runtime.Caller. At generation time,
cockroach gen metric-list resolves ownership by calling
codeowners.Match on each metric's source file — no separate AST
scanning needed.
To enforce adoption, a new metadatanew nogo analyzer flags bare
metric.Metadata{} composite literals that aren't wrapped in
InitMetadata(). The metric registry also logs a warning when metrics
are registered without a source file set.
Removed:
- pkg/cmd/gen-metric-owners and its Bazel target
- pkg/internal/metricscan/metric_owners.yaml and its go:embed wrapper
- The generateMetricOwners step from ./dev generate
- The bazel run //pkg/cmd/gen-metric-owners step from check-generated-code.sh
- The --metric-owners flag from cockroach gen metric-list
Epic: none
Release note: None
Co-Authored-By: roachdev-claude <roachdev-claude-bot@cockroachlabs.com>
588f079 to
52318d2
Compare
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.
Summary
source_filefield tometric.Metadataproto, populatedautomatically by a new
metric.NewMetadata()constructor viaruntime.Caller.cockroach gen metric-listresolves metricownership by calling
codeowners.Match()on each metric's sourcefile — eliminating the separate
gen-metric-ownersAST scanningtool,
metric_owners.yaml, and bespoke CI/dev steps.metadatanewnogo analyzer to enforce constructor usageacross the codebase.
Epic: none
Release note: None