cockroachdb / cockroachdb/cockroach

logging: improve sampled query event sampling

Open
#104,623 0 comments 0 reactions 0 assignees View on GitHub
A-cluster-observability C-enhancement T-observability
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

Improve the query sampling logic to better handle the scenario where users always set a session or transaction property.

Example:
1. Begin transaction.
2. Every transaction first statement is `SET TRANSACTION READ ONLY`
3. `SET TRANSACTION READ ONLY` always gets logged because of [this](https://github.com/cockroachdb/cockroach/blob/7fb4c16da01ef83ce2b1a4b5cffdd4ee1a0931d6/pkg/sql/exec_log.go#L282) check . This causes the [last emitted time to get reset.](https://github.com/cockroachdb/cockroach/blob/7fb4c16da01ef83ce2b1a4b5cffdd4ee1a0931d6/pkg/sql/telemetry_logging.go#L96)
4. The statements following `SET TRANSACTION READ ONLY` will get ignored because the last emit time was just reset. The default requires 125 Milliseconds between events. If the user is executing multiple transaction concurrently each one will update reset the time, so even if the query took longer than 125 Milliseconds it would not be recorded.

Jira issue: CRDB-28639

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.