Commit 52318d2
metric: embed source file in Metadata for CODEOWNERS resolution
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>1 parent 001a9ae commit 52318d2
170 files changed
Lines changed: 3304 additions & 4622 deletions
File tree
- build
- bazelutil
- github
- docs/generated/metrics
- pkg
- backup
- ccl
- changefeedccl
- cdcutils
- checkpoint
- kvevent
- schemafeed
- timers
- multitenantccl
- tenantcostclient
- tenantcostserver
- sqlproxyccl
- acl
- balancer
- cli
- cloud
- clusterversion
- cmd
- dev
- testdata/datadriven
- gen-metric-owners
- kv/datadoggen
- crosscluster
- logical
- physical
- featureflag
- gossip
- internal/metricscan
- jobs
- ingeststopped
- metricspoller
- kv
- bulk
- kvclient
- kvcoord
- kvstreamer
- kvprober
- kvserver
- allocator
- allocatorimpl
- mmaprototype
- asim/state
- concurrency
- intentresolver
- kvflowcontrol/rac2
- liveness
- logstore
- protectedts
- ptreconcile
- ptstorage
- raftentry
- rangefeed
- split
- storeliveness
- tenantrate
- tscache
- txnrecovery
- txnwait
- obs
- ash
- clustermetrics
- cmmetrics
- cmreader
- cmwatcher
- cmwriter
- raft
- rpc
- security
- clientcert
- server
- application_api
- license
- serverpb
- status
- telemetry
- spanconfig/spanconfigkvsubscriber
- sql
- bulkmerge
- catalog
- hydrateddesccache
- lease
- schematelemetry
- colflow
- contention
- txnidcache
- descmetadata
- execinfra
- importer
- inspect
- pgwire
- rowinfra
- schemachanger/scjob
- sqlliveness/slstorage
- sqlstats
- insights
- persistedsqlstats
- sslocal
- tablemetadatacache
- ttl/ttljob
- vecindex
- testutils/lint/passes/metadatanew
- ts
- util
- admission
- cidr
- log/logmetrics
- metric
- mon
- schedulerlatency
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
205 | 205 | | |
206 | 206 | | |
207 | 207 | | |
| 208 | + | |
208 | 209 | | |
209 | 210 | | |
210 | 211 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1654 | 1654 | | |
1655 | 1655 | | |
1656 | 1656 | | |
| 1657 | + | |
| 1658 | + | |
| 1659 | + | |
| 1660 | + | |
| 1661 | + | |
| 1662 | + | |
| 1663 | + | |
| 1664 | + | |
| 1665 | + | |
| 1666 | + | |
| 1667 | + | |
1657 | 1668 | | |
1658 | 1669 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | 64 | | |
69 | 65 | | |
70 | 66 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | 3 | | |
7 | | - | |
| 4 | + | |
8 | 5 | | |
9 | 6 | | |
10 | 7 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1208 | 1208 | | |
1209 | 1209 | | |
1210 | 1210 | | |
1211 | | - | |
1212 | | - | |
1213 | 1211 | | |
1214 | 1212 | | |
1215 | 1213 | | |
| |||
2761 | 2759 | | |
2762 | 2760 | | |
2763 | 2761 | | |
| 2762 | + | |
2764 | 2763 | | |
2765 | 2764 | | |
2766 | 2765 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
210 | 210 | | |
211 | 211 | | |
212 | 212 | | |
213 | | - | |
| 213 | + | |
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
178 | 178 | | |
179 | 179 | | |
180 | 180 | | |
181 | | - | |
| 181 | + | |
182 | 182 | | |
183 | 183 | | |
184 | 184 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
262 | 262 | | |
263 | 263 | | |
264 | 264 | | |
265 | | - | |
| 265 | + | |
266 | 266 | | |
267 | 267 | | |
268 | 268 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
606 | 606 | | |
607 | 607 | | |
608 | 608 | | |
609 | | - | |
| 609 | + | |
610 | 610 | | |
611 | 611 | | |
612 | 612 | | |
| |||
629 | 629 | | |
630 | 630 | | |
631 | 631 | | |
632 | | - | |
633 | | - | |
| 632 | + | |
| 633 | + | |
634 | 634 | | |
635 | 635 | | |
636 | 636 | | |
637 | 637 | | |
638 | 638 | | |
639 | 639 | | |
640 | 640 | | |
641 | | - | |
| 641 | + | |
642 | 642 | | |
643 | 643 | | |
644 | 644 | | |
| |||
0 commit comments