Commit 588f079
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.NewMetadata(), 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
NewMetadata(). 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 588f079
153 files changed
Lines changed: 3282 additions & 4600 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
- 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
- catalog
- hydrateddesccache
- lease
- schematelemetry
- colflow
- contention
- txnidcache
- execinfra
- inspect
- pgwire
- rowinfra
- 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 | |
|---|---|---|---|
| |||
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 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
31 | | - | |
| 30 | + | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
67 | | - | |
| 66 | + | |
| 67 | + | |
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
148 | | - | |
| 148 | + | |
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
153 | 153 | | |
154 | | - | |
| 154 | + | |
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
| 45 | + | |
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| |||
0 commit comments