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

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 127ccc6369a camel-opentelemetry: polished
127ccc6369a is described below

commit 127ccc6369a91321d5867993417ae99da22c9852
Author: Claus Ibsen <claus.ib...@gmail.com>
AuthorDate: Mon Jun 17 21:13:42 2024 +0200

    camel-opentelemetry: polished
---
 .../src/main/docs/opentelemetry.adoc               |  4 ++--
 .../camel/opentelemetry/AttributeProcessor.java    |  3 ++-
 .../GetCorrelationContextProcessor.java            | 14 +++----------
 .../opentelemetry/OpenTelemetrySpanAdapter.java    | 23 +++++++++++-----------
 .../OpenTelemetryTracingStrategy.java              |  4 +---
 5 files changed, 20 insertions(+), 28 deletions(-)

diff --git a/components/camel-opentelemetry/src/main/docs/opentelemetry.adoc 
b/components/camel-opentelemetry/src/main/docs/opentelemetry.adoc
index 30d8fd322de..078e69672c6 100644
--- a/components/camel-opentelemetry/src/main/docs/opentelemetry.adoc
+++ b/components/camel-opentelemetry/src/main/docs/opentelemetry.adoc
@@ -55,7 +55,7 @@ otelTracer.init(camelContext);
 
 NOTE: You would still need OpenTelemetry to instrument your code, which can be 
done via a <<OpenTelemetry-JavaAgent,Java agent>>.
 
-=== Using it with standalone Camel
+=== Using with standalone Camel
 
 If you use `camel-main` as standalone Camel, then you can enable and use 
OpenTelemetry without Java code.
 
@@ -84,7 +84,7 @@ a `OpenTelemetryTracer` bean has been defined by the 
application.
 
 Download the 
https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/[latest
 version].
 
-This package includes the instrumentation agent as well as instrumentations 
for all supported libraries and all available data exporters.
+This package includes the instrumentation agent as well as instrumentation's 
for all supported libraries and all available data exporters.
 The package provides a completely automatic, out-of-the-box experience.
 
 Enable the instrumentation agent using the `-javaagent` flag to the JVM.
diff --git 
a/components/camel-opentelemetry/src/main/java/org/apache/camel/opentelemetry/AttributeProcessor.java
 
b/components/camel-opentelemetry/src/main/java/org/apache/camel/opentelemetry/AttributeProcessor.java
index 61d81726941..2280afd0bb6 100644
--- 
a/components/camel-opentelemetry/src/main/java/org/apache/camel/opentelemetry/AttributeProcessor.java
+++ 
b/components/camel-opentelemetry/src/main/java/org/apache/camel/opentelemetry/AttributeProcessor.java
@@ -36,6 +36,7 @@ import org.slf4j.LoggerFactory;
 public class AttributeProcessor extends AsyncProcessorSupport implements 
