Skip to content
Open
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
4 changes: 2 additions & 2 deletions .build/build-resolver.xml
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@
<retry retrycount="3" retrydelay="10" >
<resolve>
<dependencies pomRef="all-pom"/>
<files dir="${build.dir.lib}/jars" layout="{artifactId}-{version}-{classifier}.{extension}" scopes="compile,provided,!system"/>
<files dir="${build.dir.lib}/jars" layout="{artifactId}-{version}-{classifier}.{extension}" scopes="compile,runtime,provided,!system"/>
</resolve>
</retry>
<retry retrycount="3" retrydelay="10" >
Expand All @@ -212,7 +212,7 @@
<retry retrycount="3" retrydelay="10" >
<resolve failOnMissingAttachments="true">
<dependencies pomRef="all-pom"/>
<files dir="${build.lib}" layout="{artifactId}-{version}-{classifier}.{extension}" scopes="compile,!provide,!system"/>
<files dir="${build.lib}" layout="{artifactId}-{version}-{classifier}.{extension}" scopes="compile,runtime,!provide,!system"/>
</resolve>
</retry>
<mkdir dir="${build.lib}/x86_64"/>
Expand Down
4 changes: 4 additions & 0 deletions .build/cassandra-build-maven-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -164,5 +164,9 @@
<artifactId>cassandra-accord</artifactId>
<classifier>tests</classifier>
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-sdk-testing</artifactId>
</dependency>
</dependencies>
</project>
21 changes: 21 additions & 0 deletions .build/cassandra-deps-maven-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -388,5 +388,26 @@
<groupId>org.passay</groupId>
<artifactId>passay</artifactId>
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-api</artifactId>
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-sdk</artifactId>
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-sdk-extension-autoconfigure</artifactId>
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-exporter-otlp</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.opentelemetry.semconv</groupId>
<artifactId>opentelemetry-semconv</artifactId>
</dependency>
</dependencies>
</project>
12 changes: 12 additions & 0 deletions .build/parent-maven-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1316,6 +1316,18 @@
<artifactId>passay</artifactId>
<version>1.6.4</version>
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-bom</artifactId>
<version>1.62.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>io.opentelemetry.semconv</groupId>
<artifactId>opentelemetry-semconv</artifactId>
<version>1.41.1</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
6 changes: 6 additions & 0 deletions conf/cassandra.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2999,3 +2999,9 @@ compression_dictionary_cache_size: 10
# Expired dictionaries will be removed from memory but can be reloaded if needed.
# Min unit: s
compression_dictionary_cache_expire: 24h

# OpenTelemetry integration
# If enabled, Cassandra can export telemetry using OpenTelemetry.
# Currently, only tracing is exported
# Default: false
opentelemetry_enabled: false
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move up to start section of EXPERIMENTAL FEATURES

6 changes: 6 additions & 0 deletions conf/cassandra_latest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2742,3 +2742,9 @@ compression_dictionary_cache_size: 10
# Expired dictionaries will be removed from memory but can be reloaded if needed.
# Min unit: s
compression_dictionary_cache_expire: 24h

# OpenTelemetry integration
# If enabled, Cassandra can export telemetry using OpenTelemetry.
# Currently, only tracing is exported
# Default: false
opentelemetry_enabled: false
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move up to start section of EXPERIMENTAL FEATURES

2 changes: 2 additions & 0 deletions src/java/org/apache/cassandra/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -1041,6 +1041,8 @@ public static void setClientMode(boolean clientMode)
public volatile CustomGuardrailConfig role_name_policy = new CustomGuardrailConfig();
public volatile AutoRepairConfig auto_repair = new AutoRepairConfig();

public volatile boolean opentelemetry_enabled = false;

/**
* The variants of paxos implementation and semantics supported by Cassandra.
*/
Expand Down
5 changes: 5 additions & 0 deletions src/java/org/apache/cassandra/config/DatabaseDescriptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -6255,6 +6255,11 @@ public static void setRepairDiskHeadroomRejectRatio(double value)
conf.repair_disk_headroom_reject_ratio = value;
}

