Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zipkin support for ActiveMQ as a collector #1990

Closed
Shatakshi26 opened this issue Apr 10, 2018 · 8 comments · Fixed by #2639
Closed

Zipkin support for ActiveMQ as a collector #1990

Shatakshi26 opened this issue Apr 10, 2018 · 8 comments · Fixed by #2639

Comments

@Shatakshi26
Copy link

Shatakshi26 commented Apr 10, 2018

We are using ActiveMQ in our project and we don't want to go for any other queue, so it will be good if Zipkin provides support for ActiveMQ as a collector.


This issue is now closed. Until a release happens with this change, you can look at the PR description of #2639 for testing

@codefromthecrypt
Copy link
Member

looks like there is an implementation started here #2466

@codefromthecrypt
Copy link
Member

Let's assume we are talking about activemq (not artemis or apollo)

I like that activemq has very few dependencies, however they do add 2MiB weight to the server.

# I bundled the dependencies
$ jar -tvf activemq.jar
     0 Tue Mar 26 08:30:02 ICT 2019 META-INF/
   214 Tue Mar 26 08:30:02 ICT 2019 META-INF/MANIFEST.MF
     0 Tue Mar 26 08:30:02 ICT 2019 lib/
1431933 Fri Mar 15 07:58:56 ICT 2019 lib/activemq-client-5.15.9.jar
 41203 Thu Mar 16 17:36:32 ICT 2017 lib/slf4j-api-1.7.25.jar
 32359 Fri Feb 01 11:35:24 ICT 2008 lib/geronimo-jms_1.1_spec-1.1.1.jar
 50155 Fri Jun 20 11:32:38 ICT 2014 lib/hawtbuf-1.11.jar
 20220 Fri Feb 01 11:42:20 ICT 2008 lib/geronimo-j2ee-management_1.1_spec-1.0.1.jar
$ du -k activemq.jar
2112	/Users/acole/.m2/repository/io/zipkin/custom/security/1.0-SNAPSHOT/security-1.0-SNAPSHOT-module.jar

Moreover, I am concerned that one of its non-annotation dependencies has not been updated since 2014: hawtbuf

I'm not sure which liabilities exist here https://github.com/fusesource/hawtbuf but this library is used all over activemq. @gtully can you weigh in on this point?

[INFO] \- org.apache.activemq:activemq-client:jar:5.15.9:compile
[INFO]    +- org.slf4j:slf4j-api:jar:1.7.25:compile
[INFO]    +- org.apache.geronimo.specs:geronimo-jms_1.1_spec:jar:1.1.1:compile
[INFO]    +- org.fusesource.hawtbuf:hawtbuf:jar:1.11:compile
[INFO]    \- org.apache.geronimo.specs:geronimo-j2ee-management_1.1_spec:jar:1.0.1:compile

@codefromthecrypt
Copy link
Member

to pre-empt an artemis question. The dependencies are a lot bigger even if you take out netty. It introduces possibly our 4th or 5th logging dep, too :P Netty is used by armeria which is ok as long as they are on compatible versions of it. However, this sortof match tends to drift over time.

$ jar -tvf artemis.jar 
     0 Tue Mar 26 08:34:16 ICT 2019 META-INF/
   214 Tue Mar 26 08:34:16 ICT 2019 META-INF/MANIFEST.MF
     0 Tue Mar 26 08:34:16 ICT 2019 lib/
728105 Thu Mar 14 13:41:06 ICT 2019 lib/artemis-core-client-2.7.0.jar
2501842 Tue Feb 07 16:43:08 ICT 2017 lib/jgroups-3.6.13.Final.jar
296065 Thu Jan 17 22:45:18 ICT 2019 lib/artemis-commons-2.6.4.jar
 66469 Wed Feb 14 13:23:28 ICT 2018 lib/jboss-logging-3.3.2.Final.jar
