Skip to content

Conversation

ZhouXing19
Copy link
Collaborator

@ZhouXing19 ZhouXing19 commented Aug 15, 2025

Previously, only metrics for executed SELECT|UPDATE|DELETE|INSERT statements are labeled, while their started equivalent are not labeled. This commit is to label these metrics. Since they are not frequently used metrics, they are not marked as Essential.

Fixes: #152074

Release note (ops change): sql.select.started.count, sql.insert.started.count, sql.update.started.count, sql.delete.started.count are now labeled with sql.count.

Copy link

blathers-crl bot commented Aug 15, 2025

It looks like your PR touches production code but doesn't add or edit any test code. Did you consider adding tests to your PR?

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

StaticLabels: metric.MakeLabelPairs(metric.LabelQueryType, "started-select"),
Essential: true,
Category: metric.Metadata_SQL,
HowToUse: "This high-level metric reflects workload volume. Monitor this metric to identify abnormal application behavior or patterns over time. If abnormal patterns emerge, apply the metric's time range to the SQL Activity pages to investigate interesting outliers or patterns. For example, on the Transactions page and the Statements page, sort on the Execution Count column. To find problematic sessions, on the Sessions page, sort on the Transaction Count column. Find the sessions with high transaction counts and trace back to a user or application.",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you say anything more specific about started vs other metrics that would be helpful here?

I'm also not sure this metric is "essential". Most customers use the executed metrics to count QPS so we should justify why they should also pay attention to these.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I searched Slack and found only 2 threads that explicitly mentioned using the started metrics for troubleshooting:

Additionally, the started metrics was introduced in #37264, which also introduced the executed metrics as a claimed more useful one.

So maybe we should close it for now until receiving explicit ask for this feature?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the "Essential:true" field per offline discussion.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that "started" shouldn't be essential.

Previously, only metrics for *executed* `SELECT|UPDATE|DELETE|INSERT`
statements are labeled, while their *started* equivalent are not labeled.
This commit is to label these metrics.

Ref cockroachdb#143536

Release note (ops change): TBD

<what was there before: Previously, ...>
<why it needed to change: This was inadequate because ...>
<what you did about it: To address this, this patch ...>
@ZhouXing19 ZhouXing19 marked this pull request as ready for review August 19, 2025 13:01
@ZhouXing19 ZhouXing19 requested a review from dhartunian August 19, 2025 13:01
Copy link
Collaborator

@dhartunian dhartunian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

Copy link
Collaborator

@dhartunian dhartunian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NVM I realized this needs an edit.

Help: "Number of SQL UPDATE statements started",
Measurement: "SQL Statements",
Unit: metric.Unit_COUNT,
LabeledName: "sql.count",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I was mistaken: these counts should not be aggregated along with other sql.count metrics because "started" and "executed" should not be added together.

This should be sql.started.count with label update for example.

Copy link
Member

@yuzefovich yuzefovich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yuzefovich reviewed 2 of 2 files at r2, all commit messages.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @dhartunian and @ZhouXing19)


-- commits line 10 at r2:
nit: this needs an update.

StaticLabels: metric.MakeLabelPairs(metric.LabelQueryType, "started-select"),
Essential: true,
Category: metric.Metadata_SQL,
HowToUse: "This high-level metric reflects workload volume. Monitor this metric to identify abnormal application behavior or patterns over time. If abnormal patterns emerge, apply the metric's time range to the SQL Activity pages to investigate interesting outliers or patterns. For example, on the Transactions page and the Statements page, sort on the Execution Count column. To find problematic sessions, on the Sessions page, sort on the Transaction Count column. Find the sessions with high transaction counts and trace back to a user or application.",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that "started" shouldn't be essential.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

metric: add static labels to sql.*.started.count
4 participants