cassandra table name should split out keyspace (#2177)

This commit is contained in:
Frank Spitulski 2021-02-03 07:20:19 -08:00 committed by GitHub
parent 1f22fcaab0
commit 71ceb7486c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -131,6 +131,11 @@ public class CassandraDatabaseClientTracer extends DatabaseClientTracer<CqlSessi
super.onStatement(span, statement);
String table = SqlStatementSanitizer.sanitize(statement).getTable();
if (table != null) {
// account for splitting out the keyspace, <keyspace>.<table>
int i = table.indexOf('.');
if (i > -1 && i + 1 < table.length()) {
table = table.substring(i + 1);
}
span.setAttribute(SemanticAttributes.DB_CASSANDRA_TABLE, table);
}
}

View File

@ -119,8 +119,8 @@ class CassandraClientTest extends AgentInstrumentationSpecification {
"$SemanticAttributes.DB_CASSANDRA_IDEMPOTENCE.key" Boolean
"$SemanticAttributes.DB_CASSANDRA_PAGE_SIZE.key" 5000
"$SemanticAttributes.DB_CASSANDRA_SPECULATIVE_EXECUTION_COUNT.key" 0
// the SqlStatementSanitizer can't handle CREATE statements or splitting out the keyspace
"$SemanticAttributes.DB_CASSANDRA_TABLE.key" { table -> (statement.contains("CREATE") || keyspace == null ? true : table.endsWith("users")) }
// the SqlStatementSanitizer can't handle CREATE statements yet
"$SemanticAttributes.DB_CASSANDRA_TABLE.key" { table -> (statement.contains("CREATE") || keyspace == null ? true : table == "users") }
}
}
}