You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@activemq.apache.org by GitBox <gi...@apache.org> on 2022/01/05 14:58:06 UTC
[GitHub] [activemq-artemis] nbrendah opened a new pull request #3895: WIP: Adding Distrubuted support using OpenTelemetry
nbrendah opened a new pull request #3895:
URL: https://github.com/apache/activemq-artemis/pull/3895
hello @clebertsuconic, basing on the advise you gave me, to go back a step behind, this is what i have first produced.
I am looking forward to seeing your comments.
Thank you
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [activemq-artemis] clebertsuconic commented on pull request #3895: WIP: Adding Distrubuted support using OpenTelemetry
Posted by GitBox <gi...@apache.org>.
clebertsuconic commented on pull request #3895:
URL: https://github.com/apache/activemq-artemis/pull/3895#issuecomment-1029043124
I am asking this a draft just to avoid merging it by accident.
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [activemq-artemis] clebertsuconic commented on a change in pull request #3895: WIP: Adding Distrubuted support using OpenTelemetry
Posted by GitBox <gi...@apache.org>.
clebertsuconic commented on a change in pull request #3895:
URL: https://github.com/apache/activemq-artemis/pull/3895#discussion_r779560273
##########
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:
Is Zipkin the only possibility for open tracing?
Isn't there any API within Open Telemetry that would replace this?
I thought we talked about using a more standard library.
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [activemq-artemis] nbrendah commented on pull request #3895: WIP: Adding Distrubuted support using OpenTelemetry
Posted by GitBox <gi...@apache.org>.
nbrendah commented on pull request #3895:
URL: https://github.com/apache/activemq-artemis/pull/3895#issuecomment-1005761845
It works very well and each time you build the example, if Zipkin is running at the provided url, then you will see the traces.

