Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/Core/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2057,6 +2057,17 @@ Max number of HTTP GET redirects hops allowed. Ensures additional security measu
\
DECLARE(Bool, use_client_time_zone, false, R"(
Use client timezone for interpreting DateTime string values, instead of adopting server timezone.
)", 0) \
\
DECLARE(Bool, send_profile_events, true, R"(
Enables or disables sending of [ProfileEvents](/native-protocol/server.md#profile-events) packets to the client.

This can be disabled to reduce network traffic for clients that do not require profile events.

Possible values:

- 0 — Disabled.
- 1 — Enabled.
)", 0) \
\
DECLARE(Bool, send_progress_in_http_headers, false, R"(
Expand Down
1 change: 1 addition & 0 deletions src/Core/SettingsChangesHistory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const VersionToSettingsChangesMap & getSettingsChangesHistory()
/// Note: please check if the key already exists to prevent duplicate entries.
addSettingsChanges(settings_changes_history, "25.11",
{
{"send_profile_events", false, true, "New setting. Whether to send profile events to the clients."},
{"into_outfile_create_parent_directories", false, false, "New setting"},
{"correlated_subqueries_default_join_kind", "left", "right", "New setting. Default join kind for decorrelated query plan."},
{"use_statistics_cache", 0, 0, "New setting"},
Expand Down
7 changes: 6 additions & 1 deletion src/Server/TCPHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ namespace Setting
extern const SettingsUInt64 poll_interval;
extern const SettingsSeconds receive_timeout;
extern const SettingsLogsLevel send_logs_level;
extern const SettingsBool send_profile_events;
extern const SettingsString send_logs_source_regexp;
extern const SettingsSeconds send_timeout;
extern const SettingsTimezone session_timezone;
Expand Down Expand Up @@ -583,7 +584,8 @@ void TCPHandler::runImpl()
CurrentThread::attachInternalTextLogsQueue(query_state->logs_queue, client_logs_level);
}

if (client_tcp_protocol_version >= DBMS_MIN_PROTOCOL_VERSION_WITH_INCREMENTAL_PROFILE_EVENTS)
const auto send_profile_events = query_state->query_context->getSettingsRef()[Setting::send_profile_events];
if (client_tcp_protocol_version >= DBMS_MIN_PROTOCOL_VERSION_WITH_INCREMENTAL_PROFILE_EVENTS && send_profile_events)
{
query_state->profile_queue = std::make_shared<InternalProfileEventsQueue>(std::numeric_limits<int>::max());
CurrentThread::attachInternalProfileEventsQueue(query_state->profile_queue);
Expand Down Expand Up @@ -1575,6 +1577,9 @@ void TCPHandler::sendExtremes(QueryState & state, const Block & extremes)

void TCPHandler::sendProfileEvents(QueryState & state)
{
if (!state.query_context->getSettingsRef()[Setting::send_profile_events])
return;

Stopwatch stopwatch;
Block block = ProfileEvents::getProfileEvents(host_name, state.profile_queue, state.last_sent_snapshots);
if (block.rows() != 0)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
default OK
enabled OK
disabled OK
18 changes: 18 additions & 0 deletions tests/queries/0_stateless/03418_send_profile_events_setting.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
# Tags: no-random-settings

set -euo pipefail

CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)

# shellcheck source=../shell_config.sh
. "$CURDIR"/../shell_config.sh

# default should send profile events without any explicit setting.
${CLICKHOUSE_CLIENT} -q 'SELECT 1' --profile-events-delay-ms=-1 --print-profile-events 2>&1 | grep -q "Query" && echo "default OK"
# enabled with explicit setting.
${CLICKHOUSE_CLIENT} -q 'SELECT 1 SETTINGS send_profile_events=1' --profile-events-delay-ms=-1 --print-profile-events 2>&1 | grep -q "Query" && echo "enabled OK"

# disabled with explicit setting.
${CLICKHOUSE_CLIENT} -q 'SELECT 1 SETTINGS send_profile_events=0' --profile-events-delay-ms=-1 --print-profile-events 2>&1 | grep -v "Query" | grep -q "1" && echo "disabled OK"

Loading