You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by bv...@apache.org on 2022/05/05 19:27:34 UTC

[camel] branch CAMEL-18055 updated (b7931e5f0de -> a7233608ac7)

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

bvahdat pushed a change to branch CAMEL-18055
in repository https://gitbox.apache.org/repos/asf/camel.git


 discard b7931e5f0de CAMEL-18055: Create tracing SpanDecorator for ServiceBusComponent
     add 18c14f88ee5 Regen for commit 63a0d061fba2f7db86e560710ab61306c8a7f219
     add ec8b1649638 Upgrade String template to version 4.3.3
     add 73cc6f94829 Sync deps
     add 0a420adce71 Upgrade Spring LDAP to version 2.3.7.RELEASE
     add ab56e7d967e Sync deps
     add c4fd9de5b14 Regen for commit 73cc6f948296f86f46bdaa4e763ffa7ec27c4f8f
     add 3d121ce5471 camel-jbang - Allow to run KameletBinding
     add fc29469169d camel-jbang - Bind should look for kamelet in local file first.
     add 3932e7df740 Fix locale issue in float formatting
     add 00094fca48c Trust self-signed certs for kubernetes client (#7551)
     add 2746a38d98a CAMEL-17861 (#7493)
     add 890a3e1537f CAMEL-17861 (#7493)
     add e0fcb229e87 CAMEL-18063: camel-jbang - Using --deps for debug may store null as GAV version
     add 051ea29efba Regen for commit 00094fca48cf5265ae75fc19ce1c4b160ae93ea2
     new a7233608ac7 CAMEL-18055: Create tracing SpanDecorator for ServiceBusComponent

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (b7931e5f0de)
            \
             N -- N -- N   refs/heads/CAMEL-18055 (a7233608ac7)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 camel-dependencies/pom.xml                         |  4 +--
 .../apache/camel/catalog/models/errorHandler.json  | 24 +++-------------
 .../camel/component/aws2/s3/utils/AWS2S3Utils.java |  8 ++++++
 .../component/azure/storage/blob/BlobUtils.java    | 11 +++++++-
 .../camel/jsonpath/JsonPathCustomMapperTest.java   |  3 +-
 .../apache/camel/dsl/jbang/core/commands/Bind.java | 32 ++++++++++++++--------
 .../camel/dsl/jbang/core/commands/Deploy.java      |  3 +-
 .../camel/dsl/jbang/core/commands/Image.java       |  3 +-
 .../apache/camel/dsl/jbang/core/commands/Run.java  |  3 +-
 .../camel/dsl/jbang/core/commands/Undeploy.java    |  3 +-
 .../main/java/org/apache/camel/main/MavenGav.java  | 10 +++++++
 parent/pom.xml                                     |  4 +--
 12 files changed, 67 insertions(+), 41 deletions(-)


[camel] 01/01: CAMEL-18055: Create tracing SpanDecorator for ServiceBusComponent

Posted by bv...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

bvahdat pushed a commit to branch CAMEL-18055
in repository https://gitbox.apache.org/repos/asf/camel.git

commit a7233608ac7bbb4bf403bd03d7690640d01d62c2
Author: Babak Vahdat <bv...@apache.org>
AuthorDate: Thu May 5 21:11:17 2022 +0200

    CAMEL-18055: Create tracing SpanDecorator for ServiceBusComponent
---
 .../org.apache.camel.tracing.SpanDecorator         |   1 +
 .../decorators/ServiceBusSpanDecorator.java        | 108 +++++++++++++++++++++
 .../decorators/ServiceBusSpanDecoratorTest.java    |  81 ++++++++++++++++
 3 files changed, 190 insertions(+)

diff --git a/components/camel-opentelemetry/src/main/resources/META-INF/services/org.apache.camel.tracing.SpanDecorator b/components/camel-opentelemetry/src/main/resources/META-INF/services/org.apache.camel.tracing.SpanDecorator
index 39b88a064e5..e575ef9978a 100644
--- a/components/camel-opentelemetry/src/main/resources/META-INF/services/org.apache.camel.tracing.SpanDecorator
+++ b/components/camel-opentelemetry/src/main/resources/META-INF/services/org.apache.camel.tracing.SpanDecorator
@@ -42,6 +42,7 @@ org.apache.camel.tracing.decorators.PlatformHttpSpanDecorator
 org.apache.camel.tracing.decorators.RabbitmqSpanDecorator
 org.apache.camel.tracing.decorators.RestSpanDecorator
 org.apache.camel.tracing.decorators.SedaSpanDecorator
+org.apache.camel.tracing.decorators.ServiceBusSpanDecorator
 org.apache.camel.tracing.decorators.ServletSpanDecorator
 org.apache.camel.tracing.decorators.SjmsSpanDecorator
 org.apache.camel.tracing.decorators.Sjms2SpanDecorator
diff --git a/components/camel-tracing/src/main/java/org/apache/camel/tracing/decorators/ServiceBusSpanDecorator.java b/components/camel-tracing/src/main/java/org/apache/camel/tracing/decorators/ServiceBusSpanDecorator.java
new file mode 100644
index 00000000000..5a38f4489a0
--- /dev/null
+++ b/components/camel-tracing/src/main/java/org/apache/camel/tracing/decorators/ServiceBusSpanDecorator.java
@@ -0,0 +1,108 @@
+package org.apache.camel.tracing.decorators;
+
+import java.time.Duration;
+import java.time.OffsetDateTime;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.tracing.SpanAdapter;
+
+public class ServiceBusSpanDecorator extends AbstractMessagingSpanDecorator {
+
+    static final String SERVICEBUS_CONTENT_TYPE = "contentType";
+    static final String SERVICEBUS_CORRELATION_ID = "correlationId";
+    static final String SERVICEBUS_DELIVERY_COUNT = "deliveryCount";
+    static final String SERVICEBUS_ENQUEUED_SEQUENCE_NUMBER = "enqueuedSequenceNumber";
+    static final String SERVICEBUS_ENQUEUED_TIME = "enqueuedTime";
+    static final String SERVICEBUS_EXPIRES_AT = "expiresAt";
+    static final String SERVICEBUS_PARTITION_KEY = "partitionKey";
+    static final String SERVICEBUS_REPLY_TO_SESSION_ID = "replyToSessionId";
+    static final String SERVICEBUS_SESSION_ID = "sessionId";
+    static final String SERVICEBUS_TIME_TO_LIVE = "ttl";
+
+    /**
+     * Constants copied from {@link org.apache.camel.component.azure.servicebus.ServiceBusConstants}
+     */
+    static final String CONTENT_TYPE = "CamelAzureServiceBusContentType";
+    static final String CORRELATION_ID = "CamelAzureServiceBusCorrelationId";
+    static final String DELIVERY_COUNT = "CamelAzureServiceBusDeliveryCount";
+    static final String ENQUEUED_SEQUENCE_NUMBER = "CamelAzureServiceBusEnqueuedSequenceNumber";
+    static final String ENQUEUED_TIME = "CamelAzureServiceBusEnqueuedTime";
+    static final String EXPIRES_AT = "CamelAzureServiceBusExpiresAt";
+    static final String MESSAGE_ID = "CamelAzureServiceBusMessageId";
+    static final String SESSION_ID = "CamelAzureServiceBusSessionId";
+    static final String REPLY_TO_SESSION_ID = "CamelAzureServiceBusReplyToSessionId";
+    static final String PARTITION_KEY = "CamelAzureServiceBusPartitionKey";
+    static final String TIME_TO_LIVE = "CamelAzureServiceBusTimeToLive";
+
+    @Override
+    public String getComponent() {
+        return "azure-servicebus";
+    }
+
+    @Override
+    public String getComponentClassName() {
+        return "org.apache.camel.component.azure.servicebus.ServiceBusComponent";
+    }
+
+    @Override
+    public void pre(SpanAdapter span, Exchange exchange, Endpoint endpoint) {
+        super.pre(span, exchange, endpoint);
+
+        String contentType = exchange.getIn().getHeader(CONTENT_TYPE, String.class);
+        if (contentType != null) {
+            span.setTag(SERVICEBUS_CONTENT_TYPE, contentType);
+        }
+
+        String correlationId = exchange.getIn().getHeader(CORRELATION_ID, String.class);
+        if (correlationId != null) {
+            span.setTag(SERVICEBUS_CORRELATION_ID, correlationId);
+        }
+
+        Long deliveryCount = exchange.getIn().getHeader(DELIVERY_COUNT, Long.class);
+        if (deliveryCount != null) {
+            span.setTag(SERVICEBUS_DELIVERY_COUNT, deliveryCount);
+        }
+
+        OffsetDateTime enqueuedSequenceNumber = exchange.getIn().getHeader(ENQUEUED_SEQUENCE_NUMBER, OffsetDateTime.class);
+        if (enqueuedSequenceNumber != null) {
+            span.setTag(SERVICEBUS_ENQUEUED_SEQUENCE_NUMBER, enqueuedSequenceNumber.toString());
+        }
+
+        OffsetDateTime enqueuedTime = exchange.getIn().getHeader(ENQUEUED_TIME, OffsetDateTime.class);
+        if (enqueuedTime != null) {
+            span.setTag(SERVICEBUS_ENQUEUED_TIME, enqueuedTime.toString());
+        }
+
+        OffsetDateTime expiresAt = exchange.getIn().getHeader(EXPIRES_AT, OffsetDateTime.class);
+        if (expiresAt != null) {
+            span.setTag(SERVICEBUS_EXPIRES_AT, expiresAt.toString());
+        }
+
+        String partitionKey = exchange.getIn().getHeader(PARTITION_KEY, String.class);
+        if (partitionKey != null) {
+            span.setTag(SERVICEBUS_PARTITION_KEY, partitionKey);
+        }
+
+        String replyToSessionId = exchange.getIn().getHeader(REPLY_TO_SESSION_ID, String.class);
+        if (replyToSessionId != null) {
+            span.setTag(SERVICEBUS_REPLY_TO_SESSION_ID, replyToSessionId);
+        }
+
+        String sessionId = exchange.getIn().getHeader(SESSION_ID, String.class);
+        if (sessionId != null) {
+            span.setTag(SERVICEBUS_SESSION_ID, sessionId);
+        }
+
+        Duration timeToLive = exchange.getIn().getHeader(TIME_TO_LIVE, Duration.class);
+        if (timeToLive != null) {
+            span.setTag(SERVICEBUS_TIME_TO_LIVE, timeToLive.toString());
+        }
+    }
+
+    @Override
+    protected String getMessageId(Exchange exchange) {
+        return exchange.getIn().getHeader(MESSAGE_ID, String.class);
+    }
+
+}
diff --git a/components/camel-tracing/src/test/java/org/apache/camel/tracing/decorators/ServiceBusSpanDecoratorTest.java b/components/camel-tracing/src/test/java/org/apache/camel/tracing/decorators/ServiceBusSpanDecoratorTest.java
new file mode 100644
index 00000000000..3006673d7ca
--- /dev/null
+++ b/components/camel-tracing/src/test/java/org/apache/camel/tracing/decorators/ServiceBusSpanDecoratorTest.java
@@ -0,0 +1,81 @@
+package org.apache.camel.tracing.decorators;
+
+import java.time.Duration;
+import java.time.OffsetDateTime;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.tracing.MockSpanAdapter;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class ServiceBusSpanDecoratorTest {
+
+    @Test
+    public void testGetMessageId() {
+        String messageId = "abcd";
+        Exchange exchange = Mockito.mock(Exchange.class);
+        Message message = Mockito.mock(Message.class);
+
+        Mockito.when(exchange.getIn()).thenReturn(message);
+        Mockito.when(message.getHeader(ServiceBusSpanDecorator.MESSAGE_ID, String.class)).thenReturn(messageId);
+
+        AbstractMessagingSpanDecorator decorator = new ServiceBusSpanDecorator();
+
+        assertEquals(messageId, decorator.getMessageId(exchange));
+    }
+
+    @Test
+    public void testPre() {
+        String contentType = "application/json";
+        String correlationId = "1234";
+        Long deliveryCount = 27L;
+        OffsetDateTime enqueuedSequenceNumber = OffsetDateTime.now();
+        OffsetDateTime enqueuedTime = OffsetDateTime.now();
+        OffsetDateTime expiresAt = OffsetDateTime.now();
+        String partitionKey = "MyPartitionKey";
+        String replyToSessionId = "MyReplyToSessionId";
+        String sessionId = "4321";
+        Duration ttl = Duration.ofDays(7);
+
+        Endpoint endpoint = Mockito.mock(Endpoint.class);
+        Exchange exchange = Mockito.mock(Exchange.class);
+        Message message = Mockito.mock(Message.class);
+
+        Mockito.when(endpoint.getEndpointUri()).thenReturn("azure-servicebus:topicOrQueueName");
+        Mockito.when(exchange.getIn()).thenReturn(message);
+        Mockito.when(message.getHeader(ServiceBusSpanDecorator.CONTENT_TYPE, String.class)).thenReturn(contentType);
+        Mockito.when(message.getHeader(ServiceBusSpanDecorator.CORRELATION_ID, String.class)).thenReturn(correlationId);
+        Mockito.when(message.getHeader(ServiceBusSpanDecorator.DELIVERY_COUNT, Long.class)).thenReturn(deliveryCount);
+        Mockito.when(message.getHeader(ServiceBusSpanDecorator.ENQUEUED_SEQUENCE_NUMBER, OffsetDateTime.class))
+                .thenReturn(enqueuedSequenceNumber);
+        Mockito.when(message.getHeader(ServiceBusSpanDecorator.ENQUEUED_TIME, OffsetDateTime.class)).thenReturn(enqueuedTime);
+        Mockito.when(message.getHeader(ServiceBusSpanDecorator.EXPIRES_AT, OffsetDateTime.class)).thenReturn(expiresAt);
+        Mockito.when(message.getHeader(ServiceBusSpanDecorator.PARTITION_KEY, String.class)).thenReturn(partitionKey);
+        Mockito.when(message.getHeader(ServiceBusSpanDecorator.REPLY_TO_SESSION_ID, String.class)).thenReturn(replyToSessionId);
+        Mockito.when(message.getHeader(ServiceBusSpanDecorator.SESSION_ID, String.class)).thenReturn(sessionId);
+        Mockito.when(message.getHeader(ServiceBusSpanDecorator.TIME_TO_LIVE, Duration.class)).thenReturn(ttl);
+
+        AbstractMessagingSpanDecorator decorator = new ServiceBusSpanDecorator();
+
+        MockSpanAdapter span = new MockSpanAdapter();
+
+        decorator.pre(span, exchange, endpoint);
+
+        assertEquals(contentType, span.tags().get(ServiceBusSpanDecorator.SERVICEBUS_CONTENT_TYPE));
+        assertEquals(correlationId, span.tags().get(ServiceBusSpanDecorator.SERVICEBUS_CORRELATION_ID));
+        assertEquals(deliveryCount, span.tags().get(ServiceBusSpanDecorator.SERVICEBUS_DELIVERY_COUNT));
+        assertEquals(enqueuedSequenceNumber.toString(),
+                span.tags().get(ServiceBusSpanDecorator.SERVICEBUS_ENQUEUED_SEQUENCE_NUMBER));
+        assertEquals(enqueuedTime.toString(), span.tags().get(ServiceBusSpanDecorator.SERVICEBUS_ENQUEUED_TIME));
+        assertEquals(expiresAt.toString(), span.tags().get(ServiceBusSpanDecorator.SERVICEBUS_EXPIRES_AT));
+        assertEquals(partitionKey, span.tags().get(ServiceBusSpanDecorator.SERVICEBUS_PARTITION_KEY));
+        assertEquals(replyToSessionId, span.tags().get(ServiceBusSpanDecorator.SERVICEBUS_REPLY_TO_SESSION_ID));
+        assertEquals(sessionId, span.tags().get(ServiceBusSpanDecorator.SERVICEBUS_SESSION_ID));
+        assertEquals(ttl.toString(), span.tags().get(ServiceBusSpanDecorator.SERVICEBUS_TIME_TO_LIVE));
+    }
+
+}