246174 Wed Sep 21 17:21:16 ICT 2016 lib/commons-beanutils-1.9.3.jar
588337 Fri Nov 13 00:10:38 ICT 2015 lib/commons-collections-3.2.2.jar
121150 Tue Dec 18 08:47:04 ICT 2018 lib/johnzon-core-1.1.11.jar
141054 Mon Jan 21 12:55:28 ICT 2019 lib/netty-transport-native-epoll-4.1.33.Final-linux-x86_64.jar
 33475 Mon Jan 21 14:11:10 ICT 2019 lib/netty-transport-native-unix-common-4.1.33.Final.jar
109210 Mon Jan 21 14:16:46 ICT 2019 lib/netty-transport-native-kqueue-4.1.33.Final-osx-x86_64.jar
563528 Mon Jan 21 12:37:12 ICT 2019 lib/netty-codec-http-4.1.33.Final.jar
278556 Mon Jan 21 12:32:22 ICT 2019 lib/netty-buffer-4.1.33.Final.jar
463615 Mon Jan 21 12:34:14 ICT 2019 lib/netty-transport-4.1.33.Final.jar
 32799 Mon Jan 21 12:32:46 ICT 2019 lib/netty-resolver-4.1.33.Final.jar
420905 Mon Jan 21 12:36:42 ICT 2019 lib/netty-handler-4.1.33.Final.jar
316689 Mon Jan 21 12:34:54 ICT 2019 lib/netty-codec-4.1.33.Final.jar
587588 Mon Jan 21 12:31:18 ICT 2019 lib/netty-common-4.1.33.Final.jar
$ du -k artemis.jar 
8256	artemis.jar

@codefromthecrypt
Copy link
Member

NEXT STEP:
think hard about the technical impact and if this should be bundled or a separate repo such as we have with amazon etc. For example, a zipkin-activemq repo with collectors and reporters or if it should be bundled in.

Active feedback from other committers or PPMC is required before proceeding IMHO.

codefromthecrypt pushed a commit that referenced this issue Jun 23, 2019
Due to popular demand, this adds support for ActiveMQ 5.x.
This is enabled when the env variable `ACTIVEMQ_URL` is set to a valid
broker. Thanks very much to @IAMTJW for early work towards this change.

To try this change, you can use jitpack https://jitpack.io/#openzipkin/zipkin

Ex.
```bash
TAG=activemq-SNAPSHOT
curl -sSL https://jitpack.io/com/github/openzipkin/zipkin/zipkin-server/${TAG}/zipkin-server-${TAG}-exec.jar > zipkin.jar
ACTIVEMQ_URL=tcp://localhost:61616 java -jar zipkin.jar
```

Supercedes #2466
Fixes #1990
@codefromthecrypt
Copy link
Member

#2639 will implement this

@codefromthecrypt
Copy link
Member

here is the java sender openzipkin/zipkin-reporter-java#149

@codefromthecrypt
Copy link
Member

I tested with authenticated, secure remote connections using the zipkin-reporter change above. There were no dropped messages or otherwise problems with a burst of 4 threads for 30s. Moreover, you can see that with concurrency level of 8, load was spread evenly across all 8 worker threads (which share the same connection)

Screenshot 2019-06-24 at 9 05 26 AM

diff --git a/webmvc4/pom.xml b/webmvc4/pom.xml
index bd58632..2ad4148 100755
--- a/webmvc4/pom.xml
+++ b/webmvc4/pom.xml
@@ -16,13 +16,20 @@
     <maven.compiler.source>1.7</maven.compiler.source>
     <maven.compiler.target>1.7</maven.compiler.target>
 
-    <spring.version>4.3.22.RELEASE</spring.version>
+    <spring.version>4.3.24.RELEASE</spring.version>
     <log4j.version>2.11.2</log4j.version>
     <brave.version>5.6.5</brave.version>
   </properties>
 
   <dependencyManagement>
     <dependencies>
+      <dependency>
+        <groupId>io.zipkin.reporter2</groupId>
+        <artifactId>zipkin-reporter-bom</artifactId>
+        <version>2.8.5-SNAPSHOT</version>
+        <type>pom</type>
+        <scope>import</scope>
+      </dependency>
       <dependency>
         <groupId>io.zipkin.brave</groupId>
         <artifactId>brave-bom</artifactId>
@@ -53,7 +60,7 @@
     <dependency>
       <groupId>org.apache.httpcomponents</groupId>
       <artifactId>httpclient</artifactId>
