Skip to content

Commit

Permalink
Refactor zipkin.storage.cassandra3 to zipkin2.storage.cassandra3
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelsembwever committed Oct 9, 2017
1 parent c992d22 commit 4fc63ad
Show file tree
Hide file tree
Showing 31 changed files with 75 additions and 74 deletions.
Expand Up @@ -23,8 +23,8 @@
import org.springframework.context.annotation.Configuration;
import zipkin.internal.V2StorageComponent;
import zipkin.storage.StorageComponent;
import zipkin.storage.cassandra3.Cassandra3Storage;
import zipkin.storage.cassandra3.Cassandra3Storage.SessionFactory;
import zipkin2.storage.cassandra3.Cassandra3Storage;
import zipkin2.storage.cassandra3.Cassandra3Storage.SessionFactory;

/**
* This storage accepts Cassandra logs in a specified category. Each log entry is expected to contain
Expand Down
Expand Up @@ -15,12 +15,12 @@

import java.io.Serializable;
import org.springframework.boot.context.properties.ConfigurationProperties;
import zipkin.storage.cassandra3.Cassandra3Storage;
import zipkin2.storage.cassandra3.Cassandra3Storage;

import static zipkin.storage.cassandra3.Cassandra3Storage.Builder;
import static zipkin.storage.cassandra3.Cassandra3Storage.newBuilder;
import static zipkin2.storage.cassandra3.Cassandra3Storage.Builder;
import static zipkin2.storage.cassandra3.Cassandra3Storage.newBuilder;

@ConfigurationProperties("zipkin.storage.cassandra3")
@ConfigurationProperties("zipkin2.storage.cassandra3")
public class ZipkinCassandra3StorageProperties implements Serializable { // for Spark jobs
private static final long serialVersionUID = 0L;

Expand Down
Expand Up @@ -20,7 +20,7 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
import zipkin.storage.cassandra3.Cassandra3Storage.SessionFactory;
import zipkin2.storage.cassandra3.Cassandra3Storage.SessionFactory;

/** Sets up the Cassandra tracing in Brave as an initialization. */
@ConditionalOnBean(Brave.class)
Expand Down
@@ -1,5 +1,5 @@
/**
* Copyright 2015-2016 The OpenZipkin Authors
* Copyright 2015-2017 The OpenZipkin Authors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
Expand All @@ -11,7 +11,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package zipkin.storage.cassandra3;
package zipkin2.storage.cassandra3;

import org.junit.After;
import org.junit.Rule;
Expand Down Expand Up @@ -68,7 +68,7 @@ public void canOverridesProperty_contactPoints() {
context = new AnnotationConfigApplicationContext();
addEnvironment(context,
"zipkin.storage.type:cassandra3",
"zipkin.storage.cassandra3.contact-points:host1,host2" // note snake-case supported
"zipkin2.storage.cassandra3.contact-points:host1,host2" // note snake-case supported
);
context.register(PropertyPlaceholderAutoConfiguration.class,
ZipkinCassandra3StorageAutoConfiguration.class);
Expand Down
29 changes: 15 additions & 14 deletions zipkin-storage/cassandra3/README.md
Expand Up @@ -2,12 +2,13 @@

*This module is experimental. Please help test this, but do not use it in production.*

This CQL-based Cassandra 3.9+ storage component includes a `GuavaSpanStore` and `GuavaSpanConsumer`.
`GuavaSpanStore.getDependencies()` returns pre-aggregated dependency links (ex via [zipkin-dependencies](https://github.com/openzipkin/zipkin-dependencies)).
This CQL-based Cassandra 3.9+ storage component, built upon the Zipkin2 API.

The implementation uses the [Datastax Java Driver 3.x](https://github.com/datastax/java-driver).
`CassandraSpanStore.getDependencies()` returns pre-aggregated dependency links (ex via [zipkin-dependencies](https://github.com/openzipkin/zipkin-dependencies)).

`zipkin.storage.cassandra3.Cassandra3Storage.Builder` includes defaults that will operate against a local Cassandra installation.
The implementation uses the [Datastax Java Driver 3.1.x](https://github.com/datastax/java-driver).

`zipkin2.storage.cassandra3.Cassandra3Storage.Builder` includes defaults that will operate against a local Cassandra installation.

## Logging
Queries are logged to the category "com.datastax.driver.core.QueryLogger" when debug or trace is
Expand Down Expand Up @@ -36,26 +37,26 @@ That said, all integration tests run on pull request via Travis.
## Tuning
This component is tuned to help reduce the size of indexes needed to
perform query operations. The most important aspects are described below.
See [Cassandra3Storage](src/main/java/zipkin/storage/cassandra3/Cassandra3Storage.java) for details.
See [Cassandra3Storage](src/main/java/zipkin2.storage.cassandra3/Cassandra3Storage.java) for details.

### Trace indexing
Indexing in CQL is simplified by SASI, for example, reducing the number
of tables from 7 down to 4. SASI also moves some write-amplification from
CassandraSpanConsumer into C*.

CassandraSpanConsumer directly writes to the tables `traces`,
`trace_by_service_span` and `span_name_by_service`. The latter two
`trace_by_service_span` and `span_by_service`. The latter two
amplify writes by a factor of the distinct service names in a span.
Other amplification happens internally to C*, visible in the increase
write latency (although write latency remains performant at single digit
milliseconds).

* A SASI index on its 'all_annotations' column permits full-text searches against annotations.
* A SASI index on the 'duration' column.
* A SASI index on its `annotation_query` column permits full-text searches against annotations.
* A SASI index on the `duration` column.
* A SASI index on the `l_service` column (the local_service name), which is used in conjunction with annotation_query searches.

Note: [Core annotations](../../zipkin/src/main/java/zipkin/Constants.java#L186-L188),
ex "sr", non-string annotations, and values longer than 256 characters
are not written to the `all_annotations` SASI, as they aren't intended
Note: annotations with values longer than 256 characters
are not written to the `annotation_query` SASI, as they aren't intended
for use in user queries.

### Time-To_live
Expand All @@ -66,10 +67,10 @@ retrieve a trace by ID for up to 7 days, but you can only search the last 3 days

### Compaction
Time-series data is compacted using TimeWindowCompactionStrategy, a known improved over DateTieredCompactionStrategy. Data is
optimised for queries with a single day. The penalty of reading multiple days is small, a few disk seeks, compared to the
optimised for queries within a single day. The penalty of reading multiple days is small, a few disk seeks, compared to the
otherwise overhead of reading a significantly larger amount of data.

### Benchmarking
Benchmarking the new datamodel demonstrates a significant performance improvement on reads. How much of this translates to te
Benchmarking the new datamodel demonstrates a significant performance improvement on reads. How much of this translates to the
Zipkin UI is hard to tell due to the complexity of CassandraSpanConsumer and how searches are possible. Benchmarking stress
profiles are found in traces-stress.yaml and trace_by_service_span-stress.yaml.
profiles are found in traces-stress.yaml and trace_by_service_span-stress.yaml and span_by_service-stress.yaml.
Expand Up @@ -11,7 +11,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package zipkin.storage.cassandra3;
package zipkin2.storage.cassandra3;

import com.datastax.driver.core.Session;
import com.datastax.driver.core.querybuilder.QueryBuilder;
Expand Down
Expand Up @@ -11,7 +11,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package zipkin.storage.cassandra3;
package zipkin2.storage.cassandra3;

import com.datastax.driver.core.BoundStatement;
import com.datastax.driver.core.PreparedStatement;
Expand All @@ -30,11 +30,11 @@
import zipkin2.Call;
import zipkin2.Span;
import zipkin2.storage.SpanConsumer;
import zipkin.storage.cassandra3.Schema.AnnotationUDT;
import zipkin.storage.cassandra3.Schema.EndpointUDT;
import zipkin2.storage.cassandra3.Schema.AnnotationUDT;
import zipkin2.storage.cassandra3.Schema.EndpointUDT;

import static zipkin.storage.cassandra3.CassandraUtil.bindWithName;
import static zipkin.storage.cassandra3.CassandraUtil.durationIndexBucket;
import static zipkin2.storage.cassandra3.CassandraUtil.bindWithName;
import static zipkin2.storage.cassandra3.CassandraUtil.durationIndexBucket;

final class CassandraSpanConsumer implements SpanConsumer {
private static final Logger LOG = LoggerFactory.getLogger(CassandraSpanConsumer.class);
Expand Down
Expand Up @@ -11,7 +11,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package zipkin.storage.cassandra3;
package zipkin2.storage.cassandra3;

import com.datastax.driver.core.BoundStatement;
import com.datastax.driver.core.KeyspaceMetadata;
Expand Down Expand Up @@ -56,7 +56,7 @@
import zipkin2.internal.DependencyLinker;
import zipkin2.storage.SpanStore;
import zipkin2.storage.QueryRequest;
import zipkin.storage.cassandra3.Schema.AnnotationUDT;
import zipkin2.storage.cassandra3.Schema.AnnotationUDT;

import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.DiscreteDomain.integers;
Expand All @@ -65,9 +65,9 @@
import static com.google.common.util.concurrent.Futures.immediateFuture;
import static com.google.common.util.concurrent.Futures.transformAsync;
import static zipkin.internal.Util.getDays;
import static zipkin.storage.cassandra3.Schema.TABLE_SERVICE_SPANS;
import static zipkin.storage.cassandra3.Schema.TABLE_TRACES;
import static zipkin.storage.cassandra3.Schema.TABLE_TRACE_BY_SERVICE_SPAN;
import static zipkin2.storage.cassandra3.Schema.TABLE_SERVICE_SPANS;
import static zipkin2.storage.cassandra3.Schema.TABLE_TRACES;
import static zipkin2.storage.cassandra3.Schema.TABLE_TRACE_BY_SERVICE_SPAN;

final class CassandraSpanStore implements SpanStore {
private static final Logger LOG = LoggerFactory.getLogger(CassandraSpanStore.class);
Expand Down
Expand Up @@ -11,7 +11,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package zipkin.storage.cassandra3;
package zipkin2.storage.cassandra3;

import com.datastax.driver.core.BoundStatement;
import com.datastax.driver.core.PreparedStatement;
Expand Down
Expand Up @@ -11,7 +11,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package zipkin.storage.cassandra3;
package zipkin2.storage.cassandra3;

import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.ConsistencyLevel;
Expand All @@ -35,11 +35,11 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import zipkin.storage.cassandra3.Schema.AnnotationUDT;
import zipkin.storage.cassandra3.Schema.EndpointUDT;
import zipkin.storage.cassandra3.Schema.TypeCodecImpl;
import zipkin2.storage.cassandra3.Schema.AnnotationUDT;
import zipkin2.storage.cassandra3.Schema.EndpointUDT;
import zipkin2.storage.cassandra3.Schema.TypeCodecImpl;

import static zipkin.storage.cassandra3.Schema.DEFAULT_KEYSPACE;
import static zipkin2.storage.cassandra3.Schema.DEFAULT_KEYSPACE;

/**
* Creates a session and ensures schema if configured. Closes the cluster and session if any
Expand Down
Expand Up @@ -11,7 +11,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package zipkin.storage.cassandra3;
package zipkin2.storage.cassandra3;

import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
Expand Down
Expand Up @@ -11,7 +11,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package zipkin.storage.cassandra3;
package zipkin2.storage.cassandra3;

import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.ConsistencyLevel;
Expand Down
Expand Up @@ -12,7 +12,7 @@
* the License.
*/

