forked from fafeidou/fast-cloud-nacos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
qinfuxiang
committed
Dec 2, 2021
1 parent
ea9f6c7
commit 2ccf5f7
Showing
16 changed files
with
130 additions
and
16 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
.../fast/cloud/nacos/metrics/CacheGauge.java → ...loud/nacos/metrics/metric/CacheGauge.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...t/cloud/nacos/metrics/CounterExample.java → .../nacos/metrics/metric/CounterExample.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...llyDecayingReservoirHistogramExample.java → ...llyDecayingReservoirHistogramExample.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package fast.cloud.nacos.metrics; | ||
package fast.cloud.nacos.metrics.metric; | ||
|
||
import com.codahale.metrics.*; | ||
|
||
|
2 changes: 1 addition & 1 deletion
2
...cloud/nacos/metrics/HistogramExample.java → ...acos/metrics/metric/HistogramExample.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...cos/metrics/JmxAttributeGaugeExample.java → ...rics/metric/JmxAttributeGaugeExample.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../fast/cloud/nacos/metrics/RadioGauge.java → ...loud/nacos/metrics/metric/RadioGauge.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...oud/nacos/metrics/SimpleGaugeExample.java → ...os/metrics/metric/SimpleGaugeExample.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...TimeWindowReservoirsHistogramExample.java → ...TimeWindowReservoirsHistogramExample.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package fast.cloud.nacos.metrics; | ||
package fast.cloud.nacos.metrics.metric; | ||
|
||
import com.codahale.metrics.*; | ||
|
||
|
2 changes: 1 addition & 1 deletion
2
...dingWindowReservoirsHistogramExample.java → ...dingWindowReservoirsHistogramExample.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package fast.cloud.nacos.metrics; | ||
package fast.cloud.nacos.metrics.metric; | ||
|
||
import com.codahale.metrics.*; | ||
|
||
|
31 changes: 31 additions & 0 deletions
31
...e-code-analysis/code-metrics/src/main/java/fast/cloud/nacos/metrics/metric/TimerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package fast.cloud.nacos.metrics.metric; | ||
|
||
import com.codahale.metrics.ConsoleReporter; | ||
import com.codahale.metrics.MetricRegistry; | ||
import com.codahale.metrics.Timer; | ||
|
||
import java.util.Random; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
public class TimerTest { | ||
|
||
public static Random random = new Random(); | ||
|
||
public static void main(String[] args) throws InterruptedException { | ||
MetricRegistry registry = new MetricRegistry(); | ||
ConsoleReporter reporter = ConsoleReporter.forRegistry(registry).build(); | ||
reporter.start(1, TimeUnit.SECONDS); | ||
|
||
Timer timer = registry.timer(MetricRegistry.name(TimerTest.class,"get-latency")); | ||
|
||
Timer.Context ctx; | ||
|
||
while(true){ | ||
ctx = timer.time(); | ||
Thread.sleep(random.nextInt(1000)); | ||
ctx.stop(); | ||
} | ||
|
||
} | ||
|
||
} |
2 changes: 1 addition & 1 deletion
2
...ics/UniformReservoirHistogramExample.java → ...ric/UniformReservoirHistogramExample.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
.../code-metrics/src/main/java/fast/cloud/nacos/metrics/reporter/ConsoleReporterExample.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package fast.cloud.nacos.metrics.reporter; | ||
|
||
import com.codahale.metrics.ConsoleReporter; | ||
import com.codahale.metrics.Histogram; | ||
import com.codahale.metrics.MetricRegistry; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
|
||
import static java.util.concurrent.ThreadLocalRandom.current; | ||
|
||
public class ConsoleReporterExample { | ||
private static final MetricRegistry registry = new MetricRegistry(); | ||
|
||
private static final ConsoleReporter reporter = ConsoleReporter.forRegistry(registry) | ||
.convertRatesTo(TimeUnit.SECONDS) | ||
.convertDurationsTo(TimeUnit.SECONDS).build(); | ||
|
||
private static final Histogram histogram = registry.histogram("search-result"); | ||
|
||
public static void main(String[] args) { | ||
reporter.start(10,TimeUnit.SECONDS); | ||
|
||
while (true) { | ||
doSearch(); | ||
randomSleep(); | ||
} | ||
} | ||
|
||
private static void doSearch() { | ||
histogram.update(current().nextInt(10)); | ||
} | ||
|
||
|
||
private static void randomSleep() { | ||
try { | ||
TimeUnit.SECONDS.sleep(current().nextInt(500)); | ||
} catch (InterruptedException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
} |
2 changes: 1 addition & 1 deletion
2
...oud/nacos/metrics/CsvReporterExample.java → .../metrics/reporter/CsvReporterExample.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...oud/nacos/metrics/JmxReporterExample.java → .../metrics/reporter/JmxReporterExample.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...is/code-metrics/src/main/java/fast/cloud/nacos/metrics/reporter/SLF4jReporterExample.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package fast.cloud.nacos.metrics.reporter; | ||
|
||
import com.codahale.metrics.Histogram; | ||
import com.codahale.metrics.MetricRegistry; | ||
import com.codahale.metrics.Slf4jReporter; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
|
||
import static java.util.concurrent.ThreadLocalRandom.current; | ||
|
||
public class SLF4jReporterExample { | ||
private static final MetricRegistry registry = new MetricRegistry(); | ||
|
||
private static final Slf4jReporter reporter = Slf4jReporter.forRegistry(registry) | ||
.outputTo(LoggerFactory.getLogger(SLF4jReporterExample.class)) | ||
.convertRatesTo(TimeUnit.SECONDS) | ||
.convertDurationsTo(TimeUnit.SECONDS).build(); | ||
|
||
private static final Histogram histogram = registry.histogram("search-result"); | ||
|
||
public static void main(String[] args) { | ||
reporter.start(10,TimeUnit.SECONDS); | ||
|
||
while (true) { | ||
doSearch(); | ||
randomSleep(); | ||
} | ||
} | ||
|
||
private static void doSearch() { | ||
histogram.update(current().nextInt(10)); | ||
} | ||
|
||
|
||
private static void randomSleep() { | ||
try { | ||
TimeUnit.SECONDS.sleep(current().nextInt(500)); | ||
} catch (InterruptedException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
} |