Loading skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/conf/Config.java +1 −1 Original line number Diff line number Diff line Loading @@ -9,7 +9,7 @@ public class Config { public static String PATH = ""; public static int SAMPLING_RATE = 10000; public static int SAMPLING_CYCLE = 1; } public static class Collector{ Loading skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/sampling/SamplingService.java +8 −9 Original line number Diff line number Diff line Loading @@ -12,7 +12,7 @@ import com.a.eye.skywalking.trace.TraceSegment; * have been traced, but, considering CPU cost of serialization/deserialization, and network bandwidth, the agent do NOT * send all of them to collector, if SAMPLING is on. * * By default, SAMPLING is off, and {@link Config.Agent#SAMPLING_RATE} == 1000. * By default, SAMPLING is off, and {@link Config.Agent#SAMPLING_CYCLE} == 1. * * @author wusheng */ Loading @@ -20,26 +20,25 @@ public class SamplingService implements BootService { private static ILog logger = LogManager.getLogger(SamplingService.class); private volatile boolean on = false; private volatile int rate = 0; private volatile int rollingSeed = 1; @Override public void bootUp() throws Throwable { if (Config.Agent.SAMPLING_RATE == 10000) { if (Config.Agent.SAMPLING_CYCLE == 1) { this.on = false; return; } if (Config.Agent.SAMPLING_RATE > 10000 || Config.Agent.SAMPLING_RATE < 1) { throw new IllegalSamplingRateException("sampling rate should stay in (0, 10000]."); if (Config.Agent.SAMPLING_CYCLE < 1) { throw new IllegalSamplingRateException("sampling cycle must greater than 0."); } rate = 10000 / Config.Agent.SAMPLING_RATE; on = true; this.on = true; logger.debug("The trace sampling is on, and the sampling rate is: {}", rate); logger.debug("The trace sampling is on, and the sampling cycle is: {}", Config.Agent.SAMPLING_CYCLE); } public void trySampling(TraceSegment segment) { if (on) { if (rollingSeed % rate != 0) { if (rollingSeed % Config.Agent.SAMPLING_CYCLE != 0) { segment.setSampled(false); } rollingSeed++; Loading skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/api/sampling/SamplingServiceTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -13,7 +13,7 @@ import org.junit.Test; public class SamplingServiceTest { @Test public void test50Percent(){ Config.Agent.SAMPLING_RATE = 5000; Config.Agent.SAMPLING_CYCLE = 2; ServiceManager.INSTANCE.boot(); TraceSegment segment = new TraceSegment(); Loading @@ -30,7 +30,7 @@ public class SamplingServiceTest { @AfterClass public static void clear(){ Config.Agent.SAMPLING_RATE = 10000; Config.Agent.SAMPLING_CYCLE = 1; ServiceManager.INSTANCE.boot(); } } skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/CallableStatementTracing.java +1 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ public class CallableStatementTracing { try { Span span = ContextManager.createSpan(connectInfo.getDBType() + "/JDBI/CallableStatement/" + method); Tags.DB_TYPE.set(span, "sql"); Tags.SPAN_KIND.set(span, Tags.SPAN_KIND_CLIENT); Tags.DB_INSTANCE.set(span, connectInfo.getDatabaseName()); Tags.DB_STATEMENT.set(span, sql); Tags.SPAN_LAYER.asDB(span); Loading skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/ConnectionTracing.java +1 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ public class ConnectionTracing { try { Span span = ContextManager.createSpan(connectInfo.getDBType() + "/JDBI/Connection/" + method); Tags.DB_TYPE.set(span, "sql"); Tags.SPAN_KIND.set(span, Tags.SPAN_KIND_CLIENT); Tags.DB_INSTANCE.set(span, connectInfo.getDatabaseName()); Tags.DB_STATEMENT.set(span, sql); Tags.COMPONENT.set(span, connectInfo.getDBType()); Loading Loading
skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/conf/Config.java +1 −1 Original line number Diff line number Diff line Loading @@ -9,7 +9,7 @@ public class Config { public static String PATH = ""; public static int SAMPLING_RATE = 10000; public static int SAMPLING_CYCLE = 1; } public static class Collector{ Loading
skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/sampling/SamplingService.java +8 −9 Original line number Diff line number Diff line Loading @@ -12,7 +12,7 @@ import com.a.eye.skywalking.trace.TraceSegment; * have been traced, but, considering CPU cost of serialization/deserialization, and network bandwidth, the agent do NOT * send all of them to collector, if SAMPLING is on. * * By default, SAMPLING is off, and {@link Config.Agent#SAMPLING_RATE} == 1000. * By default, SAMPLING is off, and {@link Config.Agent#SAMPLING_CYCLE} == 1. * * @author wusheng */ Loading @@ -20,26 +20,25 @@ public class SamplingService implements BootService { private static ILog logger = LogManager.getLogger(SamplingService.class); private volatile boolean on = false; private volatile int rate = 0; private volatile int rollingSeed = 1; @Override public void bootUp() throws Throwable { if (Config.Agent.SAMPLING_RATE == 10000) { if (Config.Agent.SAMPLING_CYCLE == 1) { this.on = false; return; } if (Config.Agent.SAMPLING_RATE > 10000 || Config.Agent.SAMPLING_RATE < 1) { throw new IllegalSamplingRateException("sampling rate should stay in (0, 10000]."); if (Config.Agent.SAMPLING_CYCLE < 1) { throw new IllegalSamplingRateException("sampling cycle must greater than 0."); } rate = 10000 / Config.Agent.SAMPLING_RATE; on = true; this.on = true; logger.debug("The trace sampling is on, and the sampling rate is: {}", rate); logger.debug("The trace sampling is on, and the sampling cycle is: {}", Config.Agent.SAMPLING_CYCLE); } public void trySampling(TraceSegment segment) { if (on) { if (rollingSeed % rate != 0) { if (rollingSeed % Config.Agent.SAMPLING_CYCLE != 0) { segment.setSampled(false); } rollingSeed++; Loading
skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/api/sampling/SamplingServiceTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -13,7 +13,7 @@ import org.junit.Test; public class SamplingServiceTest { @Test public void test50Percent(){ Config.Agent.SAMPLING_RATE = 5000; Config.Agent.SAMPLING_CYCLE = 2; ServiceManager.INSTANCE.boot(); TraceSegment segment = new TraceSegment(); Loading @@ -30,7 +30,7 @@ public class SamplingServiceTest { @AfterClass public static void clear(){ Config.Agent.SAMPLING_RATE = 10000; Config.Agent.SAMPLING_CYCLE = 1; ServiceManager.INSTANCE.boot(); } }
skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/CallableStatementTracing.java +1 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ public class CallableStatementTracing { try { Span span = ContextManager.createSpan(connectInfo.getDBType() + "/JDBI/CallableStatement/" + method); Tags.DB_TYPE.set(span, "sql"); Tags.SPAN_KIND.set(span, Tags.SPAN_KIND_CLIENT); Tags.DB_INSTANCE.set(span, connectInfo.getDatabaseName()); Tags.DB_STATEMENT.set(span, sql); Tags.SPAN_LAYER.asDB(span); Loading
skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/ConnectionTracing.java +1 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ public class ConnectionTracing { try { Span span = ContextManager.createSpan(connectInfo.getDBType() + "/JDBI/Connection/" + method); Tags.DB_TYPE.set(span, "sql"); Tags.SPAN_KIND.set(span, Tags.SPAN_KIND_CLIENT); Tags.DB_INSTANCE.set(span, connectInfo.getDatabaseName()); Tags.DB_STATEMENT.set(span, sql); Tags.COMPONENT.set(span, connectInfo.getDBType()); Loading