Java Code Examples for brave.Tracer.SpanInScope#close()

The following examples show how to use brave.Tracer.SpanInScope#close() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BraveTracerContext.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Override
public <T> T continueSpan(final Traceable<T> traceable) throws Exception {
    SpanInScope scope = null;
    
    if (tracer.currentSpan() == null && continuationSpan != null) {
        scope = tracer.withSpanInScope(continuationSpan);
    }

    try { //NOPMD
        return traceable.call(new BraveTracerContext(brave));
    } finally {
        if (continuationSpan != null && scope != null) {
            scope.close();
        }
    }
}
 
Example 2
Source File: TracingMessageProducer.java    From brave with Apache License 2.0 6 votes vote down vote up
@Override public void send(Message message) throws JMSException {
  Span span = createAndStartProducerSpan(message, destination(message));
  SpanInScope ws = tracer.withSpanInScope(span);
  Throwable error = null;
  try {
    delegate.send(message);
  } catch (Throwable t) {
    propagateIfFatal(t);
    error = t;
    throw t;
  } finally {
    if (error != null) span.error(error);
    span.finish();
    ws.close();
  }
}
 
Example 3
Source File: TracingMessageProducer.java    From brave with Apache License 2.0 6 votes vote down vote up
@Override public void send(Message message, int deliveryMode, int priority, long timeToLive)
  throws JMSException {
  Span span = createAndStartProducerSpan(message, destination(message));
  SpanInScope ws = tracer.withSpanInScope(span); // animal-sniffer mistakes this for AutoCloseable
  Throwable error = null;
  try {
    delegate.send(message, deliveryMode, priority, timeToLive);
  } catch (Throwable t) {
    propagateIfFatal(t);
    error = t;
    throw t;
  } finally {
    if (error != null) span.error(error);
    span.finish();
    ws.close();
  }
}
 
Example 4
Source File: TracingMessageProducer.java    From brave with Apache License 2.0 6 votes vote down vote up
void send(SendDestination sendDestination, Destination destination, Message message)
  throws JMSException {
  Span span = createAndStartProducerSpan(message, destination);
  SpanInScope ws = tracer.withSpanInScope(span); // animal-sniffer mistakes this for AutoCloseable
  Throwable error = null;
  try {
    sendDestination.apply(delegate, destination, message);
  } catch (Throwable t) {
    propagateIfFatal(t);
    error = t;
    throw t;
  } finally {
    if (error != null) span.error(error);
    span.finish();
    ws.close();
  }
}
 
Example 5
Source File: TracingMessageProducer.java    From brave with Apache License 2.0 6 votes vote down vote up
@Override
public void send(Destination destination, Message message, int deliveryMode, int priority,
  long timeToLive) throws JMSException {
  Span span = createAndStartProducerSpan(message, destination);
  SpanInScope ws = tracer.withSpanInScope(span);
  Throwable error = null;
  try {
    delegate.send(destination, message, deliveryMode, priority, timeToLive);
  } catch (Throwable t) {
    propagateIfFatal(t);
    error = t;
    throw t;
  } finally {
    if (error != null) span.error(error);
    span.finish();
    ws.close();
  }
}
 
Example 6
Source File: TracingMessageProducer.java    From brave with Apache License 2.0 6 votes vote down vote up
@JMS2_0
public void send(Message message, CompletionListener completionListener) throws JMSException {
  Destination destination = destination(message);
  Span span = createAndStartProducerSpan(message, destination);
  SpanInScope ws = tracer.withSpanInScope(span); // animal-sniffer mistakes this for AutoCloseable
  Throwable error = null;
  try {
    delegate.send(message, TracingCompletionListener.create(completionListener, destination, span, current));
  } catch (Throwable t) {
    propagateIfFatal(t);
    error = t;
    throw t;
  } finally {
    if (error != null) span.error(error).finish();
    ws.close();
  }
}
 
Example 7
Source File: TracingMessageProducer.java    From brave with Apache License 2.0 6 votes vote down vote up
@JMS2_0 public void send(Message message, int deliveryMode, int priority, long timeToLive,
  CompletionListener completionListener) throws JMSException {
  Destination destination = destination(message);
  Span span = createAndStartProducerSpan(message, destination);
  completionListener = TracingCompletionListener.create(completionListener, destination, span, current);
  SpanInScope ws = tracer.withSpanInScope(span); // animal-sniffer mistakes this for AutoCloseable
  Throwable error = null;
  try {
    delegate.send(message, deliveryMode, priority, timeToLive, completionListener);
  } catch (Throwable t) {
    propagateIfFatal(t);
    error = t;
    throw t;
  } finally {
    if (error != null) span.error(error).finish();
    ws.close();
  }
}
 
