Skip to content

Commit

Permalink
Deprecates EnableZipkinServer to explain custom servers are unsupported
Browse files Browse the repository at this point in the history
Especially lately, we have had a large number of people having problems
with unnecessarily custom servers. Some are due to not knowing Sleuth's
stream server is obviated by our rabbit support. Some are due to blogs
which unfortunately recommend starting Zipkin in the IDE via a custom
server.

Through discussion, we decided the easiest way to let users know custom
servers are unsupported is by deprecation. Deprecation shows up in the
IDE and will alert those doing blogs or otherwise that they are
suggesting discouraged practice. It also sends a clear signal to those
who need to make custom servers that while doing so is possible, it is
something the customizer needs to accept support reponsibility of.
  • Loading branch information
Adrian Cole committed Mar 27, 2018
1 parent c42aa93 commit 8cda3f1
Show file tree
Hide file tree
Showing 86 changed files with 774 additions and 484 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2015-2017 The OpenZipkin Authors
* Copyright 2015-2018 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 Down Expand Up @@ -32,7 +32,7 @@
import org.springframework.boot.actuate.metrics.buffer.GaugeBuffers;
import zipkin.collector.CollectorMetrics;
import zipkin.collector.InMemoryCollectorMetrics;
import zipkin.server.ActuateCollectorMetrics;
import zipkin.server.internal.ActuateCollectorMetrics;

import java.io.IOException;
import java.util.concurrent.TimeUnit;
Expand Down
4 changes: 4 additions & 0 deletions zipkin-autoconfigure/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# zipkin-autoconfigure