package zipkin.storage.cassandra3;
package zipkin2.storage.cassandra3;

import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.ConsistencyLevel;
Expand Down
Expand Up @@ -12,4 +12,4 @@
* the License.
*/
@javax.annotation.ParametersAreNonnullByDefault
package zipkin.storage.cassandra3;
package zipkin2.storage.cassandra3;
Expand Up @@ -11,7 +11,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package zipkin.storage.cassandra3;
package zipkin2.storage.cassandra3;

import com.datastax.driver.core.exceptions.NoHostAvailableException;
import org.junit.Test;
Expand Down
Expand Up @@ -11,7 +11,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package zipkin.storage.cassandra3;
package zipkin2.storage.cassandra3;

import org.junit.Rule;
import org.junit.Test;
Expand Down
Expand Up @@ -11,7 +11,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package zipkin.storage.cassandra3;
package zipkin2.storage.cassandra3;

import com.datastax.driver.core.KeyspaceMetadata;
import com.datastax.driver.core.Session;
Expand Down
Expand Up @@ -11,7 +11,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package zipkin.storage.cassandra3;
package zipkin2.storage.cassandra3;

import com.datastax.driver.core.AuthProvider;
import com.datastax.driver.core.Authenticator;
Expand All @@ -30,8 +30,8 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static zipkin.storage.cassandra3.DefaultSessionFactory.buildCluster;
import static zipkin.storage.cassandra3.DefaultSessionFactory.parseContactPoints;
import static zipkin2.storage.cassandra3.DefaultSessionFactory.buildCluster;
import static zipkin2.storage.cassandra3.DefaultSessionFactory.parseContactPoints;

