Skip to content

Commit

Permalink
Renames type from CassandraDriver to CassandraClient
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrian Cole committed May 15, 2017
1 parent c6d5634 commit 8f0a91a
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 37 deletions.
12 changes: 6 additions & 6 deletions instrumentation/cassandra-driver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ By default, the following are added to cassandra client spans:
To change the span and tag naming policy, you can do something like this:

```java
cassandraDriverTracing = cassandraDriverTracing.toBuilder()
.parser(new CassandraParser() {
cassandraClientTracing = cassandraClientTracing.toBuilder()
.parser(new CassandraClientParser() {
@Override public String spanName(Statement statement) {
return "query";
}
Expand All @@ -37,7 +37,7 @@ cassandraDriverTracing = cassandraDriverTracing.toBuilder()
})
.build();

tracesSession = TracingSession.create(cassandraDriverTracing.clientOf("remote-cluster"), session);
tracesSession = TracingSession.create(cassandraClientTracing.clientOf("remote-cluster"), session);
```

## Sampling Policy
Expand All @@ -47,12 +47,12 @@ For example, if there's no trace already in progress, the sampler
indicated by `Tracing.Builder.sampler` decides whether or not to start a
new trace for the cassandra client request.

You can change the sampling policy by specifying it in the `CassandraDriverTracing`
You can change the sampling policy by specifying it in the `CassandraClientTracing`
component. Here's an example which only starts new traces for bound statements.