public static boolean getOpenTelemetryEnabled()
{
return conf.opentelemetry_enabled;
}

@VisibleForTesting
public static void setPartitioner(String name)
{
Expand Down
11 changes: 11 additions & 0 deletions src/java/org/apache/cassandra/cql3/CQLStatement.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,17 @@ default boolean eligibleAsPreparedStatement()
return false;
}

/**
* The query summary describes a class of database queries and is useful as a grouping key.
* This is used in telemetry to group similar queries together.
*
* @see <a href="https://opentelemetry.io/docs/specs/semconv/db/database-spans/#generating-a-summary-of-the-query">Generating a summary of the query</a>
*/
default String getQuerySummary()
{
return "<unknown>";
}

abstract class Raw
{
protected VariableSpecifications bindVariables;
Expand Down
16 changes: 16 additions & 0 deletions src/java/org/apache/cassandra/cql3/statements/BatchStatement.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import java.util.concurrent.TimeUnit;

import javax.annotation.Nullable;
Expand Down Expand Up @@ -818,4 +819,19 @@ public AuditLogContext getAuditLogContext()
{
return new AuditLogContext(AuditLogEntryType.BATCH);
}

/**
* For batch statement, the query summary consists of deduplicated list of targets
* not to produce too long query summary.
*/
@Override
public String getQuerySummary()
{
TreeSet<String> summary = new TreeSet<>();
for (ModificationStatement statement : statements)
{
summary.add(statement.getQuerySummary());
}
return String.format("%s BATCH %s", type.name(), String.join(" ", summary));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,12 @@ public AuditLogContext getAuditLogContext()
return new AuditLogContext(AuditLogEntryType.CREATE_ROLE);
}

@Override
public String getQuerySummary()
{
return "CREATE ROLE";
}

@Override
public String obfuscatePassword(String query)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,12 @@ public final AuditLogContext getAuditLogContext()
return new AuditLogContext(AuditLogEntryType.DESCRIBE);
}

@Override
public String getQuerySummary()
{
return "DESCRIBE";
}

@Override
public final ResultMessage execute(QueryState state, QueryOptions options, Dispatcher.RequestTime requestTime) throws RequestValidationException, RequestExecutionException
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ public AuditLogContext getAuditLogContext()
return new AuditLogContext(AuditLogEntryType.DROP_IDENTITY);
}

@Override
public String getQuerySummary()
{
return "DROP IDENTITY";
}

@Override
public ResultMessage execute(ClientState state) throws RequestExecutionException, RequestValidationException
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,10 @@ public AuditLogContext getAuditLogContext()
{
return new AuditLogContext(AuditLogEntryType.DROP_ROLE);
}

