Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove cassandra db.name attribute #3199

Closed
wants to merge 1 commit into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

package io.opentelemetry.instrumentation.api.instrumenter.db;

import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
Expand All @@ -25,7 +26,10 @@ public abstract class DbAttributesExtractor<REQUEST, RESPONSE>
protected void onStart(AttributesBuilder attributes, REQUEST request) {
set(attributes, SemanticAttributes.DB_SYSTEM, system(request));
set(attributes, SemanticAttributes.DB_USER, user(request));
set(attributes, SemanticAttributes.DB_NAME, name(request));
AttributeKey<String> nameAttribute = dbNameAttribute();
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm this weirdness seems like a good reason to go to the spec and remove the keyspace attribute? Not filling in a generic attribute seems like a bug, non-cassandra aware tracing systems would still get benefit from it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Definitely see where #2892 came from ;)

Copy link
Member Author

@trask trask Jun 6, 2021

Choose a reason for hiding this comment

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

👍 can I block my own PR? 😂

if (nameAttribute != null) {
set(attributes, nameAttribute, name(request));
}
set(attributes, SemanticAttributes.DB_CONNECTION_STRING, connectionString(request));
set(attributes, SemanticAttributes.DB_STATEMENT, statement(request));
set(attributes, SemanticAttributes.DB_OPERATION, operation(request));
Expand All @@ -52,4 +56,8 @@ protected final void onEnd(

@Nullable
protected abstract String operation(REQUEST request);

protected AttributeKey<String> dbNameAttribute() {
return SemanticAttributes.DB_NAME;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public final class CassandraInstrumenters {
GlobalOpenTelemetry.get(), INSTRUMENTATION_NAME, spanName)
.addAttributesExtractor(attributesExtractor)
.addAttributesExtractor(new CassandraNetAttributesExtractor())
.addAttributesExtractor(new CassandraKeyspaceExtractor())
.newInstrumenter(SpanKindExtractor.alwaysClient());
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ protected String connectionString(CassandraRequest request) {
return null;
}

@Override
protected AttributeKey<String> dbNameAttribute() {
return SemanticAttributes.DB_CASSANDRA_KEYSPACE;
}

@Override
protected AttributeKey<String> dbTableAttribute() {
return SemanticAttributes.DB_CASSANDRA_TABLE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ class CassandraClientTest extends AgentInstrumentationSpecification {
"$SemanticAttributes.NET_PEER_IP.key" "127.0.0.1"
"$SemanticAttributes.NET_PEER_PORT.key" cassandraPort
"$SemanticAttributes.DB_SYSTEM.key" "cassandra"
"$SemanticAttributes.DB_NAME.key" keyspace
"$SemanticAttributes.DB_STATEMENT.key" statement
"$SemanticAttributes.DB_OPERATION.key" operation
"$SemanticAttributes.DB_CASSANDRA_KEYSPACE.key" keyspace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

package io.opentelemetry.javaagent.instrumentation.cassandra.v4_0;

import com.datastax.oss.driver.api.core.CqlIdentifier;
import com.datastax.oss.driver.api.core.config.DefaultDriverOption;
import com.datastax.oss.driver.api.core.config.DriverExecutionProfile;
import com.datastax.oss.driver.api.core.cql.ExecutionInfo;
Expand All @@ -20,12 +19,7 @@ final class CassandraAttributesExtractor
extends AttributesExtractor<CassandraRequest, ExecutionInfo> {

@Override
protected void onStart(AttributesBuilder attributes, CassandraRequest request) {
set(
attributes,
SemanticAttributes.DB_CASSANDRA_KEYSPACE,
request.getSession().getKeyspace().map(CqlIdentifier::toString).orElse(null));
}
protected void onStart(AttributesBuilder attributes, CassandraRequest request) {}

@Override
protected void onEnd(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ protected String user(CassandraRequest request) {
return null;
}

@Override
protected AttributeKey<String> dbNameAttribute() {
return SemanticAttributes.DB_CASSANDRA_KEYSPACE;
}

@Override
@Nullable
protected String name(CassandraRequest request) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ class CassandraClientTest extends AgentInstrumentationSpecification {
"$SemanticAttributes.NET_PEER_IP.key" "127.0.0.1"
"$SemanticAttributes.NET_PEER_PORT.key" cassandraPort
"$SemanticAttributes.DB_SYSTEM.key" "cassandra"
"$SemanticAttributes.DB_NAME.key" keyspace
"$SemanticAttributes.DB_STATEMENT.key" statement
"$SemanticAttributes.DB_OPERATION.key" operation
"$SemanticAttributes.DB_CASSANDRA_CONSISTENCY_LEVEL.key" "LOCAL_ONE"
Expand Down