--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [activemq-artemis] nbrendah edited a comment on pull request #3895: WIP: Adding Distrubuted support using OpenTelemetry
Posted by GitBox <gi...@apache.org>.
nbrendah edited a comment on pull request #3895:
URL: https://github.com/apache/activemq-artemis/pull/3895#issuecomment-1006141921
I am looking into cause of the build failure
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [activemq-artemis] nbrendah commented on a change in pull request #3895: WIP: Adding Distrubuted support using OpenTelemetry
Posted by GitBox <gi...@apache.org>.
nbrendah commented on a change in pull request #3895:
URL: https://github.com/apache/activemq-artemis/pull/3895#discussion_r780086256
##########
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.
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [activemq-artemis] clebertsuconic commented on a change in pull request #3895: WIP: Adding Distrubuted support using OpenTelemetry
Posted by GitBox <gi...@apache.org>.
clebertsuconic commented on a change in pull request #3895:
URL: https://github.com/apache/activemq-artemis/pull/3895#discussion_r780341186
##########
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:
Ohh.. I see.. you're light weight in dependencies...
How do you establish the connection then?
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [activemq-artemis] clebertsuconic commented on a change in pull request #3895: WIP: Adding Distrubuted support using OpenTelemetry
Posted by GitBox <gi...@apache.org>.
clebertsuconic commented on a change in pull request #3895:
URL: https://github.com/apache/activemq-artemis/pull/3895#discussion_r780341186
##########
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:
Ohh.. I see.. you're light weight in dependencies...
How do you establish the connection then?
##########
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:
@nbrendah I think we are in a good place to start packaging and testing this properly... we should be on a call..
There's one issue I see is that you always set a property called "count"... of course that would not work... we need to establish what property we are going to send.
and I believe the span would need a Thread Local?
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [activemq-artemis] nbrendah commented on a change in pull request #3895: WIP: Adding Distrubuted support using OpenTelemetry
Posted by GitBox <gi...@apache.org>.
nbrendah commented on a change in pull request #3895:
URL: https://github.com/apache/activemq-artemis/pull/3895#discussion_r789414835
##########
File path: examples/features/standard/broker-plugin/src/main/java/org/apache/activemq/artemis/jms/example/OpenTracingBrokerPlugin.java
##########
@@ -0,0 +1,90 @@
+/*
+ * 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 java.io.InputStream;
+import java.util.Properties;
+
+import io.opentelemetry.api.GlobalOpenTelemetry;
+import io.opentelemetry.api.trace.Span;
+import io.opentelemetry.api.trace.SpanBuilder;
+import io.opentelemetry.api.trace.SpanKind;
+import io.opentelemetry.api.trace.Tracer;
+import io.opentelemetry.api.trace.TracerProvider;
+import io.opentelemetry.sdk.OpenTelemetrySdk;
+import io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdk;
+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 ThreadLocal threadLocal = new ThreadLocal();
+ private static final String OPERATION_NAME = "/TracingPlugin/rootInvoke/";
+ private static OpenTelemetrySdk sdk = initOpenTracing();
+
+ public static OpenTelemetrySdk initOpenTracing() {
+ try {
+ InputStream input = OpenTracingBrokerPlugin.class.getClassLoader().getResourceAsStream("tracing.properties");
+ if (input == null) {
+ throw new NullPointerException("Unable to find tracing.properties file");
+ }
+ Properties prop = new Properties(System.getProperties());
+ prop.load(input);
+ System.setProperties(prop);
+
+ sdk = AutoConfiguredOpenTelemetrySdk.initialize().getOpenTelemetrySdk();
+
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ return sdk;
+ }
+
+ @Override
+ public void beforeSend(ServerSession session,
+ Transaction tx,
+ Message message,
+ boolean direct,
+ boolean noAutoCreateQueue) throws ActiveMQException {
+ SpanBuilder spanBuilder = GlobalOpenTelemetry.getTracer(OpenTracingBrokerPlugin.class.getName())
+ .spanBuilder(OPERATION_NAME)
+ .setAttribute("message", message.toString())
+ .setSpanKind(SpanKind.SERVER);
+ Span span = spanBuilder.startSpan();
+ threadLocal.set(span);
Review comment:
@franz1981 I thought we can add the ThreadLocal or span instance to the messages itself like `message.putObjectProperty("SpanThread", threadLocal);` But i get an exception `java.lang.ThreadLocal is not a valid property type: org.apache.activemq.artemis.api.core.ActiveMQPropertyConversionException` showing that `ThreadLocal` is not accepted as an object.
and then in the afterMethod we get it like` (ThreadLocal) message.getObjectProperty();` and finally get the span
##########
File path: examples/features/standard/broker-plugin/src/main/java/org/apache/activemq/artemis/jms/example/OpenTracingBrokerPlugin.java
##########
@@ -0,0 +1,90 @@
+/*
+ * 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 java.io.InputStream;
+import java.util.Properties;
+
+import io.opentelemetry.api.GlobalOpenTelemetry;
+import io.opentelemetry.api.trace.Span;
+import io.opentelemetry.api.trace.SpanBuilder;
+import io.opentelemetry.api.trace.SpanKind;
+import io.opentelemetry.api.trace.Tracer;
+import io.opentelemetry.api.trace.TracerProvider;
+import io.opentelemetry.sdk.OpenTelemetrySdk;
+import io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdk;
+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 ThreadLocal threadLocal = new ThreadLocal();
+ private static final String OPERATION_NAME = "/TracingPlugin/rootInvoke/";
+ private static OpenTelemetrySdk sdk = initOpenTracing();
+
+ public static OpenTelemetrySdk initOpenTracing() {
+ try {
+ InputStream input = OpenTracingBrokerPlugin.class.getClassLoader().getResourceAsStream("tracing.properties");
+ if (input == null) {
+ throw new NullPointerException("Unable to find tracing.properties file");
+ }
+ Properties prop = new Properties(System.getProperties());
+ prop.load(input);
+ System.setProperties(prop);
+
+ sdk = AutoConfiguredOpenTelemetrySdk.initialize().getOpenTelemetrySdk();
+
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ return sdk;
+ }
+
+ @Override
+ public void beforeSend(ServerSession session,
+ Transaction tx,
+ Message message,
+ boolean direct,
+ boolean noAutoCreateQueue) throws ActiveMQException {
+ SpanBuilder spanBuilder = GlobalOpenTelemetry.getTracer(OpenTracingBrokerPlugin.class.getName())
+ .spanBuilder(OPERATION_NAME)
+ .setAttribute("message", message.toString())
+ .setSpanKind(SpanKind.SERVER);
+ Span span = spanBuilder.startSpan();
+ threadLocal.set(span);
Review comment:
@franz1981 I thought we can add the ThreadLocal or span instance to the messages itself like `message.putObjectProperty("SpanThread", threadLocal);` But i get an exception `java.lang.ThreadLocal is not a valid property type: org.apache.activemq.artemis.api.core.ActiveMQPropertyConversionException` showing that `ThreadLocal` is not accepted as an object.
and then in the afterMethod we get it like` (ThreadLocal) message.getObjectProperty();` and finally get the span
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [activemq-artemis] nbrendah commented on a change in pull request #3895: WIP: Adding Distrubuted support using OpenTelemetry
Posted by GitBox <gi...@apache.org>.
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [activemq-artemis] nbrendah commented on a change in pull request #3895: WIP: Adding Distrubuted support using OpenTelemetry
Posted by GitBox <gi...@apache.org>.
nbrendah commented on a change in pull request #3895:
URL: https://github.com/apache/activemq-artemis/pull/3895#discussion_r780086256
##########
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.
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [activemq-artemis] nbrendah commented on a change in pull request #3895: WIP: Adding Distrubuted support using OpenTelemetry
Posted by GitBox <gi...@apache.org>.
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
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [activemq-artemis] nbrendah commented on a change in pull request #3895: WIP: Adding Distrubuted support using OpenTelemetry
Posted by GitBox <gi...@apache.org>.
nbrendah commented on a change in pull request #3895:
URL: https://github.com/apache/activemq-artemis/pull/3895#discussion_r779644440
##########
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:
There are very many tracing exporters @clebertsuconic
actually this takes to using auto-configuration which makes allows the user of the plugin to specify the tracing exporter.
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [activemq-artemis] clebertsuconic merged pull request #3895: ARTEMIS-3686: Adding example showing how to do telemetry support
Posted by GitBox <gi...@apache.org>.
clebertsuconic merged pull request #3895:
URL: https://github.com/apache/activemq-artemis/pull/3895
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [activemq-artemis] nbrendah commented on pull request #3895: WIP: Adding Distrubuted support using OpenTelemetry
Posted by GitBox <gi...@apache.org>.
nbrendah commented on pull request #3895:
URL: https://github.com/apache/activemq-artemis/pull/3895#issuecomment-1006141921
I am looking into cause of the build failure and also updating the licensees in my files
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [activemq-artemis] nbrendah commented on a change in pull request #3895: WIP: Adding Distrubuted support using OpenTelemetry
Posted by GitBox <gi...@apache.org>.
nbrendah commented on a change in pull request #3895:
URL: https://github.com/apache/activemq-artemis/pull/3895#discussion_r782905163
##########
File path: examples/features/standard/broker-plugin/src/test/java/org/apache/activemq/artemis/jms/example/OpenTracingBrokerPluginTest.java
##########
@@ -0,0 +1,68 @@
+/*
+ * 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 java.util.List;
+
+import io.opentelemetry.api.trace.SpanKind;
+import io.opentelemetry.sdk.testing.exporter.InMemorySpanExporter;
+import io.opentelemetry.sdk.trace.data.SpanData;
+import org.junit.Test;
+
+import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat;
+import static org.junit.Assert.assertNotNull;
+
+public class OpenTracingBrokerPluginTest {
+
+ private final InMemorySpanExporter exporter = InMemorySpanExporter.create();
+ //private SdkTracerProvider sdkTracerProvider;
+ //private Tracer tracer;
+
+ /**
+ * @Before public void setUp() {
+ * sdkTracerProvider = SdkTracerProvider.builder()
+ * .addSpanProcessor(SimpleSpanProcessor.create(exporter))
+ * .build();
+ * tracer = OpenTelemetrySdk.builder()
+ * .setTracerProvider(sdkTracerProvider)
+ * .buildAndRegisterGlobal()
+ * .getTracer("org.apache.activemq.artemis.jms.example.OpenTracingBrokerPlugin");
+ * }
+ **/
+
+ @Test
+ public void testSpans() {
+ List<SpanData> spanItems = exporter.getFinishedSpanItems();
+ assertNotNull(spanItems);
+ spanItems.forEach(span -> {
+ assertNotNull(span);
+ assertThat(span).hasKind(SpanKind.PRODUCER)
+ //.hasName("message")
+ //.hasEvents(...)
+ .hasNoParent().hasTotalRecordedEvents(1).hasEnded();
+
+ });
+ }
Review comment:
simple method checks that a span has been sent. It passes but I am really uncertain whether the passing is because i did something wrong in the configuration.
cc @clebertsuconic @michaelandrepearce
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [activemq-artemis] nbrendah commented on a change in pull request #3895: WIP: Adding Distrubuted support using OpenTelemetry
Posted by GitBox <gi...@apache.org>.
nbrendah commented on a change in pull request #3895:
URL: https://github.com/apache/activemq-artemis/pull/3895#discussion_r780476828
##########
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.
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [activemq-artemis] nbrendah commented on a change in pull request #3895: WIP: Adding Distrubuted support using OpenTelemetry
Posted by GitBox <gi...@apache.org>.
nbrendah commented on a change in pull request #3895:
URL: https://github.com/apache/activemq-artemis/pull/3895#discussion_r789414835
##########
File path: examples/features/standard/broker-plugin/src/main/java/org/apache/activemq/artemis/jms/example/OpenTracingBrokerPlugin.java
##########
@@ -0,0 +1,90 @@
+/*
+ * 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 java.io.InputStream;
+import java.util.Properties;
+
+import io.opentelemetry.api.GlobalOpenTelemetry;
+import io.opentelemetry.api.trace.Span;
+import io.opentelemetry.api.trace.SpanBuilder;
+import io.opentelemetry.api.trace.SpanKind;
+import io.opentelemetry.api.trace.Tracer;
+import io.opentelemetry.api.trace.TracerProvider;
+import io.opentelemetry.sdk.OpenTelemetrySdk;
+import io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdk;
+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 ThreadLocal threadLocal = new ThreadLocal();
+ private static final String OPERATION_NAME = "/TracingPlugin/rootInvoke/";
+ private static OpenTelemetrySdk sdk = initOpenTracing();
+
+ public static OpenTelemetrySdk initOpenTracing() {
+ try {
+ InputStream input = OpenTracingBrokerPlugin.class.getClassLoader().getResourceAsStream("tracing.properties");
+ if (input == null) {
+ throw new NullPointerException("Unable to find tracing.properties file");
+ }
+ Properties prop = new Properties(System.getProperties());
+ prop.load(input);
+ System.setProperties(prop);
+
+ sdk = AutoConfiguredOpenTelemetrySdk.initialize().getOpenTelemetrySdk();
+
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ return sdk;
+ }
+
+ @Override
+ public void beforeSend(ServerSession session,
+ Transaction tx,
+ Message message,
+ boolean direct,
+ boolean noAutoCreateQueue) throws ActiveMQException {
+ SpanBuilder spanBuilder = GlobalOpenTelemetry.getTracer(OpenTracingBrokerPlugin.class.getName())
+ .spanBuilder(OPERATION_NAME)
+ .setAttribute("message", message.toString())
+ .setSpanKind(SpanKind.SERVER);
+ Span span = spanBuilder.startSpan();
+ threadLocal.set(span);
Review comment:
@franz1981 I thought we can add the ThreadLocal or span instance to the messages itself like `message.putObjectProperty("SpanThread", threadLocal);` But i get an exception:
```
java.lang.ThreadLocal is not a valid property type: org.apache.activemq.artemis.api.core.ActiveMQPropertyConversionException
```
showing that `ThreadLocal` is not accepted as an object.
and then in the afterMethod we get it like` (ThreadLocal) message.getObjectProperty();` and finally get the span
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [activemq-artemis] nbrendah commented on pull request #3895: WIP: Adding Distrubuted support using OpenTelemetry
Posted by GitBox <gi...@apache.org>.
nbrendah commented on pull request #3895:
URL: https://github.com/apache/activemq-artemis/pull/3895#issuecomment-1018253504
am also looking into build failure so i think its something we can not too much make a point for now
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [activemq-artemis] clebertsuconic edited a comment on pull request #3895: WIP: Adding Distrubuted support using OpenTelemetry
Posted by GitBox <gi...@apache.org>.
clebertsuconic edited a comment on pull request #3895:
URL: https://github.com/apache/activemq-artemis/pull/3895#issuecomment-1029043124
I am making this a draft just to avoid merging it by accident.
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [activemq-artemis] nbrendah commented on a change in pull request #3895: WIP: Adding Distrubuted support using OpenTelemetry
Posted by GitBox <gi...@apache.org>.
nbrendah commented on a change in pull request #3895:
URL: https://github.com/apache/activemq-artemis/pull/3895#discussion_r780476828
##########
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [activemq-artemis] nbrendah edited a comment on pull request #3895: WIP: Adding Distrubuted support using OpenTelemetry
Posted by GitBox <gi...@apache.org>.
nbrendah edited a comment on pull request #3895:
URL: https://github.com/apache/activemq-artemis/pull/3895#issuecomment-1010871205
among the tests that i think need to be added, are tests to verify that all exporters are working fine. if a user changes from the default, it must work fine
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [activemq-artemis] nbrendah commented on a change in pull request #3895: WIP: Adding Distrubuted support using OpenTelemetry
Posted by GitBox <gi...@apache.org>.
nbrendah commented on a change in pull request #3895:
URL: https://github.com/apache/activemq-artemis/pull/3895#discussion_r789117896
##########
File path: examples/features/standard/broker-plugin/src/test/java/org/apache/activemq/artemis/jms/example/OpenTracingBrokerPluginTest.java
##########
@@ -18,51 +18,46 @@
import java.util.List;
+import io.opentelemetry.api.GlobalOpenTelemetry;
import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.sdk.testing.exporter.InMemorySpanExporter;
import io.opentelemetry.sdk.trace.data.SpanData;
+import org.apache.activemq.artemis.api.core.ActiveMQException;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat;
import static org.junit.Assert.assertNotNull;
+@RunWith(MockitoJUnitRunner.class)
public class OpenTracingBrokerPluginTest {
private final InMemorySpanExporter exporter = InMemorySpanExporter.create();
- //private SdkTracerProvider sdkTracerProvider;
- //private Tracer tracer;
- /**
- * @Before public void setUp() {
- * sdkTracerProvider = SdkTracerProvider.builder()
- * .addSpanProcessor(SimpleSpanProcessor.create(exporter))
- * .build();
- * tracer = OpenTelemetrySdk.builder()
- * .setTracerProvider(sdkTracerProvider)
- * .buildAndRegisterGlobal()
- * .getTracer("org.apache.activemq.artemis.jms.example.OpenTracingBrokerPlugin");
- * }
- **/
+ @Mock
+ OpenTracingBrokerPlugin plugin = new OpenTracingBrokerPlugin();
@Test
- public void testSpans() {
+ public void assertInitOpenTracing() {
Review comment:
@franz1981 running this test shows me and error
```
Failed to read or configure the org.jboss.logmanager.LogManager
java.lang.NoClassDefFoundError: org/apache/activemq/artemis/shaded/org/jboss/logmanager/ExtHandler
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:800)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:698)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:621)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:579)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:398)
at org.jboss.logmanager.config.AbstractPropertyConfiguration.<init>(AbstractPropertyConfiguration.java:72)
at org.jboss.logmanager.config.HandlerConfigurationImpl.<init>(HandlerConfigurationImpl.java:51)
at org.jboss.logmanager.config.LogContextConfigurationImpl.addHandlerConfiguration(LogContextConfigurationImpl.java:143)
at org.jboss.logmanager.PropertyConfigurator.configureHandler(PropertyConfigurator.java:673)
at org.jboss.logmanager.PropertyConfigurator.configureLogger(PropertyConfigurator.java:583)
at org.jboss.logmanager.PropertyConfigurator.configure(PropertyConfigurator.java:521)
at org.jboss.logmanager.PropertyConfigurator.configure(PropertyConfigurator.java:97)
at org.jboss.logmanager.LogManager.readConfiguration(LogManager.java:170)
at org.jboss.logmanager.LogManager.readConfiguration(LogManager.java:132)
at java.logging/java.util.logging.LogManager.readPrimordialConfiguration(LogManager.java:445)
at java.logging/java.util.logging.LogManager$2.run(LogManager.java:394)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.logging/java.util.logging.LogManager.ensureLogManagerInitialized(LogManager.java:382)
at java.logging/java.util.logging.LogManager.getLogManager(LogManager.java:430)
at java.logging/java.util.logging.Logger.demandLogger(Logger.java:648)
at java.logging/java.util.logging.Logger.getLogger(Logger.java:717)
at java.logging/java.util.logging.Logger.getLogger(Logger.java:701)
at io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdkBuilder.<clinit>(AutoConfiguredOpenTelemetrySdkBuilder.java:43)
at io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdk.builder(AutoConfiguredOpenTelemetrySdk.java:37)
at io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdk.initialize(AutoConfiguredOpenTelemetrySdk.java:29)
at org.apache.activemq.artemis.jms.example.OpenTracingBrokerPlugin.initOpenTracing(OpenTracingBrokerPlugin.java:50)
at org.apache.activemq.artemis.jms.example.OpenTracingBrokerPlugin.<clinit>(OpenTracingBrokerPlugin.java:37)
at org.apache.activemq.artemis.jms.example.OpenTracingBrokerPluginTest.<init>(OpenTracingBrokerPluginTest.java:39)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:250)
at org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:260)
at org.junit.runners.BlockJUnit4ClassRunner$2.runReflectiveCall(BlockJUnit4ClassRunner.java:309)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:306)
at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)
Caused by: java.lang.ClassNotFoundException: org.apache.activemq.artemis.shaded.org.jboss.logmanager.ExtHandler
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 61 more
Process finished with exit code 0
```
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [activemq-artemis] nbrendah commented on a change in pull request #3895: WIP: Adding Distrubuted support using OpenTelemetry
Posted by GitBox <gi...@apache.org>.
nbrendah commented on a change in pull request #3895:
URL: https://github.com/apache/activemq-artemis/pull/3895#discussion_r790434947
##########
File path: examples/features/standard/broker-plugin/src/main/java/org/apache/activemq/artemis/jms/example/OpenTracingBrokerPlugin.java
##########
@@ -0,0 +1,94 @@
+/*
+ * 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 java.io.InputStream;
+import java.util.Properties;
+
+import io.opentelemetry.api.GlobalOpenTelemetry;
+import io.opentelemetry.api.trace.Span;
+import io.opentelemetry.api.trace.SpanBuilder;
+import io.opentelemetry.api.trace.SpanKind;
+import io.opentelemetry.api.trace.StatusCode;
+import io.opentelemetry.api.trace.Tracer;
+import io.opentelemetry.sdk.OpenTelemetrySdk;
+import io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdk;
+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 static final ThreadLocal<Span> threadLocal = new ThreadLocal();
+ private static final String OPERATION_NAME = "/TracingPlugin/";
+ private static OpenTelemetrySdk sdk = initOpenTracing();
+ private static final Tracer TRACER = GlobalOpenTelemetry.getTracer(OpenTracingBrokerPlugin.class.getName());
+
+ public static OpenTelemetrySdk initOpenTracing() {
+ try {
+ InputStream input = OpenTracingBrokerPlugin.class.getClassLoader().getResourceAsStream("tracing.properties");
+ if (input == null) {
+ throw new NullPointerException("Unable to find tracing.properties file");
+ }
+ Properties prop = new Properties(System.getProperties());
+ prop.load(input);
+ System.setProperties(prop);
+
+ sdk = AutoConfiguredOpenTelemetrySdk.initialize().getOpenTelemetrySdk();
+
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ return sdk;
+ }
+
+ @Override
+ public void beforeSend(ServerSession session,
+ Transaction tx,
+ Message message,
+ boolean direct,
+ boolean noAutoCreateQueue) throws ActiveMQException {
+ SpanBuilder spanBuilder = TRACER.spanBuilder(OPERATION_NAME).setAttribute("message", message.toString()).setSpanKind(SpanKind.SERVER);
+ Span span = spanBuilder.startSpan();
+ threadLocal.set(span);
+ }
+
+ @Override
+ public void afterSend(Transaction tx,
+ Message message,
+ boolean direct,
+ boolean noAutoCreateQueue,
+ RoutingStatus result) throws ActiveMQException {
+ Span span = threadLocal.get();
+ span.end();
+ threadLocal.remove();
+ }
+
+ @Override
+ public void onSendException(ServerSession session,
+ Transaction tx,
+ Message message,
+ boolean direct,
+ boolean noAutoCreateQueue,
+ Exception e) throws ActiveMQException {
+ threadLocal.get().setStatus(StatusCode.ERROR).recordException(e);
+ threadLocal.remove();
Review comment:
@franz1981 does this guarantee that the object is gonna be removed in case of any exception?
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [activemq-artemis] nbrendah commented on a change in pull request #3895: WIP: Adding Distrubuted support using OpenTelemetry
Posted by GitBox <gi...@apache.org>.
nbrendah commented on a change in pull request #3895:
URL: https://github.com/apache/activemq-artemis/pull/3895#discussion_r790435755
##########
File path: examples/features/standard/broker-plugin/src/test/java/org/apache/activemq/artemis/jms/example/OpenTracingBrokerPluginTest.java
##########
@@ -18,51 +18,46 @@
import java.util.List;
+import io.opentelemetry.api.GlobalOpenTelemetry;
import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.sdk.testing.exporter.InMemorySpanExporter;
import io.opentelemetry.sdk.trace.data.SpanData;
+import org.apache.activemq.artemis.api.core.ActiveMQException;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat;
import static org.junit.Assert.assertNotNull;
+@RunWith(MockitoJUnitRunner.class)
public class OpenTracingBrokerPluginTest {
private final InMemorySpanExporter exporter = InMemorySpanExporter.create();
- //private SdkTracerProvider sdkTracerProvider;
- //private Tracer tracer;
- /**
- * @Before public void setUp() {
- * sdkTracerProvider = SdkTracerProvider.builder()
- * .addSpanProcessor(SimpleSpanProcessor.create(exporter))
- * .build();
- * tracer = OpenTelemetrySdk.builder()
- * .setTracerProvider(sdkTracerProvider)
- * .buildAndRegisterGlobal()
- * .getTracer("org.apache.activemq.artemis.jms.example.OpenTracingBrokerPlugin");
- * }
- **/
+ @Mock
+ OpenTracingBrokerPlugin plugin = new OpenTracingBrokerPlugin();
@Test
- public void testSpans() {
+ public void assertInitOpenTracing() {
Review comment:
@franz1981 I have made some changes in the test logic but the error i shared above is blocking still blocking me.
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [activemq-artemis] nbrendah commented on a change in pull request #3895: WIP: Adding Distrubuted support using OpenTelemetry
Posted by GitBox <gi...@apache.org>.
nbrendah commented on a change in pull request #3895:
URL: https://github.com/apache/activemq-artemis/pull/3895#discussion_r789416929
##########
File path: examples/features/standard/broker-plugin/src/test/java/org/apache/activemq/artemis/jms/example/OpenTracingBrokerPluginTest.java
##########
@@ -18,51 +18,46 @@
import java.util.List;
+import io.opentelemetry.api.GlobalOpenTelemetry;
import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.sdk.testing.exporter.InMemorySpanExporter;
import io.opentelemetry.sdk.trace.data.SpanData;
+import org.apache.activemq.artemis.api.core.ActiveMQException;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat;
import static org.junit.Assert.assertNotNull;
+@RunWith(MockitoJUnitRunner.class)
public class OpenTracingBrokerPluginTest {
private final InMemorySpanExporter exporter = InMemorySpanExporter.create();
- //private SdkTracerProvider sdkTracerProvider;
- //private Tracer tracer;
- /**
- * @Before public void setUp() {
- * sdkTracerProvider = SdkTracerProvider.builder()
- * .addSpanProcessor(SimpleSpanProcessor.create(exporter))
- * .build();
- * tracer = OpenTelemetrySdk.builder()
- * .setTracerProvider(sdkTracerProvider)
- * .buildAndRegisterGlobal()
- * .getTracer("org.apache.activemq.artemis.jms.example.OpenTracingBrokerPlugin");
- * }
- **/
+ @Mock
+ OpenTracingBrokerPlugin plugin = new OpenTracingBrokerPlugin();
@Test
- public void testSpans() {
+ public void assertInitOpenTracing() {
Review comment:
i still face the same error and am trying to solve it.
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [activemq-artemis] nbrendah commented on a change in pull request #3895: WIP: Adding Distrubuted support using OpenTelemetry
Posted by GitBox <gi...@apache.org>.
nbrendah commented on a change in pull request #3895:
URL: https://github.com/apache/activemq-artemis/pull/3895#discussion_r780476828
##########
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [activemq-artemis] nbrendah commented on a change in pull request #3895: WIP: Adding Distrubuted support using OpenTelemetry
Posted by GitBox <gi...@apache.org>.
nbrendah commented on a change in pull request #3895:
URL: https://github.com/apache/activemq-artemis/pull/3895#discussion_r782909560
##########
File path: examples/features/standard/broker-plugin/src/main/java/org/apache/activemq/artemis/jms/example/OpenTracingBrokerPlugin.java
##########
@@ -0,0 +1,68 @@
+/*
+ * 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.trace.Span;
+import io.opentelemetry.api.trace.SpanKind;
+import io.opentelemetry.api.trace.Tracer;
+import io.opentelemetry.api.trace.TracerProvider;
+import io.opentelemetry.sdk.OpenTelemetrySdk;
+import io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdk;
+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 static Tracer tracer = initOpenTracing();
+ private Span span;
+
+ public static Tracer initOpenTracing() {
+ try {
Review comment:
this is where we can pass the properties. I think we can create a properties file and comment most configurations. Leave everything to default.
A user will comment the properties he/she needs to use.
@clebertsuconic @michaelandrepearce How does activemq-artemis handle its properties configuration. What i mean is that do you have thing like a universal properties loader or anything like that??
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [activemq-artemis] clebertsuconic commented on a change in pull request #3895: WIP: Adding Distrubuted support using OpenTelemetry
Posted by GitBox <gi...@apache.org>.
clebertsuconic commented on a change in pull request #3895:
URL: https://github.com/apache/activemq-artemis/pull/3895#discussion_r780342356
##########
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:
@nbrendah I think we are in a good place to start packaging and testing this properly... we should be on a call..
There's one issue I see is that you always set a property called "count"... of course that would not work... we need to establish what property we are going to send.
and I believe the span would need a Thread Local?
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [activemq-artemis] nbrendah commented on pull request #3895: WIP: Adding Distrubuted support using OpenTelemetry
Posted by GitBox <gi...@apache.org>.
nbrendah commented on pull request #3895:
URL: https://github.com/apache/activemq-artemis/pull/3895#issuecomment-1010871205
among the tests that i think need to be added, we need to tests that all exporters are working fine. if a user changes from the default, it must work fine
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [activemq-artemis] nbrendah commented on a change in pull request #3895: WIP: Adding Distrubuted support using OpenTelemetry
Posted by GitBox <gi...@apache.org>.
nbrendah commented on a change in pull request #3895:
URL: https://github.com/apache/activemq-artemis/pull/3895#discussion_r782906037
##########
File path: examples/features/standard/broker-plugin/src/test/java/org/apache/activemq/artemis/jms/example/OpenTracingBrokerPluginTest.java
##########
@@ -0,0 +1,68 @@
+/*
+ * 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 java.util.List;
+
+import io.opentelemetry.api.trace.SpanKind;
+import io.opentelemetry.sdk.testing.exporter.InMemorySpanExporter;
+import io.opentelemetry.sdk.trace.data.SpanData;
+import org.junit.Test;
+
+import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat;
+import static org.junit.Assert.assertNotNull;
+
+public class OpenTracingBrokerPluginTest {
+
+ private final InMemorySpanExporter exporter = InMemorySpanExporter.create();
+ //private SdkTracerProvider sdkTracerProvider;
+ //private Tracer tracer;
+
+ /**
+ * @Before public void setUp() {
Review comment:
please ignore these commented code for now, i am still trying out things with them
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [activemq-artemis] nbrendah commented on a change in pull request #3895: WIP: Adding Distrubuted support using OpenTelemetry
Posted by GitBox <gi...@apache.org>.
nbrendah commented on a change in pull request #3895:
URL: https://github.com/apache/activemq-artemis/pull/3895#discussion_r783821038
##########
File path: examples/features/standard/broker-plugin/src/main/java/org/apache/activemq/artemis/jms/example/OpenTracingBrokerPlugin.java
##########
@@ -0,0 +1,79 @@
+/*
+ * 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 java.io.InputStream;
+import java.util.Properties;
+
+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.sdk.OpenTelemetrySdk;
+import io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdk;
+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 static Tracer tracer = initOpenTracing();
+ private Span span;
+
+ public static Tracer initOpenTracing() {
+ try {
+ InputStream input = OpenTracingBrokerPlugin.class.getClassLoader().getResourceAsStream("tracing.properties");
+ if (input == null) {
+ throw new NullPointerException("Unable to find tracing.properties file");
+ }
+ Properties prop = new Properties(System.getProperties());
+ prop.load(input);
+ System.setProperties(prop);
Review comment:
@clebertsuconic
This is how i have added the `.properties ` which will contain all opentelemetry configurations and customization
we can specify which exporter to use and its corresponding host and port.
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [activemq-artemis] franz1981 commented on a change in pull request #3895: WIP: Adding Distrubuted support using OpenTelemetry
Posted by GitBox <gi...@apache.org>.
franz1981 commented on a change in pull request #3895:
URL: https://github.com/apache/activemq-artemis/pull/3895#discussion_r789479101
##########
File path: examples/features/standard/broker-plugin/src/main/java/org/apache/activemq/artemis/jms/example/OpenTracingBrokerPlugin.java
##########
@@ -0,0 +1,90 @@
+/*
+ * 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 java.io.InputStream;
+import java.util.Properties;
+
+import io.opentelemetry.api.GlobalOpenTelemetry;
+import io.opentelemetry.api.trace.Span;
+import io.opentelemetry.api.trace.SpanBuilder;
+import io.opentelemetry.api.trace.SpanKind;
+import io.opentelemetry.api.trace.Tracer;
+import io.opentelemetry.api.trace.TracerProvider;
+import io.opentelemetry.sdk.OpenTelemetrySdk;
+import io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdk;
+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 ThreadLocal threadLocal = new ThreadLocal();
+ private static final String OPERATION_NAME = "/TracingPlugin/rootInvoke/";
+ private static OpenTelemetrySdk sdk = initOpenTracing();
+
+ public static OpenTelemetrySdk initOpenTracing() {
+ try {
+ InputStream input = OpenTracingBrokerPlugin.class.getClassLoader().getResourceAsStream("tracing.properties");
+ if (input == null) {
+ throw new NullPointerException("Unable to find tracing.properties file");
+ }
+ Properties prop = new Properties(System.getProperties());
+ prop.load(input);
+ System.setProperties(prop);
+
+ sdk = AutoConfiguredOpenTelemetrySdk.initialize().getOpenTelemetrySdk();
+
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ return sdk;
+ }
+
+ @Override
+ public void beforeSend(ServerSession session,
+ Transaction tx,
+ Message message,
+ boolean direct,
+ boolean noAutoCreateQueue) throws ActiveMQException {
+ SpanBuilder spanBuilder = GlobalOpenTelemetry.getTracer(OpenTracingBrokerPlugin.class.getName())
Review comment:
```suggestion
SpanBuilder spanBuilder = TRACER
```
`GlobalOpenTelemetry.getTracer(OpenTracingBrokerPlugin.class.getName())` can be declared in the plugin as
```java
private static final Tracer TRACER = GlobalOpenTelemetry.getTracer(OpenTracingBrokerPlugin.class.getName());
```
##########
File path: examples/features/standard/broker-plugin/src/main/java/org/apache/activemq/artemis/jms/example/OpenTracingBrokerPlugin.java
##########
@@ -0,0 +1,90 @@
+/*
+ * 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 java.io.InputStream;
+import java.util.Properties;
+
+import io.opentelemetry.api.GlobalOpenTelemetry;
+import io.opentelemetry.api.trace.Span;
+import io.opentelemetry.api.trace.SpanBuilder;
+import io.opentelemetry.api.trace.SpanKind;
+import io.opentelemetry.api.trace.Tracer;
+import io.opentelemetry.api.trace.TracerProvider;
+import io.opentelemetry.sdk.OpenTelemetrySdk;
+import io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdk;
+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 ThreadLocal threadLocal = new ThreadLocal();
+ private static final String OPERATION_NAME = "/TracingPlugin/rootInvoke/";
+ private static OpenTelemetrySdk sdk = initOpenTracing();
+
+ public static OpenTelemetrySdk initOpenTracing() {
+ try {
+ InputStream input = OpenTracingBrokerPlugin.class.getClassLoader().getResourceAsStream("tracing.properties");
+ if (input == null) {
+ throw new NullPointerException("Unable to find tracing.properties file");
+ }
+ Properties prop = new Properties(System.getProperties());
+ prop.load(input);
+ System.setProperties(prop);
+
+ sdk = AutoConfiguredOpenTelemetrySdk.initialize().getOpenTelemetrySdk();
+
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ return sdk;
+ }
+
+ @Override
+ public void beforeSend(ServerSession session,
+ Transaction tx,
+ Message message,
+ boolean direct,
+ boolean noAutoCreateQueue) throws ActiveMQException {
+ SpanBuilder spanBuilder = GlobalOpenTelemetry.getTracer(OpenTracingBrokerPlugin.class.getName())
+ .spanBuilder(OPERATION_NAME)
+ .setAttribute("message", message.toString())
+ .setSpanKind(SpanKind.SERVER);
+ Span span = spanBuilder.startSpan();
+ threadLocal.set(span);
+
+ /**
+ 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,
Review comment:
I suggest to override `public void onSendException` as well or we risk to leak `Span` in case of exceptions
##########
File path: examples/features/standard/broker-plugin/src/main/java/org/apache/activemq/artemis/jms/example/OpenTracingBrokerPlugin.java
##########
@@ -0,0 +1,90 @@
+/*
+ * 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 java.io.InputStream;
+import java.util.Properties;
+
+import io.opentelemetry.api.GlobalOpenTelemetry;
+import io.opentelemetry.api.trace.Span;
+import io.opentelemetry.api.trace.SpanBuilder;
+import io.opentelemetry.api.trace.SpanKind;
+import io.opentelemetry.api.trace.Tracer;
+import io.opentelemetry.api.trace.TracerProvider;
+import io.opentelemetry.sdk.OpenTelemetrySdk;
+import io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdk;
+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 ThreadLocal threadLocal = new ThreadLocal();
Review comment:
I think we have several options here:
- `ThreadLocal` must be declared as `private static final ThreadLocal` to benefit from important optimizations by the JVM
- `ThreadLocal::remove` can be quite expensive and subsequent `ThreadLocal::set` would create new `ThreadLocalMap::Entry`: saving a leak to happen seems important, but I would search a different way to solve this problem
For the latter @clebertsuconic maybe we can change the plugin API in order to bring context `Object` all around a-la C language (with function pointers)
eg
```java
default Object beforeSend(ServerSession session, Transaction tx, Message message, boolean direct, boolean noAutoCreateQueue, Object context) throws ActiveMQException {
this.beforeSend(session, tx, message, direct, noAutoCreateQueue);
return context;
}
default void afterSend(ServerSession session, Transaction tx, Message message, boolean direct, boolean noAutoCreateQueue, RoutingStatus result, Object context) throws ActiveMQException {
this.afterSend(tx, message, direct, noAutoCreateQueue, result);
}
default void onSendException(ServerSession session, Transaction tx, Message message, boolean direct, boolean noAutoCreateQueue, Exception e, Object context) throws ActiveMQException {
this.onSendException(session, tx, message, direct, noAutoCreateQueue, e);
}
```
This would allows using the `Span` as the `context` (ie state) to be propagated around without needing any extra map/thread local/....
##########
File path: examples/features/standard/broker-plugin/src/main/java/org/apache/activemq/artemis/jms/example/OpenTracingBrokerPlugin.java
##########
@@ -0,0 +1,90 @@
+/*
+ * 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 java.io.InputStream;
+import java.util.Properties;
+
+import io.opentelemetry.api.GlobalOpenTelemetry;
+import io.opentelemetry.api.trace.Span;
+import io.opentelemetry.api.trace.SpanBuilder;
+import io.opentelemetry.api.trace.SpanKind;
+import io.opentelemetry.api.trace.Tracer;
+import io.opentelemetry.api.trace.TracerProvider;
+import io.opentelemetry.sdk.OpenTelemetrySdk;
+import io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdk;
+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 ThreadLocal threadLocal = new ThreadLocal();
+ private static final String OPERATION_NAME = "/TracingPlugin/rootInvoke/";
+ private static OpenTelemetrySdk sdk = initOpenTracing();
+
+ public static OpenTelemetrySdk initOpenTracing() {
+ try {
+ InputStream input = OpenTracingBrokerPlugin.class.getClassLoader().getResourceAsStream("tracing.properties");
+ if (input == null) {
+ throw new NullPointerException("Unable to find tracing.properties file");
+ }
+ Properties prop = new Properties(System.getProperties());
+ prop.load(input);
+ System.setProperties(prop);
+
+ sdk = AutoConfiguredOpenTelemetrySdk.initialize().getOpenTelemetrySdk();
+
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ return sdk;
+ }
+
+ @Override
+ public void beforeSend(ServerSession session,
+ Transaction tx,
+ Message message,
+ boolean direct,
+ boolean noAutoCreateQueue) throws ActiveMQException {
+ SpanBuilder spanBuilder = GlobalOpenTelemetry.getTracer(OpenTracingBrokerPlugin.class.getName())
+ .spanBuilder(OPERATION_NAME)
+ .setAttribute("message", message.toString())
+ .setSpanKind(SpanKind.SERVER);
+ Span span = spanBuilder.startSpan();
+ threadLocal.set(span);
Review comment:
This is correct, because messages are not supposed to contain things that cannot be encoded and sent to client(s), and `ThreadLocal` although temporary isn't an object instance that we wish to send to client(s).
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org