public class SessionFactoryTest {

Expand Down
Expand Up @@ -11,7 +11,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package zipkin.storage.cassandra3.integration;
package zipkin2.storage.cassandra3.integration;

import java.util.List;
import zipkin.DependencyLink;
Expand All @@ -21,8 +21,8 @@
import zipkin.storage.DependenciesTest;
import zipkin.storage.InMemoryStorage;
import zipkin.storage.StorageComponent;
import zipkin.storage.cassandra3.Cassandra3Storage;
import zipkin.storage.cassandra3.InternalForTests;
import zipkin2.storage.cassandra3.Cassandra3Storage;
import zipkin2.storage.cassandra3.InternalForTests;

import static zipkin.TestObjects.DAY;
import static zipkin.TestObjects.TODAY;
Expand Down
Expand Up @@ -11,14 +11,14 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package zipkin.storage.cassandra3.integration;
package zipkin2.storage.cassandra3.integration;

import com.datastax.driver.core.KeyspaceMetadata;
import com.datastax.driver.core.Session;
import org.junit.Before;
import org.junit.Test;
import org.junit.rules.TestName;
import zipkin.storage.cassandra3.InternalForTests;
import zipkin2.storage.cassandra3.InternalForTests;

import static org.assertj.core.api.Assertions.assertThat;

Expand Down
Expand Up @@ -11,7 +11,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package zipkin.storage.cassandra3.integration;
package zipkin2.storage.cassandra3.integration;

import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.spi.LoggingEvent;
Expand All @@ -24,8 +24,8 @@
import org.mockito.ArgumentMatcher;
import org.slf4j.LoggerFactory;
import zipkin.internal.Util;
import zipkin.storage.cassandra3.Cassandra3Storage;
import zipkin.storage.cassandra3.InternalForTests;
import zipkin2.storage.cassandra3.Cassandra3Storage;
import zipkin2.storage.cassandra3.InternalForTests;
import zipkin2.Span;
import zipkin2.TestObjects;
import zipkin2.storage.SpanConsumer;
Expand Down
Expand Up @@ -11,7 +11,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package zipkin.storage.cassandra3.integration;
package zipkin2.storage.cassandra3.integration;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -28,8 +28,8 @@
import zipkin.storage.QueryRequest;
import zipkin.storage.SpanStoreTest;
import zipkin.storage.StorageComponent;
import zipkin.storage.cassandra3.Cassandra3Storage;
import zipkin.storage.cassandra3.InternalForTests;
import zipkin2.storage.cassandra3.Cassandra3Storage;
import zipkin2.storage.cassandra3.InternalForTests;

import static java.util.stream.Collectors.toList;
import static org.assertj.core.api.Assertions.assertThat;
Expand Down

0 comments on commit 4fc63ad

Please sign in to comment.