Traceable, IdAware, RouteIdAware {
 
     private static final Logger LOG = 
LoggerFactory.getLogger(AttributeProcessor.class);
+
     private final String attributeName;
     private final Expression expression;
     private String id;
@@ -55,7 +56,7 @@ public class AttributeProcessor extends AsyncProcessorSupport 
implements Traceab
                 String tag = expression.evaluate(exchange, String.class);
                 span.setAttribute(attributeName, tag);
             } else {
-                LOG.warn("OpenTelemetry: could not find managed span for 
exchange={}", exchange);
+                LOG.warn("OpenTelemetry: Cannot find managed span for 
exchange: {}", exchange);
             }
         } catch (Exception e) {
             exchange.setException(e);
diff --git 
a/components/camel-opentelemetry/src/main/java/org/apache/camel/opentelemetry/GetCorrelationContextProcessor.java
 
b/components/camel-opentelemetry/src/main/java/org/apache/camel/opentelemetry/GetCorrelationContextProcessor.java
index 7b82aa52b1a..bafff4b7b0c 100644
--- 
a/components/camel-opentelemetry/src/main/java/org/apache/camel/opentelemetry/GetCorrelationContextProcessor.java
+++ 
b/components/camel-opentelemetry/src/main/java/org/apache/camel/opentelemetry/GetCorrelationContextProcessor.java
@@ -28,7 +28,9 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class GetCorrelationContextProcessor extends AsyncProcessorSupport 
implements Traceable, IdAware, RouteIdAware {
+
     private static final Logger LOG = 
LoggerFactory.getLogger(GetCorrelationContextProcessor.class);
+
     private final String headerName;
     private final String keyName;
     private String id;
@@ -47,7 +49,7 @@ public class GetCorrelationContextProcessor extends 
AsyncProcessorSupport implem
                 String item = camelSpan.getContextPropagationItem(keyName);
                 exchange.getMessage().setHeader(headerName, item);
             } else {
-                LOG.warn("OpenTelemetry: could not find managed span for 
exchange={}", exchange);
+                LOG.warn("OpenTelemetry: Cannot find managed span for 
exchange: {}", exchange);
             }
         } catch (Exception e) {
             exchange.setException(e);
@@ -92,16 +94,6 @@ public class GetCorrelationContextProcessor extends 
AsyncProcessorSupport implem
         return headerName;
     }
 
-    @Override
-    protected void doStart() throws Exception {
-        // noop
-    }
-
-    @Override
-    protected void doStop() throws Exception {
-        // noop
-    }
-
     @Override
     public String toString() {
         return id;
diff --git 
a/components/camel-opentelemetry/src/main/java/org/apache/camel/opentelemetry/OpenTelemetrySpanAdapter.java
 
b/components/camel-opentelemetry/src/main/java/org/apache/camel/opentelemetry/OpenTelemetrySpanAdapter.java
index 16620ed785d..5c49f0bedd5 100644
--- 
a/components/camel-opentelemetry/src/main/java/org/apache/camel/opentelemetry/OpenTelemetrySpanAdapter.java
+++ 
b/components/camel-opentelemetry/src/main/java/org/apache/camel/opentelemetry/OpenTelemetrySpanAdapter.java
@@ -28,18 +28,19 @@ import org.apache.camel.tracing.SpanAdapter;
 import org.apache.camel.tracing.Tag;
 
 public class OpenTelemetrySpanAdapter implements SpanAdapter {
+
     private static final String DEFAULT_EVENT_NAME = "log";
-    private static Map<Tag, String> tagMap = new EnumMap<>(Tag.class);
+    private static final Map<Tag, String> TAG_MAP = new EnumMap<>(Tag.class);
 
     static {
-        tagMap.put(Tag.COMPONENT, "component");
-        tagMap.put(Tag.DB_TYPE, SemanticAttributes.DB_SYSTEM.getKey());
-        tagMap.put(Tag.DB_STATEMENT, SemanticAttributes.DB_STATEMENT.getKey());
-        tagMap.put(Tag.DB_INSTANCE, SemanticAttributes.DB_NAME.getKey());
-        tagMap.put(Tag.HTTP_METHOD, SemanticAttributes.HTTP_METHOD.getKey());
-        tagMap.put(Tag.HTTP_STATUS, 
SemanticAttributes.HTTP_STATUS_CODE.getKey());
-        tagMap.put(Tag.HTTP_URL, SemanticAttributes.HTTP_URL.getKey());
-        tagMap.put(Tag.MESSAGE_BUS_DESTINATION, "message_bus.destination");
+        TAG_MAP.put(Tag.COMPONENT, "component");
+        TAG_MAP.put(Tag.DB_TYPE, SemanticAttributes.DB_SYSTEM.getKey());
+        TAG_MAP.put(Tag.DB_STATEMENT, 
SemanticAttributes.DB_STATEMENT.getKey());
+        TAG_MAP.put(Tag.DB_INSTANCE, SemanticAttributes.DB_NAME.getKey());
+        TAG_MAP.put(Tag.HTTP_METHOD, SemanticAttributes.HTTP_METHOD.getKey());
+        TAG_MAP.put(Tag.HTTP_STATUS, 
SemanticAttributes.HTTP_STATUS_CODE.getKey());
+        TAG_MAP.put(Tag.HTTP_URL, SemanticAttributes.HTTP_URL.getKey());
+        TAG_MAP.put(Tag.MESSAGE_BUS_DESTINATION, "message_bus.destination");
     }
 
     private Baggage baggage;
@@ -70,7 +71,7 @@ public class OpenTelemetrySpanAdapter implements SpanAdapter {
 
     @Override
     public void setTag(Tag key, String value) {
-        String attribute = tagMap.getOrDefault(key, key.getAttribute());
+        String attribute = TAG_MAP.getOrDefault(key, key.getAttribute());
         this.span.setAttribute(attribute, value);
         if (!attribute.equals(key.getAttribute())) {
             this.span.setAttribute(key.getAttribute(), value);
@@ -79,7 +80,7 @@ public class OpenTelemetrySpanAdapter implements SpanAdapter {
 
     @Override
     public void setTag(Tag key, Number value) {
-        this.span.setAttribute(tagMap.getOrDefault(key, key.getAttribute()), 
value.intValue());
+        this.span.setAttribute(TAG_MAP.getOrDefault(key, key.getAttribute()), 
value.intValue());
     }
 
     @Override
diff --git 
a/components/camel-opentelemetry/src/main/java/org/apache/camel/opentelemetry/OpenTelemetryTracingStrategy.java
 
b/components/camel-opentelemetry/src/main/java/org/apache/camel/opentelemetry/OpenTelemetryTracingStrategy.java
index c827ca06c5a..2d7f810e6e1 100644
--- 
a/components/camel-opentelemetry/src/main/java/org/apache/camel/opentelemetry/OpenTelemetryTracingStrategy.java
+++ 
b/components/camel-opentelemetry/src/main/java/org/apache/camel/opentelemetry/OpenTelemetryTracingStrategy.java
@@ -35,7 +35,6 @@ public class OpenTelemetryTracingStrategy implements 
InterceptStrategy {
     private static final String UNNAMED = "unnamed";
 
     private final OpenTelemetryTracer tracer;
-
     private boolean propagateContext;
 
     public OpenTelemetryTracingStrategy(OpenTelemetryTracer tracer) {
@@ -108,13 +107,12 @@ public class OpenTelemetryTracingStrategy implements 
InterceptStrategy {
                 if (activateExchange) {
                     ActiveSpanManager.deactivate(exchange);
                 }
-
                 processorSpan.end();
             }
         }
     }
 
-    private class PropagateContext implements Processor {
+    private static class PropagateContext implements Processor {
         private final Processor target;
 
         public PropagateContext(Processor target) {

Reply via email to