cockroachdb / cockroach

CockroachDB — the cloud native, distributed SQL database designed for high availability, effortless scale, and control over data placement.
https://www.cockroachlabs.com
Other
30.16k stars 3.82k forks source link

sql: label latency histograms with statement fingerprint #135924

Open MattWhelan opened 5 hours ago

MattWhelan commented 5 hours ago

Previously, we collected a single histogram for all statements. While this sort of metric may be useful in overall database operations, application developers need more detail, to know how their code changes impact their query latencies.

By switching to HistogramVec, we can now offer per-statement-fingerprint latency metrics.

This feature is disabled by default. To know whether its safe to enable, we also track a cardinality estimate of the unique statement fingerprints that we see.

TREQ: https://cockroachlabs.atlassian.net/browse/TREQ-703

Release note (o11y change): The sql.distsql.exec.latency and sql.exec.latency metrics may now be labeled with their statement fingerprint. Enable this feature using the server.detailed_latency_metrics application setting.

The sql.query.unique.count metric is a new count metric that estimates the cardinality of the set of all statement fingerprints. For most workloads, this ranges from dozens to hundreds. For workloads with over a couple thousand fingerprints, we advise caution in enabling server.detailed_latency_metrics.

cockroach-teamcity commented 5 hours ago

CLA assistant check
All committers have signed the CLA.

cockroach-teamcity commented 5 hours ago

This change is Reviewable