io.pyroscope.labels.Pyroscope Maven / Gradle / Ivy
package io.pyroscope.labels;
import io.pyroscope.labels.pb.*;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Callable;
public class Pyroscope {
public static class LabelsWrapper {
public static T run(LabelsSet labels, Callable c) throws Exception {
try (ScopedContext s = new ScopedContext(labels)) {
return c.call();
}
}
public static void run(LabelsSet labels, Runnable c) {
try (ScopedContext s = new ScopedContext(labels)) {
c.run();
}
}
public static JfrLabels.Snapshot dump() {
JfrLabels.Snapshot.Builder sb = JfrLabels.Snapshot.newBuilder();
for (Ref it : RefCounted.strings.valueToRef.values()) {
sb.putStrings(it.id, it.val);
}
for (Ref