
net.wicp.tams.commons.tracer.SpanSinkRegistry Maven / Gradle / Ivy
package net.wicp.tams.commons.tracer;
import com.google.common.collect.ImmutableList;
import java.util.concurrent.atomic.AtomicReference;
public class SpanSinkRegistry {
private static AtomicReference> spanSinks = new AtomicReference<>(ImmutableList.of());
public static void register(SpanSink sink) {
final ImmutableList oldSinks = spanSinks.get();
final ImmutableList newSinks = new ImmutableList.Builder().addAll(oldSinks).add(sink).build();
if (!spanSinks.compareAndSet(oldSinks, newSinks)) {
throw new RuntimeException("Failed to add new SpanSink, concurrent add");
}
}
public static Iterable getSpanSinks() {
return spanSinks.get();
}
public static void clear() {
spanSinks.set(ImmutableList.of());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy