Add span for executeDDLQueryOnCluster

Signed-off-by: Frank Chen <frank.chen021@outlook.com>
This commit is contained in:
Frank Chen 2022-09-19 13:43:40 +08:00
parent e478079f07
commit b056bc1021
3 changed files with 10 additions and 0 deletions

View File

@ -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);

View File

@ -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

View File

@ -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.