@Override
public String getQuerySummary()
{
return "DROP ROLE";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,10 @@ public AuditLogContext getAuditLogContext()
{
return new AuditLogContext(AuditLogEntryType.LIST_PERMISSIONS);
}

@Override
public String getQuerySummary()
{
return "LIST PERMISSIONS";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,10 @@ public AuditLogContext getAuditLogContext()
{
return new AuditLogContext(AuditLogEntryType.LIST_ROLES);
}

@Override
public String getQuerySummary()
{
return "LIST ROLES";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,10 @@ public AuditLogContext getAuditLogContext()
{
return new AuditLogContext(AuditLogEntryType.LIST_SUPERUSERS);
}

@Override
public String getQuerySummary()
{
return "LIST SUPERUSERS";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,12 @@ public boolean eligibleAsPreparedStatement()
return true;
}

@Override
public String getQuerySummary()
{
return String.format("%s %s", type.name(), metadata.toString());
}

public void addFunctionsTo(List<Function> functions)
{
attrs.addFunctionsTo(functions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,12 @@ public AuditLogContext getAuditLogContext()
return new AuditLogContext(AuditLogEntryType.SELECT, keyspace(), table.name);
}

@Override
public String getQuerySummary()
{
return String.format("SELECT %s", table.toString());
}

// Simple wrapper class to avoid some code duplication
private static abstract class Pager
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,10 @@ public AuditLogContext getAuditLogContext()
{
return new AuditLogContext(AuditLogEntryType.TRUNCATE, keyspace(), name());
}

@Override
public String getQuerySummary()
{
return String.format("TRUNCATE %s", qualifiedName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ public AuditLogContext getAuditLogContext()
return new AuditLogContext(AuditLogEntryType.USE_KEYSPACE, keyspace);
}

@Override
public String getQuerySummary()
{
return String.format("USE %s", keyspace);
}

public String keyspace()
{
return keyspace;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,12 @@ public AuditLogContext getAuditLogContext()
return new AuditLogContext(AuditLogEntryType.ALTER_KEYSPACE, keyspaceName);
}

@Override
public String getQuerySummary()
{
return String.format("ALTER KEYSPACE %s", keyspaceName);
}

public String toString()
{
return String.format("%s (%s)", getClass().getSimpleName(), keyspaceName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@ public AuditLogContext getAuditLogContext()
return new AuditLogContext(AuditLogEntryType.ALTER_TABLE, keyspaceName, tableName);
}

@Override
public String getQuerySummary()
{
return String.format("ALTER TABLE %s.%s", keyspaceName, tableName);
}

public String toString()
{
return format("%s (%s, %s)", getClass().getSimpleName(), keyspaceName, tableName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ public AuditLogContext getAuditLogContext()
return new AuditLogContext(AuditLogEntryType.ALTER_TYPE, keyspaceName, typeName);
}

@Override
public String getQuerySummary()
{
return String.format("ALTER TYPE %s.%s", keyspaceName, typeName);
}

public String toString()
{
return String.format("%s (%s, %s)", getClass().getSimpleName(), keyspaceName, typeName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ public AuditLogContext getAuditLogContext()
return new AuditLogContext(AuditLogEntryType.ALTER_VIEW, keyspaceName, viewName);
}

@Override
public String getQuerySummary()
{
return String.format("ALTER VIEW %s.%s", keyspaceName, viewName);
}

public String toString()
{
return String.format("%s (%s, %s)", getClass().getSimpleName(), keyspaceName, viewName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ public AuditLogContext getAuditLogContext()
return new AuditLogContext(AuditLogEntryType.CREATE_TABLE_LIKE, targetKeyspace, targetTableName);
}

@Override
public String getQuerySummary()
{
return String.format("CREATE TABLE %s.%s LIKE %s.%s", targetKeyspace, targetTableName, sourceKeyspace, sourceTableName);
}

@Override
public boolean compatibleWith(ClusterMetadata metadata)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,12 @@ public AuditLogContext getAuditLogContext()
return new AuditLogContext(AuditLogEntryType.CREATE_AGGREGATE, keyspaceName, aggregateName);
}

@Override
public String getQuerySummary()
{
return String.format("CREATE AGGREGATE %s.%s", keyspaceName, aggregateName);
}

public String toString()
{
return String.format("%s (%s, %s)", getClass().getSimpleName(), keyspaceName, aggregateName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,12 @@ public AuditLogContext getAuditLogContext()
return new AuditLogContext(AuditLogEntryType.CREATE_FUNCTION, keyspaceName, functionName);
}

@Override
public String getQuerySummary()
{
return String.format("CREATE FUNCTION %s.%s", keyspaceName, functionName);
}

public String toString()
{
return String.format("%s (%s, %s)", getClass().getSimpleName(), keyspaceName, functionName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,12 @@ public AuditLogContext getAuditLogContext()
return new AuditLogContext(AuditLogEntryType.CREATE_INDEX, keyspaceName, indexName);
}

@Override
public String getQuerySummary()
{
return String.format("CREATE INDEX %s.%s", keyspaceName, indexName);
}

public String toString()
{
return String.format("%s (%s, %s)", getClass().getSimpleName(), keyspaceName, indexName);
Expand Down
Loading