Example 8
Source File: TracingMessageProducer.java    From brave with Apache License 2.0 6 votes vote down vote up
@JMS2_0 public void send(Destination destination, Message message,
  CompletionListener completionListener) throws JMSException {
  Span span = createAndStartProducerSpan(message, destination);
  completionListener = TracingCompletionListener.create(completionListener, destination, span, current);
  SpanInScope ws = tracer.withSpanInScope(span);
  Throwable error = null;
  try {
    delegate.send(destination, message, completionListener);
  } catch (Throwable t) {
    propagateIfFatal(t);
    error = t;
    throw t;
  } finally {
    if (error != null) span.error(error).finish();
    ws.close();
  }
}
 
Example 9
Source File: TracingMessageProducer.java    From brave with Apache License 2.0 6 votes vote down vote up
@JMS2_0 public void send(Destination destination, Message message, int deliveryMode, int priority,
  long timeToLive, CompletionListener completionListener) throws JMSException {
  Span span = createAndStartProducerSpan(message, destination);
  completionListener = TracingCompletionListener.create(completionListener, destination, span, current);
  SpanInScope ws = tracer.withSpanInScope(span);
  Throwable error = null;
  try {
    delegate.send(destination, message, deliveryMode, priority, timeToLive, completionListener);
  } catch (Throwable t) {
    propagateIfFatal(t);
    error = t;
    throw t;
  } finally {
    if (error != null) span.error(error).finish();
    ws.close();
  }
}
 
Example 10
Source File: TracingMessageProducer.java    From brave with Apache License 2.0 6 votes vote down vote up
@Override
public void send(Queue queue, Message message, int deliveryMode, int priority, long timeToLive)
  throws JMSException {
  checkQueueSender();
  QueueSender qs = (QueueSender) delegate;
  Span span = createAndStartProducerSpan(message, destination(message));
  SpanInScope ws = tracer.withSpanInScope(span);
  Throwable error = null;
  try {
    qs.send(queue, message, deliveryMode, priority, timeToLive);
  } catch (Throwable t) {
    propagateIfFatal(t);
    error = t;
    throw t;
  } finally {
    if (error != null) span.error(error);
    span.finish();
    ws.close();
  }
}
 
Example 11
Source File: TracingMessageProducer.java    From brave with Apache License 2.0 6 votes vote down vote up
@Override public void publish(Message message) throws JMSException {
  checkTopicPublisher();
  TopicPublisher tp = (TopicPublisher) delegate;

  Span span = createAndStartProducerSpan(message, destination(message));
  SpanInScope ws = tracer.withSpanInScope(span);
  Throwable error = null;
  try {
    tp.publish(message);
  } catch (Throwable t) {
    propagateIfFatal(t);
    error = t;
    throw t;
  } finally {
    if (error != null) span.error(error);
    span.finish();
    ws.close();
  }
}
 
Example 12
Source File: TracingMessageProducer.java    From brave with Apache License 2.0 6 votes vote down vote up
@Override public void publish(Message message, int deliveryMode, int priority, long timeToLive)
  throws JMSException {
  checkTopicPublisher();
  TopicPublisher tp = (TopicPublisher) delegate;

  Span span = createAndStartProducerSpan(message, destination(message));
  SpanInScope ws = tracer.withSpanInScope(span);
  Throwable error = null;
  try {
    tp.publish(message, deliveryMode, priority, timeToLive);
  } catch (Throwable t) {
    propagateIfFatal(t);
    error = t;
    throw t;
  } finally {
    if (error != null) span.error(error);
    span.finish();
    ws.close();
  }
}
 
Example 13
Source File: TracingMessageProducer.java    From brave with Apache License 2.0 6 votes vote down vote up
@Override
public void publish(Topic topic, Message message, int deliveryMode, int priority, long timeToLive)
  throws JMSException {
  checkTopicPublisher();
  TopicPublisher tp = (TopicPublisher) delegate;

  Span span = createAndStartProducerSpan(message, destination(message));
  SpanInScope ws = tracer.withSpanInScope(span);
  Throwable error = null;
  try {
    tp.publish(topic, message, deliveryMode, priority, timeToLive);
  } catch (Throwable t) {
    propagateIfFatal(t);
    error = t;
    throw t;
  } finally {
    if (error != null) span.error(error);
    span.finish();
    ws.close();
  }
}
 
Example 14
Source File: TracingMessageListener.java    From brave with Apache License 2.0 6 votes vote down vote up
@Override public void onMessage(Message message) {
  Span listenerSpan = startMessageListenerSpan(message);
  SpanInScope ws = tracer.withSpanInScope(listenerSpan);
  Throwable error = null;
  try {
    delegate.onMessage(message);
  } catch (Throwable t) {
    propagateIfFatal(t);
    error = t;
    throw t;
  } finally {
    if (error != null) listenerSpan.error(error);
    listenerSpan.finish();
    ws.close();
  }
}