```java
cassandraDriverTracing = cassandraDriverTracing.toBuilder()
.sampler(new CassandraDriverSampler() {
cassandraClientTracing = cassandraClientTracing.toBuilder()
.sampler(new CassandraClientSampler() {
@Override public Boolean trySample(Statement statement) {
return statement instanceof BoundStatement;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Provides reasonable defaults for the data contained in cassandra client spans. Subclass to
* customize, for example, to add tags based on response headers.
*/
public class CassandraDriverParser {
public class CassandraClientParser {

/**
* Override to change what data from the statement are parsed into the span representing it. By
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@
*
* <p>Ex. Here's a sampler that only starts traces for bound statements
* <pre>{@code
* cassandraDriverTracingBuilder.serverSampler(new CassandraDriverSampler() {
* cassandraClientTracingBuilder.serverSampler(new CassandraClientSampler() {
* @Override public <Req> Boolean trySample(Statement statement) {
* return statement instanceof BoundStatement;
* }
* });
* }</pre>
*/
// abstract class as it lets us make helpers in the future
public abstract class CassandraDriverSampler {
public abstract class CassandraClientSampler {
/** Ignores the request and uses the {@link brave.sampler.Sampler trace ID instead}. */
public static final CassandraDriverSampler TRACE_ID = new CassandraDriverSampler() {
public static final CassandraClientSampler TRACE_ID = new CassandraClientSampler() {
@Override public Boolean trySample(Statement statement) {
return null;
}
Expand All @@ -28,7 +28,7 @@ public abstract class CassandraDriverSampler {
}
};
/** Returns false to never start new traces for cassandra client requests. */
public static final CassandraDriverSampler NEVER_SAMPLE = new CassandraDriverSampler() {
public static final CassandraClientSampler NEVER_SAMPLE = new CassandraClientSampler() {
@Override public Boolean trySample(Statement statement) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,28 @@
import zipkin.Endpoint;

@AutoValue
public abstract class CassandraDriverTracing {
public static CassandraDriverTracing create(Tracing tracing) {
public abstract class CassandraClientTracing {
public static CassandraClientTracing create(Tracing tracing) {
return newBuilder(tracing).build();
}

public static Builder newBuilder(Tracing tracing) {
return new AutoValue_CassandraDriverTracing.Builder()
return new AutoValue_CassandraClientTracing.Builder()
.tracing(tracing)
.parser(new CassandraDriverParser())
.sampler(CassandraDriverSampler.TRACE_ID);
.parser(new CassandraClientParser())
.sampler(CassandraClientSampler.TRACE_ID);
}

public abstract Tracing tracing();

public abstract CassandraDriverParser parser();
public abstract CassandraClientParser parser();

/**
* Used by cassandra clients to indicate the name of the destination service. Defaults to the
* cluster name.
*
* <p>As this is endpoint-specific, it is typical to create a scoped instance of {@linkplain
* CassandraDriverTracing} to assign this value.
* CassandraClientTracing} to assign this value.
*
* For example:
* <pre>{@code
Expand All @@ -44,37 +44,37 @@ public static Builder newBuilder(Tracing tracing) {
*
* @see #remoteServiceName()
*/
public CassandraDriverTracing clientOf(String remoteServiceName) {
public CassandraClientTracing clientOf(String remoteServiceName) {
return toBuilder().remoteServiceName(remoteServiceName).build();
}

/**
* Returns an overriding sampling decision for a new trace. Defaults to ignore the request and use
* the {@link CassandraDriverSampler#TRACE_ID trace ID instead}.
* the {@link CassandraClientSampler#TRACE_ID trace ID instead}.
*/
public abstract CassandraDriverSampler sampler();
public abstract CassandraClientSampler sampler();

public abstract Builder toBuilder();

@AutoValue.Builder
public static abstract class Builder {
/** @see CassandraDriverTracing#tracing() */
/** @see CassandraClientTracing#tracing() */
public abstract Builder tracing(Tracing tracing);

/** @see CassandraDriverTracing#parser() */
public abstract Builder parser(CassandraDriverParser parser);
/** @see CassandraClientTracing#parser() */
public abstract Builder parser(CassandraClientParser parser);

/** @see CassandraDriverTracing#sampler() */
public abstract Builder sampler(CassandraDriverSampler sampler);
/** @see CassandraClientTracing#sampler() */
public abstract Builder sampler(CassandraClientSampler sampler);

public abstract CassandraDriverTracing build();
public abstract CassandraClientTracing build();

abstract Builder remoteServiceName(@Nullable String remoteServiceName);

Builder() {
}
}

CassandraDriverTracing() {
CassandraClientTracing() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,22 @@

public final class TracingSession extends AbstractSession {
public static Session create(Tracing tracing, Session delegate) {
return new TracingSession(CassandraDriverTracing.create(tracing), delegate);
return new TracingSession(CassandraClientTracing.create(tracing), delegate);
}

public static Session create(CassandraDriverTracing cassandraTracing, Session delegate) {
public static Session create(CassandraClientTracing cassandraTracing, Session delegate) {
return new TracingSession(cassandraTracing, delegate);
}

final Tracer tracer;
final CassandraDriverSampler sampler;
final CassandraDriverParser parser;
final CassandraClientSampler sampler;
final CassandraClientParser parser;
final String remoteServiceName;
final TraceContext.Injector<Map<String, ByteBuffer>> injector;
final ProtocolVersion version;
final Session delegate;

TracingSession(CassandraDriverTracing cassandraTracing, Session target) {
TracingSession(CassandraClientTracing cassandraTracing, Session target) {
checkNotNull(cassandraTracing, "cassandraTracing");
this.delegate = checkNotNull(target, "delegate");
tracer = cassandraTracing.tracing().tracer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class ITTracingSession {
ConcurrentLinkedDeque<Span> spans = new ConcurrentLinkedDeque<>();

Tracing tracing;
CassandraDriverTracing cassandraTracing;
CassandraClientTracing cassandraTracing;
Cluster cluster;
Session session;
PreparedStatement prepared;
Expand All @@ -62,7 +62,7 @@ public class ITTracingSession {
}

Session newSession() {
cassandraTracing = CassandraDriverTracing.create(tracing);
cassandraTracing = CassandraClientTracing.create(tracing);
Session result = TracingSession.create(cassandraTracing, cluster.connect());
prepared = result.prepare("SELECT * from system.schema_keyspaces");
return result;
Expand Down Expand Up @@ -174,7 +174,7 @@ Session newSession() {

@Test public void customSampler() throws Exception {
cassandraTracing = cassandraTracing.toBuilder()
.sampler(CassandraDriverSampler.NEVER_SAMPLE).build();
.sampler(CassandraClientSampler.NEVER_SAMPLE).build();
session = TracingSession.create(cassandraTracing, ((TracingSession) session).delegate);

invokeBoundStatement();
Expand All @@ -184,7 +184,7 @@ Session newSession() {

@Test public void supportsCustomization() throws Exception {
cassandraTracing = cassandraTracing.toBuilder()
.parser(new CassandraDriverParser() {
.parser(new CassandraClientParser() {
@Override public String spanName(Statement statement) {
return "query";
}
Expand Down

0 comments on commit 8f0a91a

Please sign in to comment.