Repository navigation
Rename SYSTEM INSTRUMENT 'parameters' to 'arguments' - #103854
Conversation
In the SYSTEM INSTRUMENT feature added in ClickHouse#89173, the values passed to handlers (LOG, SLEEP, PROFILE) were called 'parameters' in the column of `system.instrumentation`, the SQL syntax description, internal type aliases, member names and error messages. Strictly speaking, parameters are the named placeholders declared in a function/handler signature, while arguments are the actual values passed at call time. Since the column stores the values supplied to the handler (e.g. `[100]` for SLEEP), 'arguments' is the more accurate term. This patch renames consistently across: - `system.instrumentation.parameters` column to `arguments` (and its description) - The SQL syntax block in the `SYSTEM INSTRUMENT ADD` documentation: `HANDLER [PARAMETERS]` to `HANDLER [ARGUMENTS]` - Internal C++ type aliases `InstrumentedParameter` to `InstrumentedArgument` and `InstrumentParameter` to `InstrumentArgument` - AST/parser members `instrumentation_parameters` to `instrumentation_arguments` - Local variables (`params`/`param` to `args`/`arg`) and error messages - The example output and tests that select the column Also rewords "the `ALL` parameter" to "the `ALL` keyword" in the `SYSTEM INSTRUMENT REMOVE` docs, since `ALL` is a SQL keyword.
|
Workflow [PR], commit [3826458] Summary: ❌
AI ReviewSummaryThis PR consistently renames Findings
Final Verdict
|
There was a problem hiding this comment.
Pull request overview
Renames the SYSTEM INSTRUMENT handler value list concept from “parameters” to “arguments” across the user-facing system table/documentation and the internal parser/AST/manager plumbing for the XRay-based instrumentation feature.
Changes:
- Renamed
system.instrumentation.parameterscolumn toargumentsand updated system table implementation accordingly. - Renamed related parser/AST fields and internal type aliases from
*Parameter*to*Argument*. - Updated documentation and stateless tests to use the new column name and terminology.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/queries/0_stateless/03643_system_instrumentation_no_suspicious_lowcardinality.sql | Updates view creation to select arguments instead of parameters. |
| tests/queries/0_stateless/03642_system_instrument_add_remove.sh | Updates test queries selecting from system.instrumentation to use arguments. |
| src/Storages/System/StorageSystemInstrumentation.cpp | Renames the system table column and output population from parameters to arguments. |
| src/Parsers/ParserSystemQuery.cpp | Renames parser variables/AST field population to instrumentation_arguments. |
| src/Parsers/ASTSystemQuery.h | Renames the AST member/type alias to InstrumentArgument / instrumentation_arguments. |
| src/Parsers/ASTSystemQuery.cpp | Updates formatting to print instrumentation_arguments. |
| src/Interpreters/InterpreterSystemQuery.cpp | Passes instrumentation_arguments to InstrumentationManager::patchFunction. |
| src/Interpreters/InstrumentationManager.h | Renames type alias and stored point field from parameters to arguments. |
| src/Interpreters/InstrumentationManager.cpp | Renames logging/handler logic and stringification from parameters to arguments. |
| docs/en/sql-reference/statements/system.md | Updates SYSTEM INSTRUMENT syntax placeholder to [ARGUMENTS] and rewords ALL as a keyword. |
| docs/en/operations/system-tables/instrumentation.md | Renames documented system table column and example output to arguments. |
Comments suppressed due to low confidence (1)
src/Interpreters/InstrumentationManager.cpp:470
sleep()treats anyargs.size() > 1as a (min, max) pair and silently ignores any extra arguments. The docs describe either 1 value or 2 values; consider validatingargs.size()is exactly 1 or 2 and throwing a BAD_ARGUMENTS error otherwise. Also consider validatingmin <= maxbefore constructinguniform_real_distributionto avoid undefined/implementation-defined behavior for inverted ranges.
if (args.size() == 1)
{
duration_ms = static_cast<Int64>(1000 * get_value(args[0]));
}
else
{
auto min = get_value(args[0]);
auto max = get_value(args[1]);
std::uniform_real_distribution<> distrib(min, max);
duration_ms = static_cast<Int64>(1000 * distrib(random_generator));
}
The parser for `SYSTEM INSTRUMENT ADD` accepts string, integer, and float literals as arguments, but the error returned when no argument is provided only mentioned "string literal". This was misleading for users of the `SLEEP` handler that takes numeric arguments. Update the wording to list all accepted literal types. Addresses review comments: - ClickHouse#103854 (comment) - ClickHouse#103854 (comment)
The argument parsing loop in `SYSTEM INSTRUMENT ADD` only handled `String`, `Int64`, `UInt64` and `Float64` literals. Any other literal type (e.g. `NULL`) was consumed by the inner `ParserLiteral` without being added to `instrumentation_arguments` and without producing a parse error, leading to confusing follow-up failures. Add an explicit `else` branch that fails the parse with a clear `expected` message when an unsupported literal type is encountered, plus a regression test for `NULL`. Addresses review comment: - ClickHouse#103854 (comment)
`InstrumentedArgument` stores integers as `Int64`, but the parser also accepts non-negative integer literals which the lexer produces as `UInt64`. A `static_cast<Int64>` of a `UInt64` value larger than `Int64::max` silently wraps around to a negative number, e.g. passing `9223372036854775808` to the `SLEEP` handler ended up being interpreted as a negative duration. Range-check the `UInt64` value before the cast and emit a clear parse error when it does not fit in `Int64`. Add a regression test. Addresses review comment: - ClickHouse#103854 (comment)
The error thrown when the LOG handler is given the wrong number of
arguments was generic ("Expected exactly one argument for
instrumentation"), which is harder to interpret when multiple
handlers are configured for the same function. Make it explicit that
this check belongs to the LOG handler.
Addresses review comment:
- ClickHouse#103854 (comment)
| duration_ms = static_cast<Int64>(1000 * get_value(params[0])); | ||
| duration_ms = static_cast<Int64>(1000 * get_value(args[0])); | ||
| } | ||
| else |
There was a problem hiding this comment.
SLEEP still accepts any number of literals greater than 1, but this branch only consumes args[0] and args[1] and silently ignores extras. That breaks the documented contract (single duration or min max range) and can hide user mistakes like accidentally passing a third value.
Could we validate args.size() == 1 || args.size() == 2 and throw BAD_ARGUMENTS otherwise? While touching this branch, please also reject min > max before constructing std::uniform_real_distribution, because the standard requires min <= max.
LLVM Coverage Report
Changed lines: 79.25% (84/106) | lost baseline coverage: 1 line(s) · Uncovered code |
5e67948
|
Hi @pamarcos @antonio2368 — while reviewing this PR I found the following:
Happy to discuss — close anything that's wrong or already addressed. |
Reject `SLEEP` instrumentation argument counts other than one or two. Reject ranges where the minimum is greater than the maximum before constructing the distribution. ClickHouse#103854 (comment)
Use `formatQuerySingleLine` instead of `EXPLAIN SYNTAX` to test formatter output for `SYSTEM INSTRUMENT ADD` arguments. Make the reversed `SLEEP` range case explicit and verify failed validation leaves no matching instrumentation point behind. ClickHouse#105939 ClickHouse#103854 (comment)
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
The XRay-based
SYSTEM INSTRUMENTfeature now usesargumentsinstead ofparameters: thesystem.instrumentation.parameterscolumn was renamed toarguments, and theSYSTEM INSTRUMENT ADD ... HANDLER PARAMETERS ...syntax was renamed toSYSTEM INSTRUMENT ADD ... HANDLER ARGUMENTS .... Queries or automation that use the old column or syntax must be updated to use the new names; the old names are no longer supported.Documentation entry for user-facing changes
Details
In the
SYSTEM INSTRUMENTfeature added in #89173, the values passed to handlers (LOG,SLEEP,PROFILE) were calledparametersin thesystem.instrumentationcolumn, in the SQL syntax description, in internal type aliases, member names and error messages. Since they are values rather than declared placeholders, they should be calledarguments.This PR renames consistently across:
system.instrumentation.parameterscolumn ->arguments(and its description)SYSTEM INSTRUMENT ADDdocumentation:HANDLER [PARAMETERS]->HANDLER [ARGUMENTS]InstrumentedParameter->InstrumentedArgumentandInstrumentParameter->InstrumentArgumentinstrumentation_parameters->instrumentation_argumentsparams/param->args/arg) and error messagessystem.instrumentation.mdand the tests that select the columnAlso rewords "the
ALLparameter" to "theALLkeyword" in theSYSTEM INSTRUMENT REMOVEdocs, sinceALLis a SQL keyword.Note: the
system.trace_logtable did not have aparameterscolumn, so onlysystem.instrumentationis affected.Tests
All
SYSTEM INSTRUMENTrelated stateless tests were run with--test-runs 3(and--long-test-runs-ratio 1for the stress test), all passing:03642_system_instrument_add_remove03642_system_instrument_log03642_system_instrument_sleep03642_system_instrument_profile03642_system_instrument_entry_exit03642_system_instrument_stress03642_system_instrument_symbols03642_system_instrument_multiple_handlers03642_system_instrument_dispatch_bug03643_system_instrumentation_no_suspicious_lowcardinality01271_show_privilegesVersion info
26.6.1.186