You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2022/08/25 18:15:06 UTC

[activemq-artemis] branch main updated: NO-JIRA Renaming example as opentelemetry

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

clebertsuconic pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git


The following commit(s) were added to refs/heads/main by this push:
     new a72d894cb7 NO-JIRA Renaming example as opentelemetry
a72d894cb7 is described below

commit a72d894cb73dae2d51a733c184cc45a53b69fd6f
Author: Clebert Suconic <cl...@apache.org>
AuthorDate: Thu Aug 25 12:03:26 2022 -0400

    NO-JIRA Renaming example as opentelemetry
---
 .../standard/{opentracing => opentelemetry}/pom.xml        |  8 ++++----
 .../standard/{opentracing => opentelemetry}/readme.md      |  8 ++++----
 .../activemq/artemis/jms/example/OpenTelemetryPlugin.java} | 14 +++++++++-----
 .../artemis/jms/example/OpenTelemetryPluginExample.java}   |  2 +-
 .../src/main/resources/activemq/server0/broker.xml         |  2 +-
 .../src/main/resources/tracing.properties                  |  2 +-
 .../artemis/jms/example/OpenTelemetryPluginTest.java}      |  4 ++--
 examples/features/standard/pom.xml                         |  4 ++--
 8 files changed, 24 insertions(+), 20 deletions(-)

diff --git a/examples/features/standard/opentracing/pom.xml b/examples/features/standard/opentelemetry/pom.xml
similarity index 97%
rename from examples/features/standard/opentracing/pom.xml
rename to examples/features/standard/opentelemetry/pom.xml
index e39c653858..91cfd6012c 100644
--- a/examples/features/standard/opentracing/pom.xml
+++ b/examples/features/standard/opentelemetry/pom.xml
@@ -27,7 +27,7 @@ under the License.
       <version>2.25.0-SNAPSHOT</version>
    </parent>
 
-   <artifactId>opentracing</artifactId>
+   <artifactId>opentelemetry</artifactId>
    <packaging>jar</packaging>
    <name>ActiveMQ Artemis Broker Plugin Example</name>
 
@@ -123,7 +123,7 @@ under the License.
                   <configuration>
                      <!-- The broker plugin will install this library on the server's classpath -->
                      <libList>
-                        <arg>org.apache.activemq.examples.broker:opentracing:${project.version}</arg>
+                        <arg>org.apache.activemq.examples.broker:opentelemetry:${project.version}</arg>
                      </libList>
                      <libListWithDeps>
                         <arg>io.opentelemetry:opentelemetry-api:${opentelemetry.version}</arg>
@@ -167,7 +167,7 @@ under the License.
                      <goal>runClient</goal>
                   </goals>
                   <configuration>
-                     <clientClass>org.apache.activemq.artemis.jms.example.OpenTracingPluginExample</clientClass>
+                     <clientClass>org.apache.activemq.artemis.jms.example.OpenTelemetryPluginExample</clientClass>
                   </configuration>
                </execution>
                <execution>
@@ -186,7 +186,7 @@ under the License.
             <dependencies>
                <dependency>
                   <groupId>org.apache.activemq.examples.broker</groupId>
-                  <artifactId>opentracing</artifactId>
+                  <artifactId>opentelemetry</artifactId>
                   <version>${project.version}</version>
                </dependency>
             </dependencies>
