You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2019/12/04 06:43:17 UTC

[camel] branch master updated: Add nsq span decorator for opentracing

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/master by this push:
     new 46a4be8  Add nsq span decorator for opentracing
46a4be8 is described below

commit 46a4be838cbe219732ea6fa7acd395bc293cc984
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Dec 4 07:42:40 2019 +0100

    Add nsq span decorator for opentracing
---
 .../opentracing/decorators/NsqSpanDecorator.java   | 55 ++++++++++++++++++++++
 .../org.apache.camel.opentracing.SpanDecorator     |  1 +
 2 files changed, 56 insertions(+)

diff --git a/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/NsqSpanDecorator.java b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/NsqSpanDecorator.java
new file mode 100644
index 0000000..9f2d8dd
--- /dev/null
+++ b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/NsqSpanDecorator.java
@@ -0,0 +1,55 @@
+/*
+ * 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.
+ */
+package org.apache.camel.opentracing.decorators;
+
+import java.util.Map;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+
+public class NsqSpanDecorator extends AbstractMessagingSpanDecorator {
+
+    public static final String NSQ_MESSAGE_ID = "CamelNsqMessageId";
+    public static final String NSQ_TOPIC = "CamelNsqMessageTopic";
+
+    @Override
+    public String getComponent() {
+        return "nsq";
+    }
+
+    @Override
+    public String getComponentClassName() {
+        return "org.apache.camel.component.nsq.NsqComponent";
+    }
+
+
+    @Override
+    public String getDestination(Exchange exchange, Endpoint endpoint) {
+        String topic = (String)exchange.getIn().getHeader(NSQ_TOPIC);
+        if (topic == null) {
+            Map<String, String> queryParameters = toQueryParameters(endpoint.getEndpointUri());
+            topic = queryParameters.get("topic");
+        }
+        return topic != null ? topic : super.getDestination(exchange, endpoint);
+    }
+
+    @Override
+    protected String getMessageId(Exchange exchange) {
+        return exchange.getIn().getHeader(NSQ_MESSAGE_ID, String.class);
+    }
+
+}
diff --git a/components/camel-opentracing/src/main/resources/META-INF/services/org.apache.camel.opentracing.SpanDecorator b/components/camel-opentracing/src/main/resources/META-INF/services/org.apache.camel.opentracing.SpanDecorator
index fa21cb4..614d15d 100644
--- a/components/camel-opentracing/src/main/resources/META-INF/services/org.apache.camel.opentracing.SpanDecorator
+++ b/components/camel-opentracing/src/main/resources/META-INF/services/org.apache.camel.opentracing.SpanDecorator
@@ -37,6 +37,7 @@ org.apache.camel.opentracing.decorators.KafkaSpanDecorator
 org.apache.camel.opentracing.decorators.LogSpanDecorator
 org.apache.camel.opentracing.decorators.MongoDBSpanDecorator
 org.apache.camel.opentracing.decorators.NettyHttpSpanDecorator
+org.apache.camel.opentracing.decorators.NsqSpanDecorator
 org.apache.camel.opentracing.decorators.PahoSpanDecorator
 org.apache.camel.opentracing.decorators.RabbitmqSpanDecorator
 org.apache.camel.opentracing.decorators.RestSpanDecorator