Skip to content

Commit

Permalink
Decouples from io.zipkin.zipkin2:zipkin
Browse files Browse the repository at this point in the history
This copies types from zipkin, so that reporter can be used without a
dependency on it. In practice, many still will because encoders will be
present. However, those using Brave and only JSON or alternative
backends like Wavefront can now avoid a dependency on Zipkin.

Fixes #182

Signed-off-by: Adrian Cole <[email protected]>
  • Loading branch information
Adrian Cole committed Jan 6, 2024
1 parent ca6aa21 commit beeccbd
Show file tree
Hide file tree
Showing 86 changed files with 2,179 additions and 1,046 deletions.
4 changes: 2 additions & 2 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ project has a bom.
$ mvn=$PWD/mvnw
$ for p in ./bom .; do
(cd $p
$mvn versions:set -DnewVersion=2.17.1-SNAPSHOT -DgenerateBackupPoms=false
$mvn versions:set -DnewVersion=3.0.1-SNAPSHOT -DgenerateBackupPoms=false
$mvn -o clean install -DskipTests
$mvn com.mycila:license-maven-plugin:format
$mvn versions:set -DnewVersion=2.17.0-SNAPSHOT -DgenerateBackupPoms=false)
$mvn versions:set -DnewVersion=3.0.0-SNAPSHOT -DgenerateBackupPoms=false)
done
$ git commit -asm"Adjusts copyright headers for this year"
```
Expand Down
10 changes: 9 additions & 1 deletion activemq-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<parent>
<artifactId>zipkin-reporter-parent</artifactId>
<groupId>io.zipkin.reporter2</groupId>
<version>2.17.3-SNAPSHOT</version>
<version>3.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -41,6 +41,14 @@
<groupId>${project.groupId}</groupId>
<artifactId>zipkin-reporter</artifactId>
<version>${project.version}</version>
<!-- Senders don't use zipkin types. Excluding allows brave users to
avoid them by default. -->
<exclusions>
<exclusion>
<groupId>io.zipkin.zipkin2</groupId>
<artifactId>zipkin</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 The OpenZipkin Authors
* Copyright 2016-2024 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 @@ -20,7 +20,7 @@
import javax.jms.QueueSession;
import org.apache.activemq.ActiveMQConnection;
import org.apache.activemq.transport.TransportListener;
import zipkin2.CheckResult;
import zipkin2.reporter.CheckResult;

final class ActiveMQConn implements TransportListener, Closeable {
static final CheckResult
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
import javax.jms.JMSException;
import javax.jms.QueueSender;
import org.apache.activemq.ActiveMQConnectionFactory;
import zipkin2.Call;
import zipkin2.Callback;
import zipkin2.CheckResult;
import zipkin2.codec.Encoding;
import zipkin2.reporter.AsyncReporter;
import zipkin2.reporter.BytesMessageEncoder;
import zipkin2.reporter.Call;
import zipkin2.reporter.Callback;
import zipkin2.reporter.CheckResult;
import zipkin2.reporter.ClosedSenderException;
import zipkin2.reporter.Encoding;
import zipkin2.reporter.Sender;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2023 The OpenZipkin Authors
* Copyright 2016-2024 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 @@ -22,13 +22,13 @@
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.Timeout;
import org.junit.jupiter.api.extension.RegisterExtension;
import zipkin2.Call;
import zipkin2.CheckResult;
import zipkin2.Span;
import zipkin2.codec.Encoding;
import zipkin2.codec.SpanBytesDecoder;
import zipkin2.codec.SpanBytesEncoder;
import zipkin2.reporter.SpanBytesEncoder;
import zipkin2.reporter.AsyncReporter;
import zipkin2.reporter.Call;
import zipkin2.reporter.CheckResult;
import zipkin2.reporter.Encoding;
import zipkin2.reporter.Sender;

import static java.util.stream.Collectors.toList;
Expand Down
10 changes: 9 additions & 1 deletion amqp-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>io.zipkin.reporter2</groupId>
<artifactId>zipkin-reporter-parent</artifactId>
<version>2.17.3-SNAPSHOT</version>
<version>3.0.0-SNAPSHOT</version>
</parent>

<artifactId>zipkin-sender-amqp-client</artifactId>
Expand All @@ -41,6 +41,14 @@
<groupId>${project.groupId}</groupId>
<artifactId>zipkin-reporter</artifactId>
<version>${project.version}</version>
<!-- Senders don't use zipkin types. Excluding allows brave users to
avoid them by default. -->
<exclusions>
<exclusion>
<groupId>io.zipkin.zipkin2</groupId>
<artifactId>zipkin</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.TimeoutException;
import zipkin2.Call;
import zipkin2.Callback;
import zipkin2.CheckResult;
import zipkin2.codec.Encoding;
import zipkin2.reporter.AsyncReporter;
import zipkin2.reporter.BytesMessageEncoder;
import zipkin2.reporter.Call;
import zipkin2.reporter.Callback;
import zipkin2.reporter.CheckResult;
import zipkin2.reporter.ClosedSenderException;
import zipkin2.reporter.Encoding;
import zipkin2.reporter.Sender;

import static zipkin2.Call.propagateIfFatal;
import static zipkin2.reporter.Call.propagateIfFatal;

/**
* This sends (usually json v2) encoded spans to a RabbitMQ queue.
Expand Down Expand Up @@ -189,7 +189,7 @@ public final RabbitMQSender build() {
connectionFactory = builder.connectionFactory.clone();
}

public final Builder toBuilder() {
public Builder toBuilder() {
return new Builder(this);
}

Expand Down Expand Up @@ -231,7 +231,7 @@ public final Builder toBuilder() {
}
}

@Override public final String toString() {
@Override public String toString() {
return "RabbitMQSender{addresses=" + addresses + ", queue=" + queue + "}";
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2023 The OpenZipkin Authors
* Copyright 2016-2024 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 @@ -25,11 +25,11 @@
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.Timeout;
import org.junit.jupiter.api.extension.RegisterExtension;
import zipkin2.Call;
import zipkin2.Span;
import zipkin2.codec.Encoding;
import zipkin2.codec.SpanBytesDecoder;
import zipkin2.codec.SpanBytesEncoder;
import zipkin2.reporter.SpanBytesEncoder;
import zipkin2.reporter.Call;
import zipkin2.reporter.Encoding;
import zipkin2.reporter.Sender;

import static java.util.stream.Collectors.toList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.testcontainers.containers.wait.strategy.Wait;

import static org.testcontainers.utility.DockerImageName.parse;
import static zipkin2.Call.propagateIfFatal;
import static zipkin2.reporter.Call.propagateIfFatal;

class RabbitMQExtension implements BeforeAllCallback, AfterAllCallback {
static final Logger LOGGER = LoggerFactory.getLogger(RabbitMQExtension.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2023 The OpenZipkin Authors
* Copyright 2016-2024 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 @@ -14,8 +14,8 @@
package zipkin2.reporter.amqp;

import org.junit.jupiter.api.Test;
import zipkin2.CheckResult;
import zipkin2.reporter.AsyncReporter;
import zipkin2.reporter.CheckResult;
import zipkin2.reporter.ClosedSenderException;
import zipkin2.reporter.Sender;

Expand All @@ -27,20 +27,20 @@
class RabbitMQSenderTest {
// We can be pretty certain RabbitMQ isn't running on localhost port 80
RabbitMQSender sender = RabbitMQSender.newBuilder()
.connectionTimeout(100).addresses("localhost:80").build();
.connectionTimeout(100).addresses("localhost:80").build();

@Test void checkFalseWhenRabbitMQIsDown() {
CheckResult check = sender.check();
assertThat(check.ok()).isFalse();
assertThat(check.error())
.isInstanceOf(RuntimeException.class);
.isInstanceOf(RuntimeException.class);
}

@Test void illegalToSendWhenClosed() throws Exception {
sender.close();

assertThatThrownBy(() -> send(sender, CLIENT_SPAN, CLIENT_SPAN))
.isInstanceOf(ClosedSenderException.class);
.isInstanceOf(ClosedSenderException.class);
}

/**
Expand All @@ -51,7 +51,7 @@ class RabbitMQSenderTest {
*/
@Test void toStringContainsOnlySummaryInformation() {
assertThat(sender).hasToString(
"RabbitMQSender{addresses=[localhost:80], queue=zipkin}"
"RabbitMQSender{addresses=[localhost:80], queue=zipkin}"
);
}
}
2 changes: 1 addition & 1 deletion benchmarks/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>io.zipkin.reporter2</groupId>
<artifactId>zipkin-reporter-parent</artifactId>
<version>2.17.3-SNAPSHOT</version>
<version>3.0.0-SNAPSHOT</version>
</parent>

<artifactId>benchmarks</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2020 The OpenZipkin Authors
* Copyright 2016-2024 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 @@ -18,6 +18,7 @@
import com.linecorp.armeria.server.Route;
import com.linecorp.armeria.server.Server;
import java.time.Duration;
import zipkin2.reporter.internal.SenderBenchmarks;

import static com.linecorp.armeria.common.HttpMethod.POST;
import static com.linecorp.armeria.common.MediaType.JSON;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.testcontainers.containers.InternetProtocol;
import org.testcontainers.containers.output.Slf4jLogConsumer;
import org.testcontainers.containers.wait.strategy.Wait;
import zipkin2.reporter.internal.SenderBenchmarks;
import zipkin2.reporter.kafka.KafkaSender;

import static org.apache.kafka.clients.consumer.ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2023 The OpenZipkin Authors
* Copyright 2016-2024 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 @@ -20,9 +20,9 @@
import org.openjdk.jmh.runner.RunnerException;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;
import zipkin2.CheckResult;
import zipkin2.reporter.CheckResult;
import zipkin2.reporter.Sender;
import zipkin2.reporter.SenderBenchmarks;
import zipkin2.reporter.internal.SenderBenchmarks;

public class RabbitMQSenderBenchmarks extends SenderBenchmarks {
private Channel channel;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 The OpenZipkin Authors
* Copyright 2016-2024 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,9 +11,8 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package zipkin2.reporter;
package zipkin2.reporter.internal;

import java.io.IOException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import org.openjdk.jmh.annotations.AuxCounters;
Expand All @@ -34,7 +33,9 @@
import org.openjdk.jmh.annotations.Warmup;
import zipkin2.Span;
import zipkin2.TestObjects;
import zipkin2.codec.Encoding;
import zipkin2.reporter.Encoding;
import zipkin2.reporter.InMemoryReporterMetrics;
import zipkin2.reporter.SpanBytesEncoder;

@Measurement(iterations = 5, time = 1)
@Warmup(iterations = 10, time = 1)
Expand Down Expand Up @@ -85,10 +86,10 @@ public void clean() {

@Setup(Level.Trial)
public void setup() {
reporter = AsyncReporter.builder(new NoopSender(encoding))
.messageMaxBytes(1000000) // example default from Kafka message.max.bytes
.metrics(metrics)
.build();
reporter = AsyncReporter.newBuilder(new NoopSender(encoding))
.messageMaxBytes(1000000) // example default from Kafka message.max.bytes
.metrics(metrics)
.build(SpanBytesEncoder.JSON_V2);
}

@Benchmark @Group("no_contention") @GroupThreads(1)
Expand All @@ -107,7 +108,7 @@ public void high_contention_report(InMemoryReporterMetricsAsCounters counters) {
}

@TearDown(Level.Iteration)
public void clear() throws IOException {
public void clear() {
spanBacklog.addAndGet(((AsyncReporter.BoundedAsyncReporter) reporter).pending.clear());
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 The OpenZipkin Authors
* Copyright 2016-2024 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 zipkin2.reporter;
package zipkin2.reporter.internal;

import java.util.concurrent.TimeUnit;
import org.openjdk.jmh.annotations.AuxCounters;
Expand Down Expand Up @@ -143,8 +143,8 @@ public void emptyQ() {
// Convenience main entry-point
public static void main(String[] args) throws RunnerException {
Options opt = new OptionsBuilder()
.include(".*" + ByteBoundedQueueBenchmarks.class.getSimpleName() + ".*")
.build();
.include(".*" + ByteBoundedQueueBenchmarks.class.getSimpleName() + ".*")
.build();

new Runner(opt).run();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 The OpenZipkin Authors
* Copyright 2016-2024 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,12 +11,14 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package zipkin2.reporter;
package zipkin2.reporter.internal;

import java.util.List;
import zipkin2.Call;
import zipkin2.CheckResult;
import zipkin2.codec.Encoding;
import zipkin2.reporter.BytesMessageEncoder;
import zipkin2.reporter.Call;
import zipkin2.reporter.CheckResult;
import zipkin2.reporter.Encoding;
import zipkin2.reporter.Sender;

final class NoopSender extends Sender {

Expand Down
Loading

0 comments on commit beeccbd

Please sign in to comment.