davsclaus commented on a change in pull request #3919: URL: https://github.com/apache/camel/pull/3919#discussion_r440629173
########## File path: components/camel-opentracing/src/main/java/org/apache/camel/opentracing/TagProcessor.java ########## @@ -0,0 +1,102 @@ +package org.apache.camel.opentracing; + +import io.opentracing.Span; +import org.apache.camel.AsyncCallback; +import org.apache.camel.Exchange; +import org.apache.camel.Expression; +import org.apache.camel.Traceable; +import org.apache.camel.spi.IdAware; +import org.apache.camel.spi.RouteIdAware; +import org.apache.camel.support.AsyncProcessorSupport; +import org.apache.camel.util.ObjectHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * A processor which adds a tag on the active {@link io.opentracing.Span} with an {@link org.apache.camel.Expression} + */ +public class TagProcessor extends AsyncProcessorSupport implements Traceable, IdAware, RouteIdAware { + + private static final Logger LOG = LoggerFactory.getLogger(TagProcessor.class); + + private String id; + private String routeId; + private final Expression tagName; + private final Expression expression; + + public TagProcessor(Expression tagName, Expression expression) { + this.tagName = tagName; + this.expression = expression; + ObjectHelper.notNull(tagName, "headerName"); + ObjectHelper.notNull(expression, "expression"); + } + + @Override + public boolean process(Exchange exchange, AsyncCallback callback) { + try { + Span span = ActiveSpanManager.getSpan(exchange); + if (span != null) { + String key = tagName.evaluate(exchange, String.class); + String tag = expression.evaluate(exchange, String.class); Review comment: Maybe those expressions could be return null / empty key so the span tag is not set. This allows to only return keys when you want to set the tag. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org