-      <version>4.5.7</version>
+      <version>4.5.8</version>
     </dependency>
 
     <!-- Adds the MVC class and method names to server spans -->
@@ -104,7 +111,11 @@
     </dependency>
     <dependency>
       <groupId>io.zipkin.reporter2</groupId>
-      <artifactId>zipkin-sender-okhttp3</artifactId>
+      <artifactId>zipkin-reporter-spring-beans</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>io.zipkin.reporter2</groupId>
+      <artifactId>zipkin-sender-activemq-client</artifactId>
     </dependency>
   </dependencies>
 
@@ -112,7 +123,7 @@
     <plugins>
       <plugin>
         <artifactId>maven-compiler-plugin</artifactId>
-        <version>3.8.0</version>
+        <version>3.8.1</version>
       </plugin>
 
       <plugin>
@@ -150,7 +161,7 @@
         <plugin>
           <groupId>org.eclipse.jetty</groupId>
           <artifactId>jetty-maven-plugin</artifactId>
-          <version>9.4.15.v20190215</version>
+          <version>9.4.18.v20190429</version>
         </plugin>
       </plugins>
     </pluginManagement>
diff --git a/webmvc4/src/main/java/brave/webmvc/TracingConfiguration.java b/webmvc4/src/main/java/brave/webmvc/TracingConfiguration.java
index 095c043..3912ec3 100644
--- a/webmvc4/src/main/java/brave/webmvc/TracingConfiguration.java
+++ b/webmvc4/src/main/java/brave/webmvc/TracingConfiguration.java
@@ -20,9 +20,10 @@ import org.springframework.context.annotation.Import;
 import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
 import zipkin2.Span;
+import zipkin2.codec.Encoding;
 import zipkin2.reporter.AsyncReporter;
 import zipkin2.reporter.Sender;
-import zipkin2.reporter.okhttp3.OkHttpSender;
+import zipkin2.reporter.beans.ActiveMQSenderFactoryBean;
 
 /**
  * This adds tracing configuration to any web mvc controllers or rest template clients.
@@ -37,17 +38,24 @@ import zipkin2.reporter.okhttp3.OkHttpSender;
 public class TracingConfiguration extends WebMvcConfigurerAdapter {
 
   /** Configuration for how to send spans to Zipkin */
-  @Bean Sender sender() {
-    return OkHttpSender.create("http://127.0.0.1:9411/api/v2/spans");
+  @Bean ActiveMQSenderFactoryBean senderFactory() {
+    ActiveMQSenderFactoryBean result = new ActiveMQSenderFactoryBean();
+    result.setUrl(
+        "failover:(ssl://b-da18ebe4-54ff-4dfc-835f-3862a6c144b1-1.mq.ap-southeast-1.amazonaws.com:61617,ssl://b-da18ebe4-54ff-4dfc-835f-3862a6c144b1-2.mq.ap-southeast-1.amazonaws.com:61617)");
+    result.setUsername("zipkin");
+    result.setPassword("zipkin12345678");
+    result.setMessageMaxBytes(1024);
+    result.setEncoding(Encoding.PROTO3);
+    return result;
   }
 
   /** Configuration for how to buffer spans into messages for Zipkin */
-  @Bean AsyncReporter<Span> spanReporter() {
-    return AsyncReporter.create(sender());
+  @Bean AsyncReporter<Span> spanReporter() throws Exception {
+    return AsyncReporter.create((Sender) senderFactory().getObject());
   }
 
   /** Controls aspects of tracing such as the service name that shows up in the UI */
-  @Bean Tracing tracing(@Value("${zipkin.service:brave-webmvc-example}") String serviceName) {
+  @Bean Tracing tracing(@Value("${zipkin.service:brave-webmvc-example}") String serviceName) throws Exception {
     return Tracing.newBuilder()
         .localServiceName(serviceName)
         .propagationFactory(ExtraFieldPropagation.newFactory(B3Propagation.FACTORY, "user-name"))

@codefromthecrypt
Copy link
Member

#2639 includes how to test this change prior to release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants