nbrendah commented on a change in pull request #3895:
URL: https://github.com/apache/activemq-artemis/pull/3895#discussion_r780082070



##########
File path: 
examples/features/standard/broker-plugin/src/main/java/org/apache/activemq/artemis/jms/example/OpenTracingBrokerPlugin.java
##########
@@ -0,0 +1,83 @@
+/*
+ * 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.activemq.artemis.jms.example;
+
+import io.opentelemetry.api.common.Attributes;
+import io.opentelemetry.api.trace.Span;
+import io.opentelemetry.api.trace.SpanKind;
+import io.opentelemetry.api.trace.Tracer;
+import io.opentelemetry.api.trace.TracerProvider;
+import io.opentelemetry.exporter.zipkin.ZipkinSpanExporter;
+import io.opentelemetry.sdk.OpenTelemetrySdk;
+import io.opentelemetry.sdk.resources.Resource;
+import io.opentelemetry.sdk.trace.SdkTracerProvider;
+import io.opentelemetry.sdk.trace.export.SimpleSpanProcessor;
+import io.opentelemetry.semconv.resource.attributes.ResourceAttributes;
+import org.apache.activemq.artemis.api.core.ActiveMQException;
+import org.apache.activemq.artemis.api.core.Message;
+import org.apache.activemq.artemis.core.postoffice.RoutingStatus;
+import org.apache.activemq.artemis.core.server.ServerSession;
+import org.apache.activemq.artemis.core.server.plugin.ActiveMQServerPlugin;
+import org.apache.activemq.artemis.core.transaction.Transaction;
+
+public class OpenTracingBrokerPlugin implements ActiveMQServerPlugin {
+    private Span span;
+
+    static Tracer tracer = initOpenTracing();
+    private static final String ENDPOINT_V2_SPANS = "/api/v2/spans";
+
+    @Override
+    public void beforeSend(ServerSession session,
+                           Transaction tx,
+                           Message message,
+                           boolean direct,
+                           boolean noAutoCreateQueue) throws ActiveMQException 
{
+
+        span = tracer.spanBuilder(String.format("message: %s", 
message.getStringProperty("count"))).setSpanKind(SpanKind.PRODUCER).startSpan();
+        span.addEvent(String.format("message: %s", 
message.getStringProperty("count")));
+    }
+
+    @Override
+    public void afterSend(Transaction tx, Message message, boolean direct, 
boolean noAutoCreateQueue,
+                          RoutingStatus result) throws ActiveMQException {
+        span.end();
+    }
+
+    public static Tracer initOpenTracing() {
+        ZipkinSpanExporter zipkinExporter =

Review comment:
       hello @clebertsuconic, i have modified the functionality to be 
auto-configured other than manually as before.
   By default the exports are transported to the `OTLP server` running at 
`localhost/127.0.0.1:4317` 
   You can try running it your self through `docker run 
otel/opentelemetry-collector` 
   For other ways of running this, you can checkout 
https://opentelemetry.io/docs/collector/getting-started/ and 
https://github.com/open-telemetry/opentelemetry-java/blob/main/sdk-extensions/autoconfigure/README.md

##########
File path: examples/features/standard/broker-plugin/pom.xml
##########
@@ -55,6 +55,38 @@ under the License.
          <groupId>org.apache.qpid</groupId>
          <artifactId>qpid-jms-client</artifactId>
       </dependency>
+      <dependency>
+         <groupId>io.opentelemetry</groupId>
+         <artifactId>opentelemetry-api</artifactId>
+      </dependency>
+      <dependency>
+         <groupId>io.opentelemetry</groupId>
+         <artifactId>opentelemetry-sdk</artifactId>
+      </dependency>
+      <dependency>
+         <groupId>io.opentelemetry</groupId>
+         <artifactId>opentelemetry-semconv</artifactId>
+      </dependency>
+      <dependency>
+         <groupId>io.opentelemetry</groupId>
+         <artifactId>opentelemetry-sdk-extension-autoconfigure</artifactId>
+      </dependency>
+      <dependency>
+         <groupId>io.opentelemetry</groupId>
+         <artifactId>opentelemetry-exporter-logging</artifactId>
+      </dependency>
+      <dependency>
+         <groupId>io.opentelemetry</groupId>
+         <artifactId>opentelemetry-exporter-otlp</artifactId>
+      </dependency>
+      <dependency>
+         <groupId>io.opentelemetry</groupId>
+         <artifactId>opentelemetry-exporter-jaeger</artifactId>
+      </dependency>
+      <dependency>
+         <groupId>io.opentelemetry</groupId>
+         <artifactId>opentelemetry-exporter-zipkin</artifactId>

Review comment:
       i don't what to limit the exporters that can be used.  Am passing all 
available exporter dependencies so that if a use chooses an exporter he/she 
wants, the Opentelemetry doesn't complain with `ClassNotFound` Exceptions while 
trying to access resources.

##########
File path: examples/features/standard/broker-plugin/pom.xml
##########
@@ -55,6 +55,38 @@ under the License.
          <groupId>org.apache.qpid</groupId>
          <artifactId>qpid-jms-client</artifactId>
       </dependency>
+      <dependency>
+         <groupId>io.opentelemetry</groupId>
+         <artifactId>opentelemetry-api</artifactId>
+      </dependency>
+      <dependency>
+         <groupId>io.opentelemetry</groupId>
+         <artifactId>opentelemetry-sdk</artifactId>
+      </dependency>
+      <dependency>
+         <groupId>io.opentelemetry</groupId>
+         <artifactId>opentelemetry-semconv</artifactId>
+      </dependency>
+      <dependency>
+         <groupId>io.opentelemetry</groupId>
+         <artifactId>opentelemetry-sdk-extension-autoconfigure</artifactId>
+      </dependency>
+      <dependency>
+         <groupId>io.opentelemetry</groupId>
+         <artifactId>opentelemetry-exporter-logging</artifactId>
+      </dependency>
+      <dependency>
+         <groupId>io.opentelemetry</groupId>
+         <artifactId>opentelemetry-exporter-otlp</artifactId>
+      </dependency>
+      <dependency>
+         <groupId>io.opentelemetry</groupId>
+         <artifactId>opentelemetry-exporter-jaeger</artifactId>
+      </dependency>
+      <dependency>
+         <groupId>io.opentelemetry</groupId>
+         <artifactId>opentelemetry-exporter-zipkin</artifactId>

Review comment:
       @clebertsuconic  @michaelandrepearce 
   i don't what to limit the exporters that can be used.  Am passing all 
available exporter dependencies so that if a use chooses an exporter he/she 
wants, the Opentelemetry doesn't complain with `ClassNotFoundException` while 
trying to access required resources.

##########
File path: examples/features/standard/broker-plugin/pom.xml
##########
@@ -55,6 +55,38 @@ under the License.
          <groupId>org.apache.qpid</groupId>
          <artifactId>qpid-jms-client</artifactId>
       </dependency>
+      <dependency>
+         <groupId>io.opentelemetry</groupId>
+         <artifactId>opentelemetry-api</artifactId>
+      </dependency>
+      <dependency>
+         <groupId>io.opentelemetry</groupId>
+         <artifactId>opentelemetry-sdk</artifactId>
+      </dependency>
+      <dependency>
+         <groupId>io.opentelemetry</groupId>
+         <artifactId>opentelemetry-semconv</artifactId>
+      </dependency>
+      <dependency>
+         <groupId>io.opentelemetry</groupId>
+         <artifactId>opentelemetry-sdk-extension-autoconfigure</artifactId>
+      </dependency>
+      <dependency>
+         <groupId>io.opentelemetry</groupId>
+         <artifactId>opentelemetry-exporter-logging</artifactId>
+      </dependency>
+      <dependency>
+         <groupId>io.opentelemetry</groupId>
+         <artifactId>opentelemetry-exporter-otlp</artifactId>
+      </dependency>
+      <dependency>
+         <groupId>io.opentelemetry</groupId>
+         <artifactId>opentelemetry-exporter-jaeger</artifactId>
+      </dependency>
+      <dependency>
+         <groupId>io.opentelemetry</groupId>
+         <artifactId>opentelemetry-exporter-zipkin</artifactId>

Review comment:
       > How do you establish the connection then?
   
   this is done the sdk during its auto-configuration.  So its upto 
opentelemetry to make sure the connection is set.  If any error occurs, then 
its a bug in auto-configuration and we have to report it back to 
opentelemetry-java
   
   > we need to establish what property we are going to send.
   
   i use count because i need to identify each span uniquely since the 
`getMessageId()` was returning null.  I thought using the `count` property set 
in the `BrokerPligin` would for a moment, create some uniqueness in spans.

##########
File path: examples/features/standard/broker-plugin/pom.xml
##########
@@ -55,6 +55,38 @@ under the License.
          <groupId>org.apache.qpid</groupId>
          <artifactId>qpid-jms-client</artifactId>
       </dependency>
+      <dependency>
+         <groupId>io.opentelemetry</groupId>
+         <artifactId>opentelemetry-api</artifactId>
+      </dependency>
+      <dependency>
+         <groupId>io.opentelemetry</groupId>
+         <artifactId>opentelemetry-sdk</artifactId>
+      </dependency>
+      <dependency>
+         <groupId>io.opentelemetry</groupId>
+         <artifactId>opentelemetry-semconv</artifactId>
+      </dependency>
+      <dependency>
+         <groupId>io.opentelemetry</groupId>
+         <artifactId>opentelemetry-sdk-extension-autoconfigure</artifactId>
+      </dependency>
+      <dependency>
+         <groupId>io.opentelemetry</groupId>
+         <artifactId>opentelemetry-exporter-logging</artifactId>
+      </dependency>
+      <dependency>
+         <groupId>io.opentelemetry</groupId>
+         <artifactId>opentelemetry-exporter-otlp</artifactId>
+      </dependency>
+      <dependency>
+         <groupId>io.opentelemetry</groupId>
+         <artifactId>opentelemetry-exporter-jaeger</artifactId>
+      </dependency>
+      <dependency>
+         <groupId>io.opentelemetry</groupId>
+         <artifactId>opentelemetry-exporter-zipkin</artifactId>

Review comment:
       > How do you establish the connection then?
   
   this is done by the Opentelemetry during its auto-configuration.  So its 
up-to opentelemetry to make sure the connection is set.  If any error occurs, 
then its a bug in auto-configuration and we have to report it back to 
opentelemetry-java
   
   > we need to establish what property we are going to send.
   
   i use count because i need to identify each span uniquely since the 
`getMessageId()` was returning null.  I thought using the `count` property set 
in the `BrokerPligin` would for a moment, create some uniqueness in spans.

##########
File path: examples/features/standard/broker-plugin/pom.xml
##########
@@ -55,6 +55,38 @@ under the License.
          <groupId>org.apache.qpid</groupId>
          <artifactId>qpid-jms-client</artifactId>
       </dependency>
+      <dependency>
+         <groupId>io.opentelemetry</groupId>
+         <artifactId>opentelemetry-api</artifactId>
+      </dependency>
+      <dependency>
+         <groupId>io.opentelemetry</groupId>
+         <artifactId>opentelemetry-sdk</artifactId>
+      </dependency>
+      <dependency>
+         <groupId>io.opentelemetry</groupId>
+         <artifactId>opentelemetry-semconv</artifactId>
+      </dependency>
+      <dependency>
+         <groupId>io.opentelemetry</groupId>
+         <artifactId>opentelemetry-sdk-extension-autoconfigure</artifactId>
+      </dependency>
+      <dependency>
+         <groupId>io.opentelemetry</groupId>
+         <artifactId>opentelemetry-exporter-logging</artifactId>
+      </dependency>
+      <dependency>
+         <groupId>io.opentelemetry</groupId>
+         <artifactId>opentelemetry-exporter-otlp</artifactId>
+      </dependency>
+      <dependency>
+         <groupId>io.opentelemetry</groupId>
+         <artifactId>opentelemetry-exporter-jaeger</artifactId>
+      </dependency>
+      <dependency>
+         <groupId>io.opentelemetry</groupId>
+         <artifactId>opentelemetry-exporter-zipkin</artifactId>

Review comment:
       > How do you establish the connection then?
   
   this is done by the Opentelemetry during its auto-configuration.  So its 
up-to opentelemetry to make sure the connection is set.  If any error occurs, 
then its a bug in auto-configuration and we have to report it back to 
opentelemetry-java
   
   > we need to establish what property we are going to send.
   
   i use count because i need to identify each span uniquely since the 
`getMessageId()` was returning null.  I thought using the `count` property set 
in the `BrokerPligin` would, for a moment, create some uniqueness in spans.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to