Modules in this directory are considered internal details to Zipkin's
server and are unsupported unless integrated with our [server build](../zipkin-server).
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2015-2016 The OpenZipkin Authors
* Copyright 2015-2018 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 Down Expand Up @@ -29,7 +29,7 @@
@Configuration
@EnableConfigurationProperties(ZipkinKafkaCollectorProperties.class)
@Conditional(KafkaZooKeeperSetCondition.class)
public class ZipkinKafkaCollectorAutoConfiguration {
class ZipkinKafkaCollectorAutoConfiguration {

/**
* This launches a thread to run start. This prevents a several second hang, or worse crash if
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2015-2017 The OpenZipkin Authors
* Copyright 2015-2018 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 @@ -19,7 +19,7 @@
import zipkin.collector.kafka.KafkaCollector;

@ConfigurationProperties("zipkin.collector.kafka")
public class ZipkinKafkaCollectorProperties {
class ZipkinKafkaCollectorProperties {
private String topic = "zipkin";
private String zookeeper;
private String groupId = "zipkin";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* Copyright 2015-2018 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package zipkin.autoconfigure.collector.kafka;

import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Configuration;
import zipkin.collector.kafka.KafkaCollector;

/** opens package access for testing */
public final class Access {

/** Just registering properties to avoid automatically connecting to a Kafka server */
public static void registerKafkaProperties(AnnotationConfigApplicationContext context) {
context.register(
PropertyPlaceholderAutoConfiguration.class,
EnableKafkaCollectorProperties.class
);
}

@Configuration
@EnableConfigurationProperties(ZipkinKafkaCollectorProperties.class)
static class EnableKafkaCollectorProperties {
}

public static KafkaCollector.Builder collectorBuilder(
AnnotationConfigApplicationContext context
) {
return context.getBean(ZipkinKafkaCollectorProperties.class).toBuilder();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2015-2016 The OpenZipkin Authors
* Copyright 2015-2018 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,21 +11,21 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package zipkin.collector.kafka;
package zipkin.autoconfigure.collector.kafka;

import org.junit.After;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import zipkin.autoconfigure.collector.kafka.ZipkinKafkaCollectorAutoConfiguration;
import zipkin.autoconfigure.collector.kafka.ZipkinKafkaCollectorProperties;
import zipkin.collector.Collector;
import zipkin.collector.CollectorMetrics;
import zipkin.collector.CollectorSampler;
import zipkin.collector.kafka.KafkaCollector;
import zipkin.storage.InMemoryStorage;
import zipkin.storage.StorageComponent;

Expand Down Expand Up @@ -54,15 +54,18 @@ public void doesntProvidesCollectorComponent_whenKafkaZooKeeperUnset() {
context.refresh();

thrown.expect(NoSuchBeanDefinitionException.class);
context.getBean(KafkaCollector.class);
context.getBean(Collector.class);
}

@Test
public void providesCollectorComponent_whenZooKeeperSet() {
context = new AnnotationConfigApplicationContext();
addEnvironment(context, "zipkin.collector.kafka.zookeeper:localhost");
context.register(PropertyPlaceholderAutoConfiguration.class,
ZipkinKafkaCollectorAutoConfiguration.class, InMemoryConfiguration.class);
context.register(
PropertyPlaceholderAutoConfiguration.class,
ZipkinKafkaCollectorAutoConfiguration.class,
InMemoryConfiguration.class
);
context.refresh();

assertThat(context.getBean(KafkaCollector.class)).isNotNull();
Expand All @@ -83,21 +86,6 @@ public void canOverrideProperty_topic() {
.isEqualTo("zapkin");
}

@Test
public void overrideWithNestedProperties() {
context = new AnnotationConfigApplicationContext();
addEnvironment(context,
"zipkin.collector.kafka.zookeeper:localhost",
"zipkin.collector.kafka.overrides.auto.offset.reset:largest"
);
context.register(PropertyPlaceholderAutoConfiguration.class,
ZipkinKafkaCollectorAutoConfiguration.class, InMemoryConfiguration.class);
context.refresh();

assertThat(context.getBean(KafkaCollector.class).connector.config.autoOffsetReset())
.isEqualTo("largest");
}

@Configuration
static class InMemoryConfiguration {
@Bean CollectorSampler sampler() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* Copyright 2015-2018 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package zipkin.collector.kafka;

import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import zipkin.autoconfigure.collector.kafka.Access;
import zipkin.storage.InMemoryStorage;

import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.boot.test.util.EnvironmentTestUtils.addEnvironment;

public class NestedPropertyOverrideTest {
@Test public void overrideWithNestedProperties() {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
addEnvironment(context,
"zipkin.collector.kafka.zookeeper:localhost",
"zipkin.collector.kafka.overrides.auto.offset.reset:largest"
);
Access.registerKafkaProperties(context);
context.refresh();

assertThat(Access.collectorBuilder(context)
.storage(new InMemoryStorage())
.build().connector.config.autoOffsetReset())
.isEqualTo("largest");
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2015-2017 The OpenZipkin Authors
* Copyright 2015-2018 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 Down Expand Up @@ -32,7 +32,7 @@
@Configuration
@EnableConfigurationProperties(ZipkinKafkaCollectorProperties.class)
@Conditional(ZipkinKafka10CollectorAutoConfiguration.KafkaBootstrapServersSet.class)
public class ZipkinKafka10CollectorAutoConfiguration { // makes simple type name unique for /autoconfig
class ZipkinKafka10CollectorAutoConfiguration { // makes simple type name unique for /autoconfig

@Bean(initMethod = "start") KafkaCollector kafka(ZipkinKafkaCollectorProperties properties,
CollectorSampler sampler, CollectorMetrics metrics, StorageComponent storage) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2015-2017 The OpenZipkin Authors
* Copyright 2015-2018 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 @@ -19,7 +19,7 @@
import zipkin.collector.kafka10.KafkaCollector;

@ConfigurationProperties("zipkin.collector.kafka")
public class ZipkinKafkaCollectorProperties {
class ZipkinKafkaCollectorProperties {
/** Comma-separated list of Kafka bootstrap servers in the form [host]:[port],... */
private String bootstrapServers;
/** Kafka consumer group id used by the collector. */
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* Copyright 2015-2018 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package zipkin.autoconfigure.collector.kafka10;

import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Configuration;
import zipkin.collector.kafka10.KafkaCollector;

/** opens package access for testing */
public final class Access {

/** Just registering properties to avoid automatically connecting to a Kafka server */
public static void registerKafkaProperties(AnnotationConfigApplicationContext context) {
context.register(
PropertyPlaceholderAutoConfiguration.class,
EnableKafkaCollectorProperties.class
);
}

@Configuration
@EnableConfigurationProperties(ZipkinKafkaCollectorProperties.class)
static class EnableKafkaCollectorProperties {
}

public static KafkaCollector.Builder collectorBuilder(
AnnotationConfigApplicationContext context
) {
return context.getBean(ZipkinKafkaCollectorProperties.class).toBuilder();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2015-2017 The OpenZipkin Authors
* Copyright 2015-2018 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,20 +11,20 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package zipkin.collector.kafka10;
package zipkin.autoconfigure.collector.kafka10;

import org.junit.After;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import zipkin.autoconfigure.collector.kafka10.ZipkinKafka10CollectorAutoConfiguration;
import zipkin.collector.CollectorMetrics;
import zipkin.collector.CollectorSampler;
import zipkin.collector.kafka10.KafkaCollector;
import zipkin.storage.InMemoryStorage;
import zipkin.storage.StorageComponent;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2015-2017 The OpenZipkin Authors
* Copyright 2015-2018 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,10 +11,9 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package zipkin.collector.kafka10;
package zipkin.autoconfigure.collector.kafka10;

import org.junit.Test;
import zipkin.autoconfigure.collector.kafka10.ZipkinKafkaCollectorProperties;

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

Expand Down
Loading

0 comments on commit 8cda3f1

Please sign in to comment.