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: [email protected]

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


Reply via email to