Skip to content

Commit

Permalink
Merge pull request #106 from openzipkin/less-deps
Browse files Browse the repository at this point in the history
Prunes compile dependencies of zipkin-server to zipkin-core and spring
  • Loading branch information
adriancole committed Mar 18, 2016
2 parents f56b7c9 + 73efa05 commit 3f0094e
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 30 deletions.
2 changes: 2 additions & 0 deletions zipkin-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,14 @@
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>spanstore-cassandra</artifactId>
<optional>true</optional>
</dependency>

<!-- JDBC backend -->
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>spanstore-jdbc</artifactId>
<optional>true</optional>
</dependency>

<dependency>
Expand Down
2 changes: 1 addition & 1 deletion zipkin-server/src/it/minimal-dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>io.zipkin.java</groupId>
<artifactId>parent</artifactId>
<version>0.7.1-SNAPSHOT</version>
<version>0.8.1-SNAPSHOT</version>
<relativePath>../../../..</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.condition.SpringBootCondition;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
Expand All @@ -45,7 +46,6 @@
import zipkin.jdbc.JDBCSpanStore;
import zipkin.kafka.KafkaConfig;
import zipkin.kafka.KafkaTransport;
import zipkin.server.ZipkinServerProperties.Store.Type;
import zipkin.server.brave.TraceWritesSpanStore;

@Configuration
Expand All @@ -56,16 +56,6 @@ public class ZipkinServerConfiguration {
@Autowired
ZipkinServerProperties server;

@Autowired
ZipkinCassandraProperties cassandra;

@Autowired(required = false)
DataSource datasource;

@Autowired(required = false)
@Qualifier("jdbcTraceListenerProvider")
ExecuteListenerProvider listener;

@Bean
@ConditionalOnMissingBean(Codec.Factory.class)
Codec.Factory codecFactory() {
Expand All @@ -78,24 +68,10 @@ Sampler traceIdSampler(@Value("${zipkin.collector.sample-rate:1.0}") float rate)
return Sampler.create(rate);
}

@Bean SpanStore spanStore() {
if (datasource != null && server.getStore().getType() == Type.mysql) {
return new JDBCSpanStore(datasource, new Settings().withRenderSchema(false), listener);
} else if (server.getStore().getType() == Type.cassandra) {
CassandraConfig config = new CassandraConfig.Builder()
.keyspace(cassandra.getKeyspace())
.contactPoints(cassandra.getContactPoints())
.localDc(cassandra.getLocalDc())
.maxConnections(cassandra.getMaxConnections())
.ensureSchema(cassandra.isEnsureSchema())
.username(cassandra.getUsername())
.password(cassandra.getPassword())
.spanTtl(cassandra.getSpanTtl())
.indexTtl(cassandra.getIndexTtl()).build();
return new CassandraSpanStore(config);
} else {
return new InMemorySpanStore();
}
@Bean
@ConditionalOnMissingBean(SpanStore.class)
SpanStore spanStore() {
return new InMemorySpanStore();
}

@Configuration
Expand All @@ -119,6 +95,43 @@ public Object postProcessAfterInitialization(Object bean, String beanName) {
}
}

@Configuration
@ConditionalOnProperty(name = "zipkin.store.type", havingValue = "mysql")
@ConditionalOnClass(name = "zipkin.jdbc.JDBCSpanStore")
static class JDBCConfiguration {

@Autowired(required = false)
DataSource datasource;

@Autowired(required = false)
@Qualifier("jdbcTraceListenerProvider")
ExecuteListenerProvider listener;

@Bean SpanStore jdbcSpanStore() {
return new JDBCSpanStore(datasource, new Settings().withRenderSchema(false), listener);
}
}

@Configuration
@EnableConfigurationProperties(ZipkinCassandraProperties.class)
@ConditionalOnProperty(name = "zipkin.store.type", havingValue = "cassandra")
@ConditionalOnClass(name = "zipkin.cassandra.CassandraSpanStore")
static class CassandraConfiguration {
@Bean SpanStore cassandraSpanStore(ZipkinCassandraProperties cassandra) {
CassandraConfig config = new CassandraConfig.Builder()
.keyspace(cassandra.getKeyspace())
.contactPoints(cassandra.getContactPoints())
.localDc(cassandra.getLocalDc())
.maxConnections(cassandra.getMaxConnections())
.ensureSchema(cassandra.isEnsureSchema())
.username(cassandra.getUsername())
.password(cassandra.getPassword())
.spanTtl(cassandra.getSpanTtl())
.indexTtl(cassandra.getIndexTtl()).build();
return new CassandraSpanStore(config);
}
}

/**
* This transport consumes a topic, decodes spans from thrift messages and stores them subject to
* sampling policy.
Expand Down

0 comments on commit 3f0094e

Please sign in to comment.