CAMEL-9759: camel-zipkin - Instrument Camel. Work in progress.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/da6102a3 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/da6102a3 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/da6102a3 Branch: refs/heads/master Commit: da6102a37646c0f43c822f4ca76df906b9e04ae5 Parents: 82ead72 Author: Claus Ibsen <davscl...@apache.org> Authored: Wed Mar 30 11:01:14 2016 +0200 Committer: Claus Ibsen <davscl...@apache.org> Committed: Wed Mar 30 11:12:28 2016 +0200 ---------------------------------------------------------------------- .../camel/zipkin/starter/CamelZipkin.java | 6 ++-- .../zipkin/starter/ZipkinAutoConfiguration.java | 27 +++++++++------- .../starter/ZipkinConfigurationProperties.java | 34 ++++++++++++++------ .../src/main/resources/application.properties | 7 ++-- 4 files changed, 48 insertions(+), 26 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/da6102a3/components/camel-zipkin-starter/src/main/java/org/apache/camel/zipkin/starter/CamelZipkin.java ---------------------------------------------------------------------- diff --git a/components/camel-zipkin-starter/src/main/java/org/apache/camel/zipkin/starter/CamelZipkin.java b/components/camel-zipkin-starter/src/main/java/org/apache/camel/zipkin/starter/CamelZipkin.java index 823c889..339f603 100644 --- a/components/camel-zipkin-starter/src/main/java/org/apache/camel/zipkin/starter/CamelZipkin.java +++ b/components/camel-zipkin-starter/src/main/java/org/apache/camel/zipkin/starter/CamelZipkin.java @@ -5,9 +5,9 @@ * 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 - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> + * + * 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. http://git-wip-us.apache.org/repos/asf/camel/blob/da6102a3/components/camel-zipkin-starter/src/main/java/org/apache/camel/zipkin/starter/ZipkinAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/components/camel-zipkin-starter/src/main/java/org/apache/camel/zipkin/starter/ZipkinAutoConfiguration.java b/components/camel-zipkin-starter/src/main/java/org/apache/camel/zipkin/starter/ZipkinAutoConfiguration.java index 31cac0d..0466d34 100644 --- a/components/camel-zipkin-starter/src/main/java/org/apache/camel/zipkin/starter/ZipkinAutoConfiguration.java +++ b/components/camel-zipkin-starter/src/main/java/org/apache/camel/zipkin/starter/ZipkinAutoConfiguration.java @@ -5,9 +5,9 @@ * 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 - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> + * + * 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. @@ -34,19 +34,22 @@ public class ZipkinAutoConfiguration { // Camel handles the lifecycle of this bean @ConditionalOnMissingBean(ZipkinEventNotifier.class) ZipkinEventNotifier zipkinEventNotifier(CamelContext camelContext, - ZipkinConfigurationProperties configurationProperties) { + ZipkinConfigurationProperties config) { ZipkinEventNotifier notifier = new ZipkinEventNotifier(); - notifier.setHostName(configurationProperties.getHostName()); - notifier.setPort(configurationProperties.getPort()); - notifier.setRate(configurationProperties.getRate()); - if (ObjectHelper.isNotEmpty(configurationProperties.getServiceName())) { - notifier.setServiceName(configurationProperties.getServiceName()); + notifier.setHostName(config.getHostName()); + notifier.setPort(config.getPort()); + notifier.setRate(config.getRate()); + if (ObjectHelper.isNotEmpty(config.getServiceName())) { + notifier.setServiceName(config.getServiceName()); } - if (ObjectHelper.isNotEmpty(configurationProperties.getExcludePattern())) { - notifier.addExcludePattern(configurationProperties.getExcludePattern()); + if (config.getExcludePatterns() != null) { + notifier.setExcludePatterns(config.getExcludePatterns()); } - notifier.setIncludeMessageBody(configurationProperties.isIncludeMessageBody()); + if (config.getServiceMappings() != null) { + notifier.setServiceMappings(config.getServiceMappings()); + } + notifier.setIncludeMessageBody(config.isIncludeMessageBody()); // register the bean into CamelContext camelContext.getManagementStrategy().addEventNotifier(notifier); http://git-wip-us.apache.org/repos/asf/camel/blob/da6102a3/components/camel-zipkin-starter/src/main/java/org/apache/camel/zipkin/starter/ZipkinConfigurationProperties.java ---------------------------------------------------------------------- diff --git a/components/camel-zipkin-starter/src/main/java/org/apache/camel/zipkin/starter/ZipkinConfigurationProperties.java b/components/camel-zipkin-starter/src/main/java/org/apache/camel/zipkin/starter/ZipkinConfigurationProperties.java index 5d9f4fa..ffd338b 100644 --- a/components/camel-zipkin-starter/src/main/java/org/apache/camel/zipkin/starter/ZipkinConfigurationProperties.java +++ b/components/camel-zipkin-starter/src/main/java/org/apache/camel/zipkin/starter/ZipkinConfigurationProperties.java @@ -5,9 +5,9 @@ * 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 - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> + * + * 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. @@ -16,6 +16,9 @@ */ package org.apache.camel.zipkin.starter; +import java.util.Map; +import java.util.Set; + import org.springframework.boot.context.properties.ConfigurationProperties; @ConfigurationProperties(prefix = "camel.zipkin") @@ -26,7 +29,8 @@ public class ZipkinConfigurationProperties { private float rate = 1.0f; private boolean includeMessageBody; private String serviceName; - private String excludePattern; + private Set<String> excludePatterns; + private Map<String, String> serviceMappings; public String getHostName() { return hostName; @@ -89,14 +93,26 @@ public class ZipkinConfigurationProperties { this.serviceName = serviceName; } - public String getExcludePattern() { - return excludePattern; + public Set<String> getExcludePatterns() { + return excludePatterns; + } + + /** + * Sets exclude pattern(s) that will disable tracing with zipkin for Camel messages that matches the pattern. + */ + public void setExcludePatterns(Set<String> excludePatterns) { + this.excludePatterns = excludePatterns; + } + + public Map<String, String> getServiceMappings() { + return serviceMappings; } /** - * Sets an exclude pattern that will disable tracing with zipkin for Camel messages that matches the pattern. + * Sets service mapping(s) that matches Camel events to the given zipkin service name. + * The key is the pattern, the value is the service name. */ - public void setExcludePattern(String excludePattern) { - this.excludePattern = excludePattern; + public void setServiceMappings(Map<String, String> serviceMappings) { + this.serviceMappings = serviceMappings; } } http://git-wip-us.apache.org/repos/asf/camel/blob/da6102a3/examples/camel-example-zipkin/src/main/resources/application.properties ---------------------------------------------------------------------- diff --git a/examples/camel-example-zipkin/src/main/resources/application.properties b/examples/camel-example-zipkin/src/main/resources/application.properties index 39f6bd5..515564d 100644 --- a/examples/camel-example-zipkin/src/main/resources/application.properties +++ b/examples/camel-example-zipkin/src/main/resources/application.properties @@ -23,9 +23,12 @@ camel.springboot.main-run-controller=true camel.zipkin.host-name=192.168.99.100 camel.zipkin.port=9410 +# the name of the service camel.zipkin.service-name=hello -# the timer is just to trigger new requests ( -camel.zipkin.exclude-pattern=timer:hello* + +# exclude the timer as it just triggers a new client request +camel.zipkin.exclude-patterns=timer:hello* + # include the message body in the zipkin traces camel.zipkin.include-message-body=true