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

com.yammer.telemetry.tracing.SpanSinkRegistry Maven / Gradle / Ivy

The newest version!
package com.yammer.telemetry.tracing;

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 - 2024 Weber Informatics LLC | Privacy Policy