All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.kristofa.brave.BraveCallable Maven / Gradle / Ivy

There is a newer version: 4.13.6
Show newest version
package com.github.kristofa.brave;

import java.util.concurrent.Callable;

import com.github.kristofa.brave.internal.Nullable;
import com.google.auto.value.AutoValue;

/**
 * Callable implementation that wraps another Callable and makes sure the wrapped Callable will be executed in the same
 * Span/Trace context as the thread from which the Callable was executed.
 * 

* Is used by {@link BraveExecutorService}. * * @author kristof * @param Return type. * @see BraveExecutorService */ @AutoValue public abstract class BraveCallable implements Callable { /** * Creates a new instance. * * @param wrappedCallable The wrapped Callable. * @param serverSpanThreadBinder ServerSpan thread binder. */ public static BraveCallable create(Callable wrappedCallable, ServerSpanThreadBinder serverSpanThreadBinder) { return new AutoValue_BraveCallable(wrappedCallable, serverSpanThreadBinder, serverSpanThreadBinder.getCurrentServerSpan()); } abstract Callable wrappedCallable(); abstract ServerSpanThreadBinder serverSpanThreadBinder(); @Nullable abstract ServerSpan currentServerSpan(); /** * {@inheritDoc} */ @Override public T call() throws Exception { serverSpanThreadBinder().setCurrentSpan(currentServerSpan()); return wrappedCallable().call(); } BraveCallable() { } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy