metric: embed source file in Metadata for CODEOWNERS resolution#167494
metric: embed source file in Metadata for CODEOWNERS resolution#167494angles-n-daemons wants to merge 1 commit intocockroachdb:masterfrom
Conversation
|
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. |
588f079 to
52318d2
Compare
jasonlmfong
left a comment
There was a problem hiding this comment.
overall makes sense, some comments
| recv := sql.MakeDistSQLReceiver( | ||
| ctx, | ||
| sql.NewMetadataCallbackWriter(rowResultWriter, metaFn), | ||
| sql.InitMetadataCallbackWriter(rowResultWriter, metaFn), |
There was a problem hiding this comment.
i don't think these are supposed to change?
| meta, ok := metadata.mu.registeredMetadata[name] | ||
| if !ok { | ||
| return metric.Metadata{}, nil, false | ||
| return metric.InitMetadata(metric.Metadata{}), nil, false |
There was a problem hiding this comment.
what happens when the metadata is empty?
| pkg := frame.Function | ||
| if idx := strings.LastIndex(pkg, "."); idx >= 0 { | ||
| pkg = pkg[:idx] | ||
| } |
There was a problem hiding this comment.
claude suggests that this can break for some paths that have more than one .
There was a problem hiding this comment.
maybe add some tests for this
angles-n-daemons
left a comment
There was a problem hiding this comment.
Thanks for the review Jason, really appreciate you catching these!
- MetadataCallbackWriter renames: Good eye — that was unintended collateral from the rename. Reverted all of them back to
New. - Empty metadata in cmmetrics: This one we actually need to keep since the linter will flag it otherwise.
LastIndex(".")bug: You were right to flag this. It broke for method receivers (e.g.pkg.(*Type).Method) and closures (pkg.init.func1) where there are multiple dots. Fixed it to find the last/and then take the first.after that, which correctly isolates the package in all cases.- Tests: Added tests covering plain functions, method receivers, and closures. All green.
a89a6e8 to
a61b6b9
Compare
|
Detected infrastructure failure (matched: ). Automatically rerunning failed jobs. (run link) |
1 similar comment
|
Detected infrastructure failure (matched: ). Automatically rerunning failed jobs. (run link) |
|
Detected infrastructure failure (matched: ). Automatically rerunning failed jobs. (run link) |
1 similar comment
|
Detected infrastructure failure (matched: ). Automatically rerunning failed jobs. (run link) |
|
Detected infrastructure failure (matched: ). Automatically rerunning failed jobs. (run link) |
|
Detected infrastructure failure (matched: ). Automatically rerunning failed jobs. (run link) |
1 similar comment
|
Detected infrastructure failure (matched: ). Automatically rerunning failed jobs. (run link) |
545d136 to
cb97091
Compare
| // "path/to/pkg.(*Type).Method". We find the last '/' to isolate | ||
| // the final segment, then take the first '.' after it — that | ||
| // always separates the package name from the symbol. | ||
| pkg := frame.Function |
There was a problem hiding this comment.
why frame.Function and not frame.File?
There was a problem hiding this comment.
Good call — switched to using frame.File directly. Go records module-relative paths in frame.File for code within a module, so strings.TrimPrefix(frame.File, modulePrefix) is all we need. Much simpler and avoids the dot-parsing complexity that Jason flagged.
Adds a `source_file` field to `metric.Metadata` proto, populated automatically by new `metric.InitMetadata()` and `metric.NewMetadata()` constructors via `runtime.Callers`. At generation time, `cockroach gen metric-list` resolves metric ownership by calling `codeowners.Match()` on each metric's source file — eliminating the separate `gen-metric-owners` AST scanning tool, `metric_owners.yaml`, and bespoke CI/dev steps. Adds a `metricmetadatainit` nogo analyzer to enforce constructor usage across the codebase. Epic: none Release note: None Co-Authored-By: roachdev-claude <roachdev-claude-bot@cockroachlabs.com>
cb97091 to
c533a65
Compare
jasonlmfong
left a comment
There was a problem hiding this comment.
looks good! thanks for addressing the comments
Metrics change detectedThis PR adds or updates one or more CRDB metrics. If you want these metrics to be exported by CRDB Cloud clusters to Internal CRL Datadog and/or included in the customer metric export integration (Essential metrics for standard deployment, and Essential metrics for advanced deployment), refer to this Installation and Usage guide of a CLI tool that syncs the metric mappings in managed-service. Run this CLI tool after your CRDB PR is merged.
Note: Your metric will appear in Internal CRL Datadog only after the managed-service PR merges and the new OTel configuration rolls out to at least one cluster running a CRDB build that includes this metric. Docs: cockroach-metric-sync Questions: reach out to @obs-india-prs |
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