diff --git a/src/Interpreters/executeDDLQueryOnCluster.cpp b/src/Interpreters/executeDDLQueryOnCluster.cpp index 06a6512e21b..016a740a7bc 100644 --- a/src/Interpreters/executeDDLQueryOnCluster.cpp +++ b/src/Interpreters/executeDDLQueryOnCluster.cpp @@ -55,6 +55,8 @@ bool isSupportedAlterType(int type) BlockIO executeDDLQueryOnCluster(const ASTPtr & query_ptr_, ContextPtr context, const DDLQueryOnClusterParams & params) { + OpenTelemetry::SpanHolder span(__FUNCTION__); + if (context->getCurrentTransaction() && context->getSettingsRef().throw_on_unsupported_query_inside_transaction) throw Exception(ErrorCodes::NOT_IMPLEMENTED, "ON CLUSTER queries inside transactions are not supported"); @@ -88,6 +90,8 @@ BlockIO executeDDLQueryOnCluster(const ASTPtr & query_ptr_, ContextPtr context, cluster = context->getCluster(query->cluster); } + span.addAttribute("clickhouse.cluster", query->cluster); + /// TODO: support per-cluster grant context->checkAccess(AccessType::CLUSTER); diff --git a/tests/queries/0_stateless/02423_ddl_for_opentelemetry.reference b/tests/queries/0_stateless/02423_ddl_for_opentelemetry.reference index 68152d602cf..09c15e5098e 100644 --- a/tests/queries/0_stateless/02423_ddl_for_opentelemetry.reference +++ b/tests/queries/0_stateless/02423_ddl_for_opentelemetry.reference @@ -1,17 +1,21 @@ ===case 1==== 1 1 +test_shard_localhost 2 ===case 2==== 1 1 +test_shard_localhost 2 ===case 3==== 1 1 +test_shard_localhost 2 ===case 4==== 1 1 +test_shard_localhost exception_code=60 exception_code=60 diff --git a/tests/queries/0_stateless/02423_ddl_for_opentelemetry.sh b/tests/queries/0_stateless/02423_ddl_for_opentelemetry.sh index 551e8b3c723..043a968104d 100755 --- a/tests/queries/0_stateless/02423_ddl_for_opentelemetry.sh +++ b/tests/queries/0_stateless/02423_ddl_for_opentelemetry.sh @@ -65,6 +65,7 @@ for ddl_version in 1 2 3; do check_span $trace_id "count()" "HTTPHandler" check_span $trace_id "count()" "%DDLWorker::processTask%" + check_span $trace_id "attribute['clickhouse.cluster']" "%executeDDLQueryOnCluster%" # There should be two 'query' spans, # one is for the HTTPHandler, the other is for the DDL executing in DDLWorker @@ -91,6 +92,7 @@ execute_query $trace_id "DROP TABLE ddl_test_for_opentelemetry_non_exist ON CLUS check_span $trace_id "count()" "HTTPHandler" check_span $trace_id "count()" "%DDLWorker::processTask%" +check_span $trace_id "attribute['clickhouse.cluster']" "%executeDDLQueryOnCluster%" # There should be two 'query' spans, # one is for the HTTPHandler, the other is for the DDL executing in DDLWorker.