Last active
April 10, 2018 12:15
-
-
Save acogoluegnes/9df69e2262c05bcfe5dfa56fa1a9c5a7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
for (String dc : new String[] {"us", "europe", "asia"}) { | |
Tags tags = Tags.of("host", hostname, "dc", dc); | |
MeterRegistry jmxRegistry = new JmxMeterRegistry(JmxConfig.DEFAULT, Clock.SYSTEM); | |
new ClassLoaderMetrics(tags).bindTo(jmxRegistry); | |
new JvmMemoryMetrics(tags).bindTo(jmxRegistry); | |
new JvmGcMetrics(tags).bindTo(jmxRegistry); | |
new ProcessorMetrics(tags).bindTo(jmxRegistry); | |
new JvmThreadMetrics(tags).bindTo(jmxRegistry); | |
ConnectionFactory connectionFactory = new ConnectionFactory(); | |
MicrometerMetricsCollector metricsCollector = new MicrometerMetricsCollector( | |
jmxRegistry, "rabbitmq.client", tags | |
); | |
connectionFactory.setMetricsCollector(metricsCollector); | |
Connection connection = connectionFactory.newConnection(); | |
Channel channel = connection.createChannel(); | |
String queue = channel.queueDeclare().getQueue(); | |
channel.basicConsume(queue, true, (ctag, msg) -> { }, (ctag) -> { }); | |
executor.submit(() -> { | |
Random random = new Random(); | |
int offset = dc.length() * 10; | |
while (true) { | |
Thread.sleep(random.nextInt(100) + offset); | |
channel.basicPublish("", queue, null, "".getBytes()); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment