From commits-return-97-archive-asf-public=cust-asf.ponee.io@zipkin.apache.org Wed Jan 30 17:07:03 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id E4D741807A3 for ; Wed, 30 Jan 2019 18:07:00 +0100 (CET) Received: (qmail 58016 invoked by uid 500); 30 Jan 2019 17:06:52 -0000 Mailing-List: contact commits-help@zipkin.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@zipkin.apache.org Delivered-To: mailing list commits@zipkin.apache.org Received: (qmail 57935 invoked by uid 99); 30 Jan 2019 17:06:51 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 Jan 2019 17:06:51 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 3C5C08572E; Wed, 30 Jan 2019 17:06:50 +0000 (UTC) Date: Wed, 30 Jan 2019 17:07:12 +0000 To: "commits@zipkin.apache.org" Subject: [incubator-zipkin-brave-karaf] 24/37: Revamps project to recent version of Brave and refactors senders MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit From: abesto@apache.org In-Reply-To: <154886800866.26132.2518170867932446027@gitbox.apache.org> References: <154886800866.26132.2518170867932446027@gitbox.apache.org> X-Git-Host: gitbox.apache.org X-Git-Repo: incubator-zipkin-brave-karaf X-Git-Refname: refs/heads/jenkinsfile-wip X-Git-Reftype: branch X-Git-Rev: a9f4e8578ff14a9edc0b02a1a559b5a45d0f7c9c X-Git-NotificationType: diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated Message-Id: <20190130170650.3C5C08572E@gitbox.apache.org> This is an automated email from the ASF dual-hosted git repository. abesto pushed a commit to branch jenkinsfile-wip in repository https://gitbox.apache.org/repos/asf/incubator-zipkin-brave-karaf.git commit a9f4e8578ff14a9edc0b02a1a559b5a45d0f7c9c Author: Adrian Cole AuthorDate: Sat Feb 24 15:59:32 2018 +0800 Revamps project to recent version of Brave and refactors senders Before, I think we accidentally conflated zipkin reporter's senders with instrumentation. When we go to instrument okhttp, for example, that will different than the sender (what sends spans to zipkin). This doesn't pass tests, so could use a hand. --- .gitignore | 13 +- .mvn/wrapper/MavenWrapperDownloader.java | 110 +++ .mvn/wrapper/maven-wrapper.jar | Bin 49519 -> 48337 bytes .mvn/wrapper/maven-wrapper.properties | 2 +- .settings.xml | 2 +- brave-exporter-kafka08/pom.xml | 90 --- .../osgi/exporter/kafka/KafkaReporterExporter.java | 90 --- brave-exporter-okhttp3/pom.xml | 103 --- .../okhttp3/internal/OkHttp3ReporterExporter.java | 140 ---- brave-exporter/pom.xml | 85 --- .../zipkin/brave/osgi/exporter/BraveExporter.java | 66 -- .../urlconnect/SenderUrlConnectExporter.java | 71 -- brave-features/.classpath | 36 - brave-features/pom.xml | 80 --- brave-features/src/main/resources/features.xml | 60 -- brave-itests/pom.xml | 175 ----- .../java/io/zipkin/brave/itests/BraveTest.java | 126 ---- exporter-sender-kafka/pom.xml | 78 +++ .../exporter/sender/kafka/KafkaSenderExporter.java | 80 +++ .../sender/kafka/KafkaSenderExporterTest.java | 45 +- exporter-sender-okhttp/pom.xml | 73 ++ .../sender/okhttp/SenderOkHttpExporter.java | 63 ++ exporter/pom.xml | 77 +++ .../brave/exporter/AsyncReporterExporter.java | 60 ++ .../zipkin/brave/exporter/HttpTracingExporter.java | 55 ++ .../io/zipkin/brave/exporter/TracingExporter.java | 68 ++ .../urlconnection/URLConnectionSenderExporter.java | 66 ++ features/pom.xml | 81 +++ features/src/main/resources/features.xml | 44 ++ {brave-itests => itests}/.gitignore | 0 itests/pom.xml | 156 +++++ .../java/io/zipkin/brave/itests/BraveTest.java | 97 +++ .../src/test/resources/exam.properties | 0 .../src/test/resources/logback.xml | 0 mvnw | 158 +++-- mvnw.cmd | 26 +- pom.xml | 754 ++++++++++++--------- 37 files changed, 1696 insertions(+), 1534 deletions(-) diff --git a/.gitignore b/.gitignore index 3e4494c..e1f45e2 100644 --- a/.gitignore +++ b/.gitignore @@ -10,7 +10,12 @@ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* -.classpath -.project -.settings -target +# Maven +target/ + +# IntelliJ +.idea/ +*.iml + +# macOS +.DS_Store diff --git a/.mvn/wrapper/MavenWrapperDownloader.java b/.mvn/wrapper/MavenWrapperDownloader.java new file mode 100755 index 0000000..fa4f7b4 --- /dev/null +++ b/.mvn/wrapper/MavenWrapperDownloader.java @@ -0,0 +1,110 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you 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. +*/ + +import java.net.*; +import java.io.*; +import java.nio.channels.*; +import java.util.Properties; + +public class MavenWrapperDownloader { + + /** + * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. + */ + private static final String DEFAULT_DOWNLOAD_URL = + "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"; + + /** + * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to + * use instead of the default one. + */ + private static final String MAVEN_WRAPPER_PROPERTIES_PATH = + ".mvn/wrapper/maven-wrapper.properties"; + + /** + * Path where the maven-wrapper.jar will be saved to. + */ + private static final String MAVEN_WRAPPER_JAR_PATH = + ".mvn/wrapper/maven-wrapper.jar"; + + /** + * Name of the property which should be used to override the default download url for the wrapper. + */ + private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; + + public static void main(String args[]) { + System.out.println("- Downloader started"); + File baseDirectory = new File(args[0]); + System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); + + // If the maven-wrapper.properties exists, read it and check if it contains a custom + // wrapperUrl parameter. + File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); + String url = DEFAULT_DOWNLOAD_URL; + if(mavenWrapperPropertyFile.exists()) { + FileInputStream mavenWrapperPropertyFileInputStream = null; + try { + mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); + Properties mavenWrapperProperties = new Properties(); + mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); + url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); + } catch (IOException e) { + System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); + } finally { + try { + if(mavenWrapperPropertyFileInputStream != null) { + mavenWrapperPropertyFileInputStream.close(); + } + } catch (IOException e) { + // Ignore ... + } + } + } + System.out.println("- Downloading from: : " + url); + + File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); + if(!outputFile.getParentFile().exists()) { + if(!outputFile.getParentFile().mkdirs()) { + System.out.println( + "- ERROR creating output direcrory '" + outputFile.getParentFile().getAbsolutePath() + "'"); + } + } + System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); + try { + downloadFileFromURL(url, outputFile); + System.out.println("Done"); + System.exit(0); + } catch (Throwable e) { + System.out.println("- Error downloading"); + e.printStackTrace(); + System.exit(1); + } + } + + private static void downloadFileFromURL(String urlString, File destination) throws Exception { + URL website = new URL(urlString); + ReadableByteChannel rbc; + rbc = Channels.newChannel(website.openStream()); + FileOutputStream fos = new FileOutputStream(destination); + fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); + fos.close(); + rbc.close(); + } + +} diff --git a/.mvn/wrapper/maven-wrapper.jar b/.mvn/wrapper/maven-wrapper.jar old mode 100644 new mode 100755 index c6feb8b..01e6799 Binary files a/.mvn/wrapper/maven-wrapper.jar and b/.mvn/wrapper/maven-wrapper.jar differ diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties old mode 100644 new mode 100755 index c9023ed..00d32aa --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -1 +1 @@ -distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip \ No newline at end of file +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip \ No newline at end of file diff --git a/.settings.xml b/.settings.xml index 74dd284..15f5f03 100644 --- a/.settings.xml +++ b/.settings.xml @@ -1,7 +1,7 @@ - - 4.0.0 - - io.zipkin.brave.karaf - brave-karaf-parent - 1.0.0-SNAPSHOT - - - brave-exporter-kafka08 - - - ${project.basedir}/.. - - - - - org.osgi - osgi.core - 6.0.0 - provided - - - org.osgi - osgi.cmpn - 6.0.0 - provided - - - io.zipkin.brave - brave-core - - - io.zipkin.reporter - zipkin-reporter - - - io.zipkin.reporter - zipkin-sender-kafka08 - - - org.mockito - mockito-core - test - - - - - - - biz.aQute.bnd - bnd-maven-plugin - 3.3.0 - - - - bnd-process - - - - - - org.apache.maven.plugins - maven-jar-plugin - 3.0.2 - - - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - - - - - - \ No newline at end of file diff --git a/brave-exporter-kafka08/src/main/java/io/zipkin/brave/osgi/exporter/kafka/KafkaReporterExporter.java b/brave-exporter-kafka08/src/main/java/io/zipkin/brave/osgi/exporter/kafka/KafkaReporterExporter.java deleted file mode 100644 index 4c48df2..0000000 --- a/brave-exporter-kafka08/src/main/java/io/zipkin/brave/osgi/exporter/kafka/KafkaReporterExporter.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * Copyright 2016 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 io.zipkin.brave.osgi.exporter.kafka; - -import java.util.HashMap; -import java.util.Hashtable; -import java.util.Map; - -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceRegistration; -import org.osgi.service.component.annotations.Activate; -import org.osgi.service.component.annotations.Component; -import org.osgi.service.component.annotations.ConfigurationPolicy; -import org.osgi.service.component.annotations.Deactivate; -import org.osgi.service.metatype.annotations.Designate; -import org.osgi.service.metatype.annotations.ObjectClassDefinition; -import zipkin.Span; -import zipkin.reporter.AsyncReporter; -import zipkin.reporter.Encoding; -import zipkin.reporter.Reporter; -import zipkin.reporter.kafka08.KafkaSender; - -@Component // -( // - immediate = true, // - name = "io.zipkin.reporter.kafka08", // - configurationPolicy = ConfigurationPolicy.REQUIRE -) -@Designate(ocd = KafkaReporterExporter.Config.class) -public class KafkaReporterExporter { - - private static final String OVERRIDE_PREFIX = "kafka."; - @SuppressWarnings("rawtypes") - private ServiceRegistration reg; - private AsyncReporter reporter; - - @ObjectClassDefinition(name = "Zipkin Reporter Kafka08") - @interface Config { - String bootstrapServers() default "localhost:9092"; - Encoding encoding() default Encoding.THRIFT; - int messageMaxBytes() default 1000000; - String topic() default "zipkin"; - } - - @Activate - public void activate(Config config, BundleContext context, Map properties) { - KafkaSender sender = createSender(config, properties); - reporter = AsyncReporter.builder(sender).build(); - reg = context.registerService(Reporter.class, reporter, new Hashtable(properties)); - } - - KafkaSender createSender(Config config, Map properties) { - KafkaSender sender = KafkaSender.builder() // - .bootstrapServers(config.bootstrapServers()) // - .encoding(config.encoding()) // - .messageMaxBytes(config.messageMaxBytes()) // - .overrides(getOverrides(properties)) // - .topic(config.topic()) // - .build(); - return sender; - } - - private HashMap getOverrides(Map properties) { - HashMap overrides = new HashMap(); - for (String key : properties.keySet()) { - if (key.startsWith(OVERRIDE_PREFIX)) { - overrides.put(key.substring(OVERRIDE_PREFIX.length() - 1), properties.get(key)); - } - } - return overrides; - } - - @Deactivate - public void deactive() { - reg.unregister(); - reporter.close(); - } - -} diff --git a/brave-exporter-okhttp3/pom.xml b/brave-exporter-okhttp3/pom.xml deleted file mode 100644 index 17827bb..0000000 --- a/brave-exporter-okhttp3/pom.xml +++ /dev/null @@ -1,103 +0,0 @@ - - - - - brave-karaf-parent - io.zipkin.brave.karaf - 1.0.0-SNAPSHOT - - 4.0.0 - - brave-exporter-okhttp3 - - - ${project.basedir}/.. - - - - - org.osgi - osgi.core - 6.0.0 - provided - - - org.osgi - osgi.cmpn - 6.0.0 - provided - - - - io.zipkin.java - zipkin - - - - io.zipkin.brave - brave-context-slf4j - ${brave.version} - - - - io.zipkin.reporter - zipkin-reporter - - - - io.zipkin.reporter - zipkin-sender-okhttp3 - ${zipkin.reporter.version} - - - - org.mockito - mockito-core - test - - - - - - - biz.aQute.bnd - bnd-maven-plugin - 3.3.0 - - - - bnd-process - - - - - - org.apache.maven.plugins - maven-jar-plugin - 3.0.2 - - - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - - - - - - - \ No newline at end of file diff --git a/brave-exporter-okhttp3/src/main/java/io/zipkin/brave/osgi/exporter/okhttp3/internal/OkHttp3ReporterExporter.java b/brave-exporter-okhttp3/src/main/java/io/zipkin/brave/osgi/exporter/okhttp3/internal/OkHttp3ReporterExporter.java deleted file mode 100644 index 55aecac..0000000 --- a/brave-exporter-okhttp3/src/main/java/io/zipkin/brave/osgi/exporter/okhttp3/internal/OkHttp3ReporterExporter.java +++ /dev/null @@ -1,140 +0,0 @@ -/** - * Copyright 2016-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 - * - * 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 io.zipkin.brave.osgi.exporter.okhttp3.internal; - -import brave.Tracing; -import brave.context.slf4j.MDCCurrentTraceContext; -import brave.sampler.Sampler; -import org.osgi.framework.BundleContext; -import org.osgi.framework.InvalidSyntaxException; -import org.osgi.framework.ServiceReference; -import org.osgi.framework.ServiceRegistration; -import org.osgi.service.component.annotations.Activate; -import org.osgi.service.component.annotations.Component; -import org.osgi.service.component.annotations.ConfigurationPolicy; -import org.osgi.service.component.annotations.Deactivate; -import org.osgi.service.metatype.annotations.Designate; -import org.osgi.service.metatype.annotations.ObjectClassDefinition; -import zipkin.Span; -import zipkin.reporter.AsyncReporter; -import zipkin.reporter.Encoding; -import zipkin.reporter.Reporter; -import zipkin.reporter.okhttp3.OkHttpSender; - -import java.util.HashMap; -import java.util.Hashtable; -import java.util.Map; - -@Component( - immediate = true, - name = "io.zipkin.reporter.okhttp3", - property = {"sender=okhttp3"}, - configurationPolicy = ConfigurationPolicy.REQUIRE -) -@Designate(ocd = OkHttp3ReporterExporter.Config.class) -public class OkHttp3ReporterExporter { - - private static final String OVERRIDE_PREFIX = "okhttp3."; - - @SuppressWarnings("rawtypes") - private ServiceRegistration reporterServiceRegistration; - @SuppressWarnings("rawtypes") - private ServiceRegistration tracingServiceRegistration; - - private AsyncReporter reporter; - private Tracing tracing; - - private BundleContext context; - - @ObjectClassDefinition(name = "Zipkin Reporter OkHttp3") - @interface Config { - String zipkinUrl() default "localhost:9411"; - - boolean compressionEnabled() default true; - - Encoding encoding() default Encoding.THRIFT; - - int messageMaxBytes() default 1000000; - - String localServiceName() default "zipkin-okhttp3"; - - String samplerFilter() default "(type=always)"; - } - - @Activate - public void activate(Config config, BundleContext context, Map properties) { - this.context = context; - OkHttpSender sender = createSender(config, properties); - reporter = AsyncReporter.create(sender); - - reporterServiceRegistration = context.registerService(Reporter.class, reporter, - new Hashtable(properties)); - - tracing = httpTracer(config, properties, reporter); - tracingServiceRegistration = context.registerService(Tracing.class, tracing, - new Hashtable(properties)); - } - - @SuppressWarnings("unchecked") - public Tracing httpTracer(Config config, Map properties, Reporter reporter) { - - Sampler sampler = Sampler.ALWAYS_SAMPLE; - - try { - ServiceReference[] samplers = - (ServiceReference[]) context.getAllServiceReferences( - Sampler.class.getName(), config.samplerFilter()); - if (samplers != null && samplers.length > 0) { - sampler = context.getService(samplers[0]); - } - - } catch (InvalidSyntaxException e) { - - } - - Tracing.Builder tracingBuilder = Tracing.newBuilder(); - tracingBuilder.localServiceName(config.localServiceName()); - tracingBuilder.sampler(sampler); - tracingBuilder.reporter(reporter); - tracingBuilder.currentTraceContext(MDCCurrentTraceContext.create()); - - return tracingBuilder.build(); - } - - - OkHttpSender createSender(Config config, Map properties) { - return OkHttpSender.builder() - .endpoint(config.zipkinUrl()) - .compressionEnabled(config.compressionEnabled()) - .messageMaxBytes(config.messageMaxBytes()) - .build(); - } - - private HashMap getOverrides(Map properties) { - HashMap overrides = new HashMap(); - for (String key : properties.keySet()) { - if (key.startsWith(OVERRIDE_PREFIX)) { - overrides.put(key.substring(OVERRIDE_PREFIX.length() - 1), properties.get(key)); - } - } - return overrides; - } - - @Deactivate - public void deactive() { - tracingServiceRegistration.unregister(); - reporterServiceRegistration.unregister(); - reporter.close(); - } -} diff --git a/brave-exporter/pom.xml b/brave-exporter/pom.xml deleted file mode 100644 index dbc38ac..0000000 --- a/brave-exporter/pom.xml +++ /dev/null @@ -1,85 +0,0 @@ - - - - 4.0.0 - - io.zipkin.brave.karaf - brave-karaf-parent - 1.0.0-SNAPSHOT - - - brave-exporter - - - ${project.basedir}/.. - - - - - org.osgi - osgi.core - 6.0.0 - provided - - - org.osgi - osgi.cmpn - 6.0.0 - provided - - - io.zipkin.brave - brave-core - - - io.zipkin.reporter - zipkin-reporter - - - io.zipkin.reporter - zipkin-sender-urlconnection - - - - - - - biz.aQute.bnd - bnd-maven-plugin - 3.3.0 - - - - bnd-process - - - - - - org.apache.maven.plugins - maven-jar-plugin - 3.0.2 - - - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - - - - - - \ No newline at end of file diff --git a/brave-exporter/src/main/java/io/zipkin/brave/osgi/exporter/BraveExporter.java b/brave-exporter/src/main/java/io/zipkin/brave/osgi/exporter/BraveExporter.java deleted file mode 100644 index 04b9536..0000000 --- a/brave-exporter/src/main/java/io/zipkin/brave/osgi/exporter/BraveExporter.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Copyright 2016 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 io.zipkin.brave.osgi.exporter; - -import java.util.Hashtable; -import java.util.Map; - -import com.github.kristofa.brave.Brave; -import com.github.kristofa.brave.Sampler; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceRegistration; -import org.osgi.service.component.annotations.Activate; -import org.osgi.service.component.annotations.Component; -import org.osgi.service.component.annotations.Deactivate; -import org.osgi.service.component.annotations.Reference; -import org.osgi.service.metatype.annotations.Designate; -import org.osgi.service.metatype.annotations.ObjectClassDefinition; -import zipkin.Span; -import zipkin.reporter.Reporter; - -@Component // -( // - immediate = true, // - name = "io.zipkin.brave" // -) -@Designate(ocd = BraveExporter.Config.class) -public class BraveExporter { - @Reference - Reporter reporter; - - private ServiceRegistration reg; - - @ObjectClassDefinition(name = "Brave") - @interface Config { - String name() default "default"; - boolean traceId128Bit() default false; - float rate() default 1; - } - - @Activate - public void activate(Config config, BundleContext context, Map properties) { - Brave brave = new Brave.Builder(config.name()) - .reporter(reporter) // - .traceId128Bit(config.traceId128Bit()) // - .traceSampler(Sampler.create(config.rate())) - .build(); - reg = context.registerService(Brave.class, brave, new Hashtable(properties)); - } - - @Deactivate - public void deactive() { - reg.unregister(); - } - -} diff --git a/brave-exporter/src/main/java/io/zipkin/brave/osgi/exporter/urlconnect/SenderUrlConnectExporter.java b/brave-exporter/src/main/java/io/zipkin/brave/osgi/exporter/urlconnect/SenderUrlConnectExporter.java deleted file mode 100644 index 94f85b9..0000000 --- a/brave-exporter/src/main/java/io/zipkin/brave/osgi/exporter/urlconnect/SenderUrlConnectExporter.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * Copyright 2016 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 io.zipkin.brave.osgi.exporter.urlconnect; - -import java.util.Hashtable; -import java.util.Map; - -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceRegistration; -import org.osgi.service.component.annotations.Activate; -import org.osgi.service.component.annotations.Component; -import org.osgi.service.component.annotations.ConfigurationPolicy; -import org.osgi.service.component.annotations.Deactivate; -import org.osgi.service.metatype.annotations.Designate; -import org.osgi.service.metatype.annotations.ObjectClassDefinition; -import zipkin.Span; -import zipkin.reporter.AsyncReporter; -import zipkin.reporter.Reporter; -import zipkin.reporter.urlconnection.URLConnectionSender; - -@Component // -( // - immediate = true, // - name = "io.zipkin.reporter.urlconnect", // - configurationPolicy = ConfigurationPolicy.REQUIRE -) -@Designate(ocd = SenderUrlConnectExporter.Config.class) -public class SenderUrlConnectExporter { - - @SuppressWarnings("rawtypes") - private ServiceRegistration reg; - private AsyncReporter reporter; - - @ObjectClassDefinition(name = "Zipkin Reporter URLConnect") - @interface Config { - String endpoint() default "http://localhost:9411/api/v1/spans"; - boolean compressionEnabled() default true; - int connectTimeout() default 10 * 1000; - int messageMaxBytes() default 5 * 1024 * 1024; - } - - @Activate - public void activate(Config config, BundleContext context, Map properties) { - URLConnectionSender sender = URLConnectionSender.builder() - .endpoint(config.endpoint()) // - .compressionEnabled(config.compressionEnabled()) // - .connectTimeout(config.connectTimeout()) - .messageMaxBytes(config.messageMaxBytes()) - .build(); - reporter = AsyncReporter.builder(sender).build(); - reg = context.registerService(Reporter.class, reporter, new Hashtable(properties)); - } - - @Deactivate - public void deactive() { - reg.unregister(); - reporter.close(); - } - -} diff --git a/brave-features/.classpath b/brave-features/.classpath deleted file mode 100644 index fae1a2b..0000000 --- a/brave-features/.classpath +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/brave-features/pom.xml b/brave-features/pom.xml deleted file mode 100644 index 2a1bb0f..0000000 --- a/brave-features/pom.xml +++ /dev/null @@ -1,80 +0,0 @@ - - - - 4.0.0 - - io.zipkin.brave.karaf - brave-karaf-parent - 1.0.0-SNAPSHOT - ../pom.xml - - brave-features - pom - - - ${project.basedir}/.. - - - - - - src/main/resources - true - - - - - org.apache.maven.plugins - maven-resources-plugin - 2.7 - - - filter - generate-resources - - resources - - - - - - org.codehaus.mojo - build-helper-maven-plugin - 1.7 - - - attach-artifacts - package - - attach-artifact - - - - - target/classes/features.xml - xml - features - - - - - - - - - diff --git a/brave-features/src/main/resources/features.xml b/brave-features/src/main/resources/features.xml deleted file mode 100644 index 9cb5b49..0000000 --- a/brave-features/src/main/resources/features.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - scr - mvn:io.zipkin.java/zipkin/${zipkin.version} - mvn:io.zipkin.reporter/zipkin-reporter/${zipkin.reporter.version} - mvn:io.zipkin.reporter/zipkin-sender-urlconnection/${zipkin.reporter.version} - mvn:io.zipkin.brave/brave-core/${brave.version} - mvn:io.zipkin.brave.karaf/brave-exporter/${project.version} - - - - brave-core - mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.kafka-clients/0.8.2.2_1 - mvn:io.zipkin.reporter/zipkin-sender-kafka08/${zipkin.reporter.version} - mvn:io.zipkin.brave.karaf/brave-exporter-kafka08/${project.version} - - - - brave-core - mvn:org.apache.httpcomponents/httpcore-osgi/4.4.5 - mvn:org.apache.httpcomponents/httpclient-osgi/4.5.3 - mvn:io.zipkin.brave/brave/${brave.version} - mvn:io.zipkin.brave/brave/${brave.version} - mvn:io.zipkin.brave/brave-instrumentation-http/${brave.version} - mvn:io.zipkin.brave/brave-instrumentation-httpclient/${brave.version} - mvn:io.zipkin.brave/brave-context-slf4j/${brave.version} - mvn:io.zipkin.reporter/zipkin-sender-okhttp3/${zipkin.reporter.version} - wrap:mvn:com.squareup.okhttp3/okhttp/3.8.0 - wrap:mvn:com.squareup.okio/okio/1.13.0 - mvn:io.zipkin.brave.karaf/brave-exporter-okhttp3/${project.version} - - - - brave-core - mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.jsr339-api-2.0.1/2.6.0 - mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.javax-inject/1_2 - mvn:io.zipkin.brave/brave-http/${brave.version} - mvn:io.zipkin.brave/brave-jaxrs2/${brave.version} - - - \ No newline at end of file diff --git a/brave-itests/pom.xml b/brave-itests/pom.xml deleted file mode 100644 index ce934df..0000000 --- a/brave-itests/pom.xml +++ /dev/null @@ -1,175 +0,0 @@ - - - - 4.0.0 - - io.zipkin.brave.karaf - brave-karaf-parent - 1.0.0-SNAPSHOT - ../pom.xml - - brave-itests - - - 4.5.0 - 2.1.0 - 1.0.4 - 1.7.4 - 4.0.7 - 4.12 - ${project.basedir}/.. - - - - - io.zipkin.brave - brave-core - - - io.zipkin.brave.karaf - brave-exporter - ${project.version} - - - io.zipkin.brave.karaf - brave-exporter-kafka08 - ${project.version} - - - io.zipkin.reporter - zipkin-sender-urlconnection - - - io.zipkin.reporter - zipkin-sender-kafka08 - - - - junit - junit - test - - - - - org.ops4j.pax.exam - pax-exam-junit4 - ${pax.exam.version} - test - - - org.ops4j.pax.exam - pax-exam-cm - ${pax.exam.version} - test - - - org.ops4j.pax.exam - pax-exam-invoker-junit - ${pax.exam.version} - test - - - - - org.ops4j.pax.exam - pax-exam-container-karaf - ${pax.exam.version} - test - - - org.ops4j.pax.exam - pax-exam-inject - ${pax.exam.version} - test - - - org.ops4j.pax.exam - pax-exam-extender-service - ${pax.exam.version} - test - - - - - org.ops4j.pax.exam - pax-exam-link-mvn - ${pax.exam.version} - test - - - - org.ops4j.pax.exam - pax-exam-link-assembly - ${pax.exam.version} - test - - - - ch.qos.logback - logback-core - ${logback.version} - test - - - - ch.qos.logback - logback-classic - ${logback.version} - test - - - - org.apache.geronimo.specs - geronimo-atinject_1.0_spec - 1.0 - provided - - - - org.osgi - org.osgi.core - 4.3.1 - provided - - - - org.osgi - org.osgi.compendium - 4.3.1 - provided - - - - - org.apache.karaf.features - standard - ${karaf.version} - xml - features - test - - - org.apache.karaf.features - org.apache.karaf.features.core - ${karaf.version} - test - - - - diff --git a/brave-itests/src/test/java/io/zipkin/brave/itests/BraveTest.java b/brave-itests/src/test/java/io/zipkin/brave/itests/BraveTest.java deleted file mode 100644 index 1e32ba8..0000000 --- a/brave-itests/src/test/java/io/zipkin/brave/itests/BraveTest.java +++ /dev/null @@ -1,126 +0,0 @@ -/** - * Copyright 2016 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 io.zipkin.brave.itests; - -import static org.hamcrest.core.IsEqual.equalTo; -import static org.ops4j.pax.exam.CoreOptions.maven; -import static org.ops4j.pax.exam.cm.ConfigurationAdminOptions.newConfiguration; -import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.configureConsole; -import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.features; -import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.karafDistributionConfiguration; -import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.keepRuntimeFolder; -import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.logLevel; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import javax.inject.Inject; - -import com.github.kristofa.brave.Brave; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.ops4j.pax.exam.Configuration; -import org.ops4j.pax.exam.Option; -import org.ops4j.pax.exam.junit.PaxExam; -import org.ops4j.pax.exam.karaf.options.LogLevelOption.LogLevel; -import org.ops4j.pax.exam.options.MavenArtifactUrlReference; -import org.ops4j.pax.exam.options.MavenUrlReference; -import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy; -import org.ops4j.pax.exam.spi.reactors.PerClass; -import org.ops4j.pax.exam.util.Filter; -import org.osgi.framework.BundleContext; -import org.osgi.framework.InvalidSyntaxException; -import org.osgi.framework.ServiceReference; -import zipkin.Span; -import zipkin.reporter.Reporter; - -@RunWith(PaxExam.class) -@ExamReactorStrategy(PerClass.class) -public class BraveTest { - private static final String FILTER_KAFKA08 = "(component.name=io.zipkin.reporter.kafka08)"; - - private static final String FILTER_URLCONNECT = "(component.name=io.zipkin.reporter.urlconnect)"; - - List spans = new ArrayList(); - - @Inject - @Filter(FILTER_URLCONNECT) - Reporter reporter; - - @Inject - @Filter(FILTER_KAFKA08) - Reporter reporterKafka; - - @Inject - BundleContext context; - - @Configuration - public static Option[] configuration() throws Exception { - MavenArtifactUrlReference karaf = maven().groupId("org.apache.karaf").artifactId("apache-karaf") - .type("zip").version("4.0.7"); - MavenUrlReference brave = maven().groupId("io.zipkin.brave.karaf").artifactId("brave-features").type("xml") - .classifier("features").version("1.0.0-SNAPSHOT"); - return new Option[] // - { - karafDistributionConfiguration().frameworkUrl(karaf).useDeployFolder(false), - configureConsole().ignoreLocalConsole(), // - logLevel(LogLevel.INFO), // - keepRuntimeFolder(), // - features(brave, "brave-core", "brave-kafka08"), - // Create an empty config to trigger creation of component - newConfiguration("io.zipkin.reporter.urlconnect").asOption(), - newConfiguration("io.zipkin.reporter.kafka08").asOption() - }; - } - - @Test - public void inlineBraveSetup() { - Reporter local = new Reporter() { - - @Override - public void report(Span span) { - spans.add(span); - } - }; - Brave brave = new Brave.Builder().reporter(local).build(); - brave.localTracer().startNewSpan("test", "testop"); - brave.localTracer().finishSpan(); - Assert.assertThat(1, equalTo(spans.size())); - } - - @SuppressWarnings("rawtypes") - @Test - public void checkReporterUrlConnect() throws InvalidSyntaxException { - ServiceReference ref = getSingleService(FILTER_URLCONNECT); - Assert.assertEquals(10000, ref.getProperty("connectTimeout")); - } - - @SuppressWarnings("rawtypes") - @Test - public void checkReporterKafka() throws InvalidSyntaxException { - ServiceReference ref = getSingleService(FILTER_KAFKA08); - Assert.assertEquals("zipkin", ref.getProperty("topic")); - } - - @SuppressWarnings("rawtypes") - private ServiceReference getSingleService(String filter) throws InvalidSyntaxException { - Collection> refs = context.getServiceReferences(Reporter.class, filter); - Assert.assertEquals(1, refs.size()); - return refs.iterator().next(); - } - -} diff --git a/exporter-sender-kafka/pom.xml b/exporter-sender-kafka/pom.xml new file mode 100644 index 0000000..d294f02 --- /dev/null +++ b/exporter-sender-kafka/pom.xml @@ -0,0 +1,78 @@ + + + + + io.zipkin.brave.karaf + brave-karaf-parent + 0.1.0-SNAPSHOT + + 4.0.0 + + brave-exporter-sender-kafka + Brave OSGi Exporter: Kafka Sender + + + ${project.basedir}/.. + + + + + org.osgi + osgi.core + provided + + + org.osgi + osgi.cmpn + provided + + + + io.zipkin.reporter2 + zipkin-reporter + + + io.zipkin.reporter2 + zipkin-sender-kafka11 + + + org.mockito + mockito-core + test + + + + + + + biz.aQute.bnd + bnd-maven-plugin + + + org.apache.maven.plugins + maven-jar-plugin + + + ${project.build.outputDirectory}/META-INF/MANIFEST.MF + + + + + + diff --git a/exporter-sender-kafka/src/main/java/io/zipkin/brave/exporter/sender/kafka/KafkaSenderExporter.java b/exporter-sender-kafka/src/main/java/io/zipkin/brave/exporter/sender/kafka/KafkaSenderExporter.java new file mode 100644 index 0000000..48d2b38 --- /dev/null +++ b/exporter-sender-kafka/src/main/java/io/zipkin/brave/exporter/sender/kafka/KafkaSenderExporter.java @@ -0,0 +1,80 @@ +/* + * Copyright 2016-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 io.zipkin.brave.exporter.sender.kafka; + +import java.util.HashMap; +import java.util.Hashtable; +import java.util.Map; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceRegistration; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.ConfigurationPolicy; +import org.osgi.service.component.annotations.Deactivate; +import org.osgi.service.metatype.annotations.Designate; +import org.osgi.service.metatype.annotations.ObjectClassDefinition; +import zipkin2.codec.Encoding; +import zipkin2.reporter.Sender; +import zipkin2.reporter.kafka11.KafkaSender; + +@Component( + immediate = true, + name = "io.zipkin.sender.kafka", + configurationPolicy = ConfigurationPolicy.REQUIRE +) +@Designate(ocd = KafkaSenderExporter.Config.class) +public class KafkaSenderExporter { + + private static final String OVERRIDE_PREFIX = "kafka."; + private ServiceRegistration reg; + private KafkaSender sender; + + @Activate + public void activate(Config config, BundleContext context, Map properties) { + sender = KafkaSender.newBuilder() + .bootstrapServers(config.bootstrapServers()) + .encoding(config.encoding()) + .messageMaxBytes(config.messageMaxBytes()) + .overrides(getOverrides(properties)) + .topic(config.topic()) + .build(); + reg = context.registerService(Sender.class, sender, new Hashtable(properties)); + } + + private HashMap getOverrides(Map properties) { + HashMap overrides = new HashMap(); + for (String key : properties.keySet()) { + if (key.startsWith(OVERRIDE_PREFIX)) { + overrides.put(key.substring(OVERRIDE_PREFIX.length() - 1), properties.get(key)); + } + } + return overrides; + } + + @Deactivate + public void deactive() { + reg.unregister(); + sender.close(); + } + + @ObjectClassDefinition(name = "Zipkin Sender Kafka") @interface Config { + String bootstrapServers() default "localhost:9092"; + + Encoding encoding() default Encoding.JSON; + + int messageMaxBytes() default 1000000; + + String topic() default "zipkin"; + } +} diff --git a/brave-exporter-kafka08/src/test/java/io/zipkin/brave/osgi/exporter/kafka/KafkaReporterExporterTest.java b/exporter-sender-kafka/src/test/java/io/zipkin/brave/exporter/sender/kafka/KafkaSenderExporterTest.java similarity index 50% rename from brave-exporter-kafka08/src/test/java/io/zipkin/brave/osgi/exporter/kafka/KafkaReporterExporterTest.java rename to exporter-sender-kafka/src/test/java/io/zipkin/brave/exporter/sender/kafka/KafkaSenderExporterTest.java index 8b6b10e..3c685c3 100644 --- a/brave-exporter-kafka08/src/test/java/io/zipkin/brave/osgi/exporter/kafka/KafkaReporterExporterTest.java +++ b/exporter-sender-kafka/src/test/java/io/zipkin/brave/exporter/sender/kafka/KafkaSenderExporterTest.java @@ -1,5 +1,5 @@ -/** - * Copyright 2016 The OpenZipkin Authors +/* + * Copyright 2016-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 @@ -11,34 +11,31 @@ * or implied. See the License for the specific language governing permissions and limitations under * the License. */ -package io.zipkin.brave.osgi.exporter.kafka; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; +package io.zipkin.brave.exporter.sender.kafka; +import io.zipkin.brave.exporter.sender.kafka.KafkaSenderExporter.Config; import java.util.HashMap; import java.util.Map; - -import io.zipkin.brave.osgi.exporter.kafka.KafkaReporterExporter.Config; import org.junit.Test; import org.osgi.framework.BundleContext; -import zipkin.reporter.Encoding; +import zipkin2.codec.Encoding; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; -@Config(bootstrapServers = "server1", messageMaxBytes = 10, topic="mytopic") -public class KafkaReporterExporterTest { - - @Test - public void testConfig() { - KafkaReporterExporter exporter = new KafkaReporterExporter(); - Map properties = new HashMap(); - properties.put("kafka.myprop", "myvalue"); - BundleContext context = mock(BundleContext.class); - Config config = mock(Config.class); - when(config.bootstrapServers()).thenReturn("server1"); - when(config.encoding()).thenReturn(Encoding.THRIFT); - when(config.topic()).thenReturn("mytopic"); - exporter.activate(config, context, properties); - } +@Config(bootstrapServers = "server1", messageMaxBytes = 10, topic = "mytopic") +public class KafkaSenderExporterTest { + @Test + public void testConfig() { + KafkaSenderExporter exporter = new KafkaSenderExporter(); + Map properties = new HashMap(); + properties.put("kafka.myprop", "myvalue"); + BundleContext context = mock(BundleContext.class); + Config config = mock(Config.class); + when(config.bootstrapServers()).thenReturn("server1"); + when(config.encoding()).thenReturn(Encoding.JSON); + when(config.topic()).thenReturn("mytopic"); + exporter.activate(config, context, properties); + } } diff --git a/exporter-sender-okhttp/pom.xml b/exporter-sender-okhttp/pom.xml new file mode 100644 index 0000000..9d919ba --- /dev/null +++ b/exporter-sender-okhttp/pom.xml @@ -0,0 +1,73 @@ + + + + + io.zipkin.brave.karaf + brave-karaf-parent + 0.1.0-SNAPSHOT + + 4.0.0 + + brave-exporter-sender-okhttp + Brave OSGi Exporter: OkHttp Sender + + + ${project.basedir}/.. + + + + + org.osgi + osgi.core + provided + + + org.osgi + osgi.cmpn + provided + + + + io.zipkin.reporter2 + zipkin-reporter + + + io.zipkin.reporter2 + zipkin-sender-okhttp3 + + + + + + + biz.aQute.bnd + bnd-maven-plugin + + + org.apache.maven.plugins + maven-jar-plugin + + + ${project.build.outputDirectory}/META-INF/MANIFEST.MF + + + + + + diff --git a/exporter-sender-okhttp/src/main/java/io/zipkin/brave/exporter/sender/okhttp/SenderOkHttpExporter.java b/exporter-sender-okhttp/src/main/java/io/zipkin/brave/exporter/sender/okhttp/SenderOkHttpExporter.java new file mode 100644 index 0000000..4899f1b --- /dev/null +++ b/exporter-sender-okhttp/src/main/java/io/zipkin/brave/exporter/sender/okhttp/SenderOkHttpExporter.java @@ -0,0 +1,63 @@ +/* + * Copyright 2016-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 io.zipkin.brave.exporter.sender.okhttp; + +import java.util.Hashtable; +import java.util.Map; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceRegistration; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.ConfigurationPolicy; +import org.osgi.service.component.annotations.Deactivate; +import org.osgi.service.metatype.annotations.Designate; +import org.osgi.service.metatype.annotations.ObjectClassDefinition; +import zipkin2.reporter.Sender; +import zipkin2.reporter.okhttp3.OkHttpSender; + +@Component( + immediate = true, + name = "io.zipkin.sender.okhttp", + configurationPolicy = ConfigurationPolicy.REQUIRE +) +@Designate(ocd = SenderOkHttpExporter.Config.class) +public class SenderOkHttpExporter { + + private ServiceRegistration reg; + private OkHttpSender sender; + + @ObjectClassDefinition(name = "Zipkin Sender OkHttp") @interface Config { + String endpoint() default "http://localhost:9411/api/v2/spans"; + + boolean compressionEnabled() default true; + + int messageMaxBytes() default 5 * 1024 * 1024; + } + + @Activate + public void activate(Config config, BundleContext context, Map properties) { + sender = OkHttpSender.newBuilder() + .endpoint(config.endpoint()) + .compressionEnabled(config.compressionEnabled()) + .messageMaxBytes(config.messageMaxBytes()) + .build(); + reg = context.registerService(Sender.class, sender, new Hashtable<>(properties)); + } + + @Deactivate + public void deactive() { + reg.unregister(); + if (sender != null) sender.close(); + } +} \ No newline at end of file diff --git a/exporter/pom.xml b/exporter/pom.xml new file mode 100644 index 0000000..dfb4c0f --- /dev/null +++ b/exporter/pom.xml @@ -0,0 +1,77 @@ + + + + + io.zipkin.brave.karaf + brave-karaf-parent + 0.1.0-SNAPSHOT + + 4.0.0 + + brave-exporter + Brave OSGi Exporter + + + ${project.basedir}/.. + + + + + org.osgi + osgi.core + provided + + + org.osgi + osgi.cmpn + provided + + + + io.zipkin.brave + brave + + + io.zipkin.brave + brave-instrumentation-http + + + io.zipkin.reporter2 + zipkin-sender-urlconnection + + + + + + + biz.aQute.bnd + bnd-maven-plugin + + + org.apache.maven.plugins + maven-jar-plugin + + + ${project.build.outputDirectory}/META-INF/MANIFEST.MF + + + + + + diff --git a/exporter/src/main/java/io/zipkin/brave/exporter/AsyncReporterExporter.java b/exporter/src/main/java/io/zipkin/brave/exporter/AsyncReporterExporter.java new file mode 100644 index 0000000..6d32a38 --- /dev/null +++ b/exporter/src/main/java/io/zipkin/brave/exporter/AsyncReporterExporter.java @@ -0,0 +1,60 @@ +/* + * Copyright 2016-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 io.zipkin.brave.exporter; + +import java.util.Hashtable; +import java.util.Map; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceRegistration; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Deactivate; +import org.osgi.service.component.annotations.Reference; +import org.osgi.service.metatype.annotations.Designate; +import org.osgi.service.metatype.annotations.ObjectClassDefinition; +import zipkin2.Span; +import zipkin2.reporter.AsyncReporter; +import zipkin2.reporter.Reporter; +import zipkin2.reporter.Sender; + +@Component( + immediate = true, + name = "io.zipkin.asyncreporter" +) +@Designate(ocd = AsyncReporterExporter.Config.class) +public class AsyncReporterExporter { + @Reference + Sender sender; + + private AsyncReporter reporter; + @SuppressWarnings("rawtypes") + private ServiceRegistration reg; + + @Activate + public void activate(Config config, BundleContext context, Map properties) { + reporter = AsyncReporter.builder(sender) + .build(); + reg = context.registerService(Reporter.class, reporter, + new Hashtable(properties)); + } + + @Deactivate + public void deactive() { + reg.unregister(); + if (reporter != null) reporter.close(); + } + + @ObjectClassDefinition(name = "AsyncReporter") @interface Config { + } +} diff --git a/exporter/src/main/java/io/zipkin/brave/exporter/HttpTracingExporter.java b/exporter/src/main/java/io/zipkin/brave/exporter/HttpTracingExporter.java new file mode 100644 index 0000000..be6dcd7 --- /dev/null +++ b/exporter/src/main/java/io/zipkin/brave/exporter/HttpTracingExporter.java @@ -0,0 +1,55 @@ +/* + * Copyright 2016-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 io.zipkin.brave.exporter; + +import brave.Tracing; +import brave.http.HttpTracing; +import java.util.Hashtable; +import java.util.Map; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceRegistration; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Deactivate; +import org.osgi.service.component.annotations.Reference; +import org.osgi.service.metatype.annotations.Designate; +import org.osgi.service.metatype.annotations.ObjectClassDefinition; + +@Component( + immediate = true, + name = "io.zipkin.brave.http" +) +@Designate(ocd = HttpTracingExporter.Config.class) +public class HttpTracingExporter { + @Reference + Tracing tracing; + + private ServiceRegistration reg; + + @Activate + public void activate(Config config, BundleContext context, Map properties) { + HttpTracing httpTracing = HttpTracing.newBuilder(tracing) + .build(); + reg = context.registerService(HttpTracing.class, httpTracing, + new Hashtable(properties)); + } + + @Deactivate + public void deactive() { + reg.unregister(); + } + + @ObjectClassDefinition(name = "HttpTracing") @interface Config { + } +} diff --git a/exporter/src/main/java/io/zipkin/brave/exporter/TracingExporter.java b/exporter/src/main/java/io/zipkin/brave/exporter/TracingExporter.java new file mode 100644 index 0000000..eae174d --- /dev/null +++ b/exporter/src/main/java/io/zipkin/brave/exporter/TracingExporter.java @@ -0,0 +1,68 @@ +/* + * Copyright 2016-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 io.zipkin.brave.exporter; + +import brave.Tracing; +import brave.sampler.Sampler; +import java.util.Hashtable; +import java.util.Map; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceRegistration; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Deactivate; +import org.osgi.service.component.annotations.Reference; +import org.osgi.service.metatype.annotations.Designate; +import org.osgi.service.metatype.annotations.ObjectClassDefinition; +import zipkin2.Span; +import zipkin2.reporter.Reporter; + +@Component( + immediate = true, + name = "io.zipkin.brave" +) +@Designate(ocd = TracingExporter.Config.class) +public class TracingExporter { + @Reference + Reporter reporter; + + private Tracing tracing; + private ServiceRegistration reg; + + @Activate + public void activate(Config config, BundleContext context, Map properties) { + tracing = Tracing.newBuilder() + .localServiceName(config.name()) + .spanReporter(reporter) + .traceId128Bit(config.traceId128Bit()) + .sampler(Sampler.create(config.rate())) + .build(); + reg = + context.registerService(Tracing.class, tracing, new Hashtable(properties)); + } + + @Deactivate + public void deactive() { + reg.unregister(); + if (tracing != null) tracing.close(); + } + + @ObjectClassDefinition(name = "Tracing") @interface Config { + String name() default "unknown"; + + boolean traceId128Bit() default false; + + float rate() default 1; + } +} diff --git a/exporter/src/main/java/io/zipkin/brave/exporter/sender/urlconnection/URLConnectionSenderExporter.java b/exporter/src/main/java/io/zipkin/brave/exporter/sender/urlconnection/URLConnectionSenderExporter.java new file mode 100644 index 0000000..78c8b11 --- /dev/null +++ b/exporter/src/main/java/io/zipkin/brave/exporter/sender/urlconnection/URLConnectionSenderExporter.java @@ -0,0 +1,66 @@ +/* + * Copyright 2016-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 io.zipkin.brave.exporter.sender.urlconnection; + +import java.util.Hashtable; +import java.util.Map; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceRegistration; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.ConfigurationPolicy; +import org.osgi.service.component.annotations.Deactivate; +import org.osgi.service.metatype.annotations.Designate; +import org.osgi.service.metatype.annotations.ObjectClassDefinition; +import zipkin2.reporter.Sender; +import zipkin2.reporter.urlconnection.URLConnectionSender; + +@Component( + immediate = true, + name = "io.zipkin.sender.urlconnection", + configurationPolicy = ConfigurationPolicy.REQUIRE +) +@Designate(ocd = URLConnectionSenderExporter.Config.class) +public class URLConnectionSenderExporter { + + private ServiceRegistration reg; + private URLConnectionSender sender; + + @Activate + public void activate(Config config, BundleContext context, Map properties) { + sender = URLConnectionSender.newBuilder() + .endpoint(config.endpoint()) + .compressionEnabled(config.compressionEnabled()) + .connectTimeout(config.connectTimeout()) + .messageMaxBytes(config.messageMaxBytes()) + .build(); + reg = context.registerService(Sender.class, sender, new Hashtable(properties)); + } + + @Deactivate + public void deactive() { + reg.unregister(); + if (sender != null) sender.close(); + } + + @ObjectClassDefinition(name = "Zipkin Sender URLConnection") @interface Config { + String endpoint() default "http://localhost:9411/api/v2/spans"; + + boolean compressionEnabled() default true; + + int connectTimeout() default 10 * 1000; + + int messageMaxBytes() default 5 * 1024 * 1024; + } +} \ No newline at end of file diff --git a/features/pom.xml b/features/pom.xml new file mode 100644 index 0000000..5f6256d --- /dev/null +++ b/features/pom.xml @@ -0,0 +1,81 @@ + + + + 4.0.0 + + io.zipkin.brave.karaf + brave-karaf-parent + 0.1.0-SNAPSHOT + ../pom.xml + + brave-features + pom + + + ${project.basedir}/.. + + + + + + src/main/resources + true + + + + + org.apache.maven.plugins + maven-resources-plugin + 3.1.0 + + + filter + generate-resources + + resources + + + + + + org.codehaus.mojo + build-helper-maven-plugin + 3.0.0 + + + attach-artifacts + package + + attach-artifact + + + + + target/classes/features.xml + xml + features + + + + + + + + + diff --git a/features/src/main/resources/features.xml b/features/src/main/resources/features.xml new file mode 100644 index 0000000..72377d7 --- /dev/null +++ b/features/src/main/resources/features.xml @@ -0,0 +1,44 @@ + + + + + + scr + mvn:io.zipkin.zipkin2/zipkin/${zipkin.version} + mvn:io.zipkin.reporter2/zipkin-reporter/${zipkin.reporter.version} + mvn:io.zipkin.reporter2/zipkin-sender-urlconnection/${zipkin.reporter.version} + mvn:io.zipkin.brave/brave/${brave.version} + mvn:io.zipkin.brave/brave-instrumentation-http/${brave.version} + mvn:io.zipkin.brave.karaf/brave-exporter/${project.version} + + + + brave + mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.kafka-clients/1.1.0_1 + mvn:io.zipkin.reporter2/zipkin-sender-kafka11/${zipkin.reporter.version} + mvn:io.zipkin.brave.karaf/brave-exporter-sender-kafka/${project.version} + + + + brave + mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.okhttp/3.10.0_2 + mvn:io.zipkin.reporter2/zipkin-sender-okhttp3/${zipkin.reporter.version} + mvn:io.zipkin.brave.karaf/brave-exporter-sender-okhttp/${project.version} + + \ No newline at end of file diff --git a/brave-itests/.gitignore b/itests/.gitignore similarity index 100% rename from brave-itests/.gitignore rename to itests/.gitignore diff --git a/itests/pom.xml b/itests/pom.xml new file mode 100644 index 0000000..7bed232 --- /dev/null +++ b/itests/pom.xml @@ -0,0 +1,156 @@ + + + + 4.0.0 + + io.zipkin.brave.karaf + brave-karaf-parent + 0.1.0-SNAPSHOT + ../pom.xml + + brave-itests + + + 4.12.0 + 4.2.0 + ${project.basedir}/.. + + + + + io.zipkin.brave.karaf + brave-exporter + + + io.zipkin.reporter2 + zipkin-sender-urlconnection + + + io.zipkin.brave + brave + + + + io.zipkin.brave.karaf + brave-exporter-sender-kafka + + + io.zipkin.reporter2 + zipkin-sender-kafka11 + + + + io.zipkin.brave.karaf + brave-exporter-sender-okhttp + + + io.zipkin.reporter2 + zipkin-sender-okhttp3 + + + + + org.ops4j.pax.exam + pax-exam-junit4 + ${pax-exam.version} + test + + + org.ops4j.pax.exam + pax-exam-cm + ${pax-exam.version} + test + + + org.ops4j.pax.exam + pax-exam-invoker-junit + ${pax-exam.version} + test + + + + + org.ops4j.pax.exam + pax-exam-container-karaf + ${pax-exam.version} + test + + + org.ops4j.pax.exam + pax-exam-inject + ${pax-exam.version} + test + + + org.ops4j.pax.exam + pax-exam-extender-service + ${pax-exam.version} + test + + + + + org.ops4j.pax.exam + pax-exam-link-mvn + ${pax-exam.version} + test + + + + org.ops4j.pax.exam + pax-exam-link-assembly + ${pax-exam.version} + test + + + + org.apache.geronimo.specs + geronimo-atinject_1.0_spec + 1.0 + provided + + + + org.osgi + osgi.core + provided + + + org.osgi + osgi.cmpn + provided + + + + + org.apache.karaf.features + standard + ${karaf.version} + xml + features + test + + + org.apache.karaf.features + org.apache.karaf.features.core + ${karaf.version} + test + + + diff --git a/itests/src/test/java/io/zipkin/brave/itests/BraveTest.java b/itests/src/test/java/io/zipkin/brave/itests/BraveTest.java new file mode 100644 index 0000000..6698d4e --- /dev/null +++ b/itests/src/test/java/io/zipkin/brave/itests/BraveTest.java @@ -0,0 +1,97 @@ +/* + * Copyright 2016-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 io.zipkin.brave.itests; + +import java.util.Collection; +import javax.inject.Inject; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.ops4j.pax.exam.Configuration; +import org.ops4j.pax.exam.Option; +import org.ops4j.pax.exam.junit.PaxExam; +import org.ops4j.pax.exam.karaf.options.LogLevelOption.LogLevel; +import org.ops4j.pax.exam.options.MavenArtifactUrlReference; +import org.ops4j.pax.exam.options.MavenUrlReference; +import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy; +import org.ops4j.pax.exam.spi.reactors.PerClass; +import org.osgi.framework.BundleContext; +import org.osgi.framework.InvalidSyntaxException; +import org.osgi.framework.ServiceReference; +import zipkin2.reporter.Sender; + +import static org.ops4j.pax.exam.CoreOptions.maven; +import static org.ops4j.pax.exam.cm.ConfigurationAdminOptions.newConfiguration; +import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.configureConsole; +import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.features; +import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.karafDistributionConfiguration; +import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.keepRuntimeFolder; +import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.logLevel; + +@RunWith(PaxExam.class) +@ExamReactorStrategy(PerClass.class) +public class BraveTest { + private static final String FILTER_KAFKA = "(component.name=io.zipkin.sender.kafka)"; + private static final String FILTER_OKHTTP = "(component.name=io.zipkin.sender.okhttp)"; + private static final String FILTER_URLCONNECTION = + "(component.name=io.zipkin.sender.urlconnection)"; + + @Inject + BundleContext context; + + @Configuration + public static Option[] configuration() { + MavenArtifactUrlReference karaf = maven().groupId("org.apache.karaf").artifactId("apache-karaf") + .type("zip").version("4.0.7"); + MavenUrlReference brave = + maven().groupId("io.zipkin.brave.karaf").artifactId("brave-features").type("xml") + .classifier("features").version("0.1.0-SNAPSHOT"); + return new Option[] { + karafDistributionConfiguration().frameworkUrl(karaf).useDeployFolder(false), + configureConsole().ignoreLocalConsole(), + logLevel(LogLevel.INFO), + keepRuntimeFolder(), + features(brave, "brave", "brave-kafka", "brave-okhttp"), + // Create an empty config to trigger creation of component + newConfiguration("io.zipkin.sender.urlconnection").asOption(), + newConfiguration("io.zipkin.sender.okhttp").asOption(), + newConfiguration("io.zipkin.sender.kafka").asOption() + }; + } + + @Test + public void checkSenderUrlConnection() throws InvalidSyntaxException { + ServiceReference ref = getSingleSender(FILTER_URLCONNECTION); + Assert.assertEquals(10000, ref.getProperty("connectTimeout")); + } + + @Test + public void checkSenderKafka() throws InvalidSyntaxException { + ServiceReference ref = getSingleSender(FILTER_KAFKA); + Assert.assertEquals("zipkin", ref.getProperty("topic")); + } + + @Test + public void checkSenderOkHttp() throws InvalidSyntaxException { + ServiceReference ref = getSingleSender(FILTER_OKHTTP); + Assert.assertEquals("zipkin", ref.getProperty("topic")); + } + + @SuppressWarnings("rawtypes") + private ServiceReference getSingleSender(String filter) throws InvalidSyntaxException { + Collection> refs = context.getServiceReferences(Sender.class, filter); + Assert.assertEquals(1, refs.size()); + return refs.iterator().next(); + } +} diff --git a/brave-itests/src/test/resources/exam.properties b/itests/src/test/resources/exam.properties similarity index 100% rename from brave-itests/src/test/resources/exam.properties rename to itests/src/test/resources/exam.properties diff --git a/brave-itests/src/test/resources/logback.xml b/itests/src/test/resources/logback.xml similarity index 100% rename from brave-itests/src/test/resources/logback.xml rename to itests/src/test/resources/logback.xml diff --git a/mvnw b/mvnw index fc7efd1..5551fde 100755 --- a/mvnw +++ b/mvnw @@ -54,38 +54,16 @@ case "`uname`" in CYGWIN*) cygwin=true ;; MINGW*) mingw=true;; Darwin*) darwin=true - # - # Look for the Apple JDKs first to preserve the existing behaviour, and then look - # for the new JDKs provided by Oracle. - # - if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ] ; then - # - # Apple JDKs - # - export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home - fi - - if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ] ; then - # - # Apple JDKs - # - export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home - fi - - if [ -z "$JAVA_HOME" ] && [ -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ] ; then - # - # Oracle JDKs - # - export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home - fi - - if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then - # - # Apple JDKs - # - export JAVA_HOME=`/usr/libexec/java_home` - fi - ;; + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="`/usr/libexec/java_home`" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; esac if [ -z "$JAVA_HOME" ] ; then @@ -130,7 +108,7 @@ if $cygwin ; then CLASSPATH=`cygpath --path --unix "$CLASSPATH"` fi -# For Migwn, ensure paths are in UNIX format before anything is touched +# For Mingw, ensure paths are in UNIX format before anything is touched if $mingw ; then [ -n "$M2_HOME" ] && M2_HOME="`(cd "$M2_HOME"; pwd)`" @@ -184,27 +162,28 @@ fi CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher -# For Cygwin, switch paths to Windows format before running java -if $cygwin; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --path --windows "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --windows "$CLASSPATH"` -fi - # traverses directory structure from process work directory to filesystem root # first directory with .mvn subdirectory is considered project base directory find_maven_basedir() { - local basedir=$(pwd) - local wdir=$(pwd) + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" while [ "$wdir" != '/' ] ; do if [ -d "$wdir"/.mvn ] ; then basedir=$wdir break fi - wdir=$(cd "$wdir/.."; pwd) + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround done echo "${basedir}" } @@ -216,13 +195,87 @@ concat_lines() { fi } -export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)} +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" + while IFS="=" read key value; do + case "$key" in (wrapperUrl) jarUrl="$value"; break ;; + esac + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + + if command -v wget > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + wget "$jarUrl" -O "$wrapperJarPath" + elif command -v curl > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + curl -o "$wrapperJarPath" "$jarUrl" + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") + fi + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +fi MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" -# Provide a "standardized" way to retrieve the CLI args that will -# work with both Windows and non-Windows executions. -MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" -export MAVEN_CMD_LINE_ARGS +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain @@ -230,5 +283,4 @@ exec "$JAVACMD" \ $MAVEN_OPTS \ -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ - ${WRAPPER_LAUNCHER} $MAVEN_CMD_LINE_ARGS - + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/mvnw.cmd b/mvnw.cmd old mode 100644 new mode 100755 index 0d49a2d..48363fa --- a/mvnw.cmd +++ b/mvnw.cmd @@ -35,6 +35,8 @@ @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' @echo off +@REM set title of command window +title %0 @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% @@ -80,8 +82,6 @@ goto error :init -set MAVEN_CMD_LINE_ARGS=%MAVEN_CONFIG% %* - @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". @REM Fallback to current working directory if not found. @@ -117,11 +117,27 @@ for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do s :endReadAdditionalConfig SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" - -set WRAPPER_JAR=""%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain -%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CMD_LINE_ARGS% +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" +FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + echo Found %WRAPPER_JAR% +) else ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')" + echo Finished downloading %WRAPPER_JAR% +) +@REM End of extension + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* if ERRORLEVEL 1 goto error goto end diff --git a/pom.xml b/pom.xml index 1d271c1..5008b36 100644 --- a/pom.xml +++ b/pom.xml @@ -1,338 +1,444 @@ - - 4.0.0 - - io.zipkin.brave.karaf - brave-karaf-parent - 1.0.0-SNAPSHOT - pom - - - brave-features - brave-itests - brave-exporter - brave-exporter-kafka08 - brave-exporter-okhttp3 + + 4.0.0 + + io.zipkin.brave.karaf + brave-karaf-parent + 0.1.0-SNAPSHOT + pom + + + features + itests + exporter + exporter-sender-kafka + exporter-sender-okhttp - - UTF-8 - UTF-8 + + UTF-8 + UTF-8 1.6 java16 - ${project.basedir} - - 2.11 - - 4.5.0 - 1.24.0 - 0.10.0 - - 1.7.21 - - - Brave Karaf Parent - Brave Karaf Parent - https://github.com/openzipkin/brave-karaf - 2016 - - - OpenZipkin - http://zipkin.io/ - - - - - The Apache Software License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt - repo - - - - - https://github.com/openzipkin/brave-karaf - scm:git:https://github.com/openzipkin/brave-karaf - scm:git:https://github.com/openzipkin/brave-karaf - 0.0.1 - - - - - - - - bintray - https://api.bintray.com/maven/openzipkin/maven/brave-karaf/;publish=1 - - - jfrog-snapshots - http://oss.jfrog.org/artifactory/oss-snapshot-local - - - - - Github - https://github.com/openzipkin/brave-karaf/issues - - - - - - io.zipkin.java - zipkin - ${zipkin.version} - - - io.zipkin.reporter - zipkin-reporter - ${zipkin.reporter.version} - - - io.zipkin.reporter - zipkin-sender-urlconnection - ${zipkin.reporter.version} - - - io.zipkin.reporter - zipkin-sender-kafka08 - ${zipkin.reporter.version} - - - - io.zipkin.brave - brave-core - ${brave.version} - - - junit - junit - 4.12 - - - org.awaitility - awaitility - 2.0.0 - - - org.mockito - mockito-core - 2.3.0 - - - - - - - io.zipkin.java - zipkin - - - - - com.google.auto.value - auto-value - 1.3 - provided - - - - junit - junit - test - - - org.assertj - assertj-core - 3.5.2 - test - - - io.zipkin.java - zipkin - ${zipkin.version} - test-jar - - - ch.qos.logback - logback-classic - 1.1.7 - test - - - - - - - - - - io.takari - maven - 0.3.3 - - - - - - - true - maven-compiler-plugin - 3.5.1 - - 1.6 - 1.6 - - - - - org.codehaus.mojo - animal-sniffer-maven-plugin - 1.15 - - - org.codehaus.mojo.signature - ${main.signature.artifact} - 1.0 - - - - - - check - - - - - - - - maven-install-plugin - 2.5.2 - - true - - - - - com.mycila - license-maven-plugin - ${license-maven-plugin.version} - -
${main.basedir}/src/etc/header.txt
- - pom.xml - .travis.yml - .gitignore - .mvn/** - .settings.xml - mvnw* - build-support/** - etc/header.txt - **/.idea/** - LICENSE - **/*.md - src/test/resources/** - src/main/resources/** - - true -
- - - com.mycila - license-maven-plugin-git - ${license-maven-plugin.version} - - - - - - check - - compile - - -
- - - maven-release-plugin - 2.5.3 - - false - release - true - @{project.version} - - - - - io.zipkin.centralsync-maven-plugin - centralsync-maven-plugin - 0.1.0 - - zipkin-aws - - -
-
- - - - release - - - - - maven-source-plugin - 3.0.1 - - - attach-sources - - jar - - - - - - - maven-javadoc-plugin - 2.10.4 - - false - zipkin.aws.internal,zipkin.aws.internal.* - - - -Xdoclint:none - - - - attach-javadocs - - jar - - package - - - - - - - + ${project.basedir} + + + 5.1.5 + 2.10.4 + 2.7.7 + + 2.11 + 2.22.0 +
+ + Brave Karaf (Parent) + Brave Karaf (Parent) + https://github.com/openzipkin/brave-karaf + 2016 + + + OpenZipkin + http://zipkin.io/ + + + + + The Apache Software License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + + + https://github.com/openzipkin/brave-karaf + scm:git:https://github.com/openzipkin/brave-karaf.git + scm:git:https://github.com/openzipkin/brave-karaf.git + HEAD + + + + + + openzipkin + OpenZipkin Gitter + https://gitter.im/openzipkin/zipkin + + + + + + bintray + https://api.bintray.com/maven/openzipkin/maven/brave-karaf/;publish=1 + + + jfrog-snapshots + http://oss.jfrog.org/artifactory/oss-snapshot-local + + + + + Github + https://github.com/openzipkin/brave-karaf/issues + + + + + + ${project.groupId} + brave-exporter + ${project.version} + + + ${project.groupId} + brave-exporter-sender-kafka + ${project.version} + + + ${project.groupId} + brave-exporter-sender-okhttp + ${project.version} + + + + io.zipkin.zipkin2 + zipkin + ${zipkin.version} + + + io.zipkin.reporter2 + zipkin-reporter + ${zipkin-reporter.version} + + + io.zipkin.reporter2 + zipkin-sender-urlconnection + ${zipkin-reporter.version} + + + io.zipkin.reporter2 + zipkin-sender-kafka11 + ${zipkin-reporter.version} + + + io.zipkin.reporter2 + zipkin-sender-okhttp3 + ${zipkin-reporter.version} + + + io.zipkin.brave + brave + ${brave.version} + + + io.zipkin.brave + brave-instrumentation-http + ${brave.version} + + + + org.osgi + osgi.core + 6.0.0 + + + org.osgi + osgi.cmpn + 6.0.0 + + + + org.awaitility + awaitility + 3.1.2 + + + org.mockito + mockito-core + 2.21.0 + + + + + + + junit + junit + 4.12 + test + + + org.assertj + assertj-core + 3.10.0 + test + + + ch.qos.logback + logback-classic + 1.2.3 + test + + + + + + + + + + io.takari + maven + 0.6.1 + + + biz.aQute.bnd + bnd-maven-plugin + 4.0.0 + + + + bnd-process + + + + + + + + + + true + maven-compiler-plugin + 3.7.0 + + + 1.8 + 1.8 + javac-with-errorprone + true + true + + + + org.codehaus.plexus + plexus-compiler-javac-errorprone + 2.8.4 + + + com.google.errorprone + error_prone_core + 2.3.1 + + + + + + net.orfjackal.retrolambda + retrolambda-maven-plugin + 2.5.4 + + + + process-main + + + ${main.java.version} + true + true + + + + + + + maven-jar-plugin + 3.1.0 + + + + maven-surefire-plugin + ${maven-failsafe-plugin.version} + + + maven-failsafe-plugin + ${maven-failsafe-plugin.version} + + + + org.codehaus.mojo + animal-sniffer-maven-plugin + 1.17 + + + org.codehaus.mojo.signature + ${main.signature.artifact} + 1.0 + + + + + + check + + + + + + + + maven-install-plugin + 2.5.2 + + true + + + + + maven-deploy-plugin + 2.8.2 + + + + com.mycila + license-maven-plugin + ${license-maven-plugin.version} + +
${main.basedir}/src/etc/header.txt
+ + + SLASHSTAR_STYLE + + + .travis.yml + .gitignore + .mvn/** + mvnw* + etc/header.txt + **/.idea/** + LICENSE + **/*.md + src/test/resources/** + src/main/resources/** + build-support/** + + true +
+ + + com.mycila + license-maven-plugin-git + ${license-maven-plugin.version} + + + + + + check + + compile + + +
+ + + maven-enforcer-plugin + 3.0.0-M2 + + + enforce-java + + enforce + + + + + [1.8,9) + + + + + + + + + maven-release-plugin + 2.5.3 + + false + release + true + @{project.version} + + + + + io.zipkin.centralsync-maven-plugin + centralsync-maven-plugin + 0.1.0 + + brave-karaf + + +
+
+ + + + release + + + + + maven-source-plugin + 3.0.1 + + + attach-sources + + jar + + + + + + + maven-javadoc-plugin + 3.0.1 + + false + + none + + + + attach-javadocs + + jar + + package + + + + + + +