diff --git a/examples/features/standard/opentracing/readme.md b/examples/features/standard/opentelemetry/readme.md
similarity index 94%
rename from examples/features/standard/opentracing/readme.md
rename to examples/features/standard/opentelemetry/readme.md
index 7687166f94..e537d7acc3 100644
--- a/examples/features/standard/opentracing/readme.md
+++ b/examples/features/standard/opentelemetry/readme.md
@@ -1,10 +1,10 @@
-# Opentracing Plugin Example
+# opentelemetry Plugin Example
 
 This plugin
 embraces [OpenTelemetry Autoconfiguration](https://github.com/open-telemetry/opentelemetry-java/tree/main/sdk-extensions/autoconfigure)
 using environment-based properties to configure OpenTelemetry SDK.
 
-## Run Opentracing Plugin Example
+## Run OpenTelemetry Plugin Example
 
 [![Running the Example Demo](https://img.youtube.com/vi/MVGx7QrztZQ/0.jpg)](https://www.youtube.com/watch?v=MVGx7QrztZQ)
 
@@ -16,7 +16,7 @@ and create the broker manually.
 
 After seeing a **`Build Success`**, open the browser, connect to your Jeager running instance and check for spans.
 
-## Customise Opentracing Plugin Example
+## Customise OpenTelemetry Plugin Example
 
 The [`tracing.properties`](./src/main/resources/tracing.properties) has configuration properties that
 autoconfigure [Opentelemetry Exporter](https://github.com/open-telemetry/opentelemetry-java/tree/main/sdk-extensions/autoconfigure#exporters)
@@ -40,7 +40,7 @@ You can change this by choosing to use:
   > **Note:** command to start Zipkin instance `docker run -p 9411:9411 openzipkin/zipkin`
  
   
-You can also change the default service name from `opentracing_plugin` to any string by changing the value
+You can also change the default service name from `opentelemetry_plugin` to any string by changing the value
 of `otel.service.name`
 
 ## How to start exporters
diff --git a/examples/features/standard/opentracing/src/main/java/org/apache/activemq/artemis/jms/example/OpenTracingPlugin.java b/examples/features/standard/opentelemetry/src/main/java/org/apache/activemq/artemis/jms/example/OpenTelemetryPlugin.java
similarity index 86%
rename from examples/features/standard/opentracing/src/main/java/org/apache/activemq/artemis/jms/example/OpenTracingPlugin.java
rename to examples/features/standard/opentelemetry/src/main/java/org/apache/activemq/artemis/jms/example/OpenTelemetryPlugin.java
index 6668e9dd38..00bf1fd618 100644
--- a/examples/features/standard/opentracing/src/main/java/org/apache/activemq/artemis/jms/example/OpenTracingPlugin.java
+++ b/examples/features/standard/opentelemetry/src/main/java/org/apache/activemq/artemis/jms/example/OpenTelemetryPlugin.java
@@ -36,15 +36,15 @@ 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 OpenTracingPlugin implements ActiveMQServerPlugin {
+public class OpenTelemetryPlugin implements ActiveMQServerPlugin {
 
    private static final String OPERATION_NAME = "ArtemisMessageDelivery";
-   private static OpenTelemetrySdk sdk = initOpenTracing();
-   private static Tracer tracer = GlobalOpenTelemetry.getTracer(OpenTracingPlugin.class.getName());
+   private static OpenTelemetrySdk sdk = initopentelemetry();
+   private static Tracer tracer = GlobalOpenTelemetry.getTracer(OpenTelemetryPlugin.class.getName());
 
-   public static OpenTelemetrySdk initOpenTracing() {
+   public static OpenTelemetrySdk initopentelemetry() {
       try {
-         InputStream input = OpenTracingPlugin.class.getClassLoader().getResourceAsStream("tracing.properties");
+         InputStream input = OpenTelemetryPlugin.class.getClassLoader().getResourceAsStream("tracing.properties");
          if (input == null) {
             throw new NullPointerException("Unable to find tracing.properties file");
          }
@@ -66,6 +66,10 @@ public class OpenTracingPlugin implements ActiveMQServerPlugin {
                           Message message,
                           boolean direct,
                           boolean noAutoCreateQueue) throws ActiveMQException {
+
+      // TODO: find a way to inject a context based in https://github.com/kittylyst/OTel/blob/8faea2aab7b19680f78804ddff3d59b7b1135aab/src/main/java/io/opentelemetry/examples/utils/OpenTelemetryConfig.java#L96-L100
+      // if a client has the metadata, we should get the parent context here
+
       SpanBuilder spanBuilder = getTracer().spanBuilder(OPERATION_NAME).setAttribute("message", message.toString()).setSpanKind(SpanKind.SERVER);
       Span span = spanBuilder.startSpan();
       message.setUserContext(Span.class, span);
diff --git a/examples/features/standard/opentracing/src/main/java/org/apache/activemq/artemis/jms/example/OpenTracingPluginExample.java b/examples/features/standard/opentelemetry/src/main/java/org/apache/activemq/artemis/jms/example/OpenTelemetryPluginExample.java
similarity index 98%
rename from examples/features/standard/opentracing/src/main/java/org/apache/activemq/artemis/jms/example/OpenTracingPluginExample.java
rename to examples/features/standard/opentelemetry/src/main/java/org/apache/activemq/artemis/jms/example/OpenTelemetryPluginExample.java
index 9690d32ac8..213b15fee7 100644
--- a/examples/features/standard/opentracing/src/main/java/org/apache/activemq/artemis/jms/example/OpenTracingPluginExample.java
+++ b/examples/features/standard/opentelemetry/src/main/java/org/apache/activemq/artemis/jms/example/OpenTelemetryPluginExample.java
@@ -32,7 +32,7 @@ import org.apache.qpid.jms.JmsConnectionFactory;
 /**
  * A simple example which shows how to use a QueueBrowser to look at messages of a queue without removing them from the queue
  */
-public class OpenTracingPluginExample {
+public class OpenTelemetryPluginExample {
 
    public static void main(final String[] args) throws Exception {
 
diff --git a/examples/features/standard/opentracing/src/main/resources/activemq/server0/broker.xml b/examples/features/standard/opentelemetry/src/main/resources/activemq/server0/broker.xml
similarity index 99%
rename from examples/features/standard/opentracing/src/main/resources/activemq/server0/broker.xml
rename to examples/features/standard/opentelemetry/src/main/resources/activemq/server0/broker.xml
index 667ce90bf4..eeb69ebd9d 100644
--- a/examples/features/standard/opentracing/src/main/resources/activemq/server0/broker.xml
+++ b/examples/features/standard/opentelemetry/src/main/resources/activemq/server0/broker.xml
@@ -107,7 +107,7 @@ under the License.
       -->
 
       <broker-plugins>
-         <broker-plugin class-name="org.apache.activemq.artemis.jms.example.OpenTracingPlugin"/>
+         <broker-plugin class-name="org.apache.activemq.artemis.jms.example.OpenTelemetryPlugin"/>
       </broker-plugins>
 
       <acceptors>
diff --git a/examples/features/standard/opentracing/src/main/resources/tracing.properties b/examples/features/standard/opentelemetry/src/main/resources/tracing.properties
similarity index 97%
rename from examples/features/standard/opentracing/src/main/resources/tracing.properties
rename to examples/features/standard/opentelemetry/src/main/resources/tracing.properties
index f4eaee5f62..d1925a3449 100644
--- a/examples/features/standard/opentracing/src/main/resources/tracing.properties
+++ b/examples/features/standard/opentelemetry/src/main/resources/tracing.properties
@@ -25,7 +25,7 @@
 #otel.exporter.otlp.traces.protocol=grpc
 
 # service name
-otel.service.name=artemis_opentracing
+otel.service.name=artemis_opentelemetry
 
 # Jaeger exporter
 otel.traces.exporter=jaeger
diff --git a/examples/features/standard/opentracing/src/test/java/org/apache/activemq/artemis/jms/example/OpenTracingPluginTest.java b/examples/features/standard/opentelemetry/src/test/java/org/apache/activemq/artemis/jms/example/OpenTelemetryPluginTest.java
similarity index 98%
rename from examples/features/standard/opentracing/src/test/java/org/apache/activemq/artemis/jms/example/OpenTracingPluginTest.java
rename to examples/features/standard/opentelemetry/src/test/java/org/apache/activemq/artemis/jms/example/OpenTelemetryPluginTest.java
index 653aba695e..f70bce67e5 100644
--- a/examples/features/standard/opentracing/src/test/java/org/apache/activemq/artemis/jms/example/OpenTracingPluginTest.java
+++ b/examples/features/standard/opentelemetry/src/test/java/org/apache/activemq/artemis/jms/example/OpenTelemetryPluginTest.java
@@ -49,11 +49,11 @@ import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
 @RunWith(MockitoJUnitRunner.class)
-public class OpenTracingPluginTest {
+public class OpenTelemetryPluginTest {
 
    private final InMemorySpanExporter exporter = InMemorySpanExporter.create();
    @InjectMocks
-   private OpenTracingPlugin plugin;
+   private OpenTelemetryPlugin plugin;
 
    @Mock
    private SpanBuilder spanBuilder;
diff --git a/examples/features/standard/pom.xml b/examples/features/standard/pom.xml
index d99a468df7..c873e7ffc4 100644
--- a/examples/features/standard/pom.xml
+++ b/examples/features/standard/pom.xml
@@ -80,7 +80,7 @@ under the License.
             <module>message-priority</module>
             <module>netty-openssl</module>
             <module>no-consumer-buffering</module>
-            <module>opentracing</module>
+            <module>opentelemetry</module>
             <module>paging</module>
             <module>pre-acknowledge</module>
             <module>producer-rate-limit</module>
@@ -157,7 +157,7 @@ under the License.
             <module>message-priority</module>
             <module>netty-openssl</module>
             <module>no-consumer-buffering</module>
-            <module>opentracing</module>
+            <module>opentelemetry</module>
             <module>paging</module>
             <module>pre-acknowledge</module>
             <module>producer-rate-limit</module>