Skip to content

Commit

Permalink
Removing build and format error
Browse files Browse the repository at this point in the history
  • Loading branch information
PaurushGarg committed Nov 28, 2023
1 parent 0df5553 commit 244335b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,16 @@ private void createGauges(Meter meter) {
if (meter != null) {
log.info("Registering gauge metrics...");
gaugeValues = new long[param.getRate() * 5];
for (int i = 0; i < param.getRate() * 5; i++) {
meter.gaugeBuilder(API_LATENCY_METRIC + i)
int id = 0;
for (long gaugeValue : gaugeValues) {
meter.gaugeBuilder(API_LATENCY_METRIC + id++)
.setDescription("API latency time")
.setUnit("ms")
.ofLongs().buildWithCallback(measurement ->
{
Attributes atr = Attributes.of(AttributeKey.stringKey(DIMENSION_API_NAME), API_NAME,
AttributeKey.stringKey(DIMENSION_STATUS_CODE), "200");
measurement.record(gaugeValues[0], atr);
measurement.record(gaugeValue, atr);
}
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@
import com.amazon.opentelemetry.load.generator.model.Parameter;
import lombok.extern.log4j.Log4j2;


import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.util.concurrent.ThreadLocalRandom;

@Log4j2
public class StatsdMetricEmitter extends MetricEmitter{
public class StatsdMetricEmitter extends MetricEmitter {

InetAddress ipAddress;
int portAddress;
Expand All @@ -46,8 +45,8 @@ public void emitDataLoad() throws Exception {
@Override
public void setupProvider() throws Exception {
log.info("Setting up Statsd metric emitter to generate load...");
ipAddress = InetAddress.getByName(param.getEndpoint().split(":",2)[0]);
portAddress = Integer.parseInt(param.getEndpoint().split(":",2)[1]);
ipAddress = InetAddress.getByName(param.getEndpoint().split(":", 2)[0]);
portAddress = Integer.parseInt(param.getEndpoint().split(":", 2)[1]);
socket = new DatagramSocket();
log.info("Finished Setting up Statsd metric emitter.");
}
Expand All @@ -69,16 +68,14 @@ public void sendStatsd() throws IOException {
String attributes = "#mykey:myvalue,datapoint_id:";
log.debug("Updating metrics...");
for (int i = 0; i < this.param.getRate() * 5; i++) {
for (int id = 0; id < this.param.getDatapointCount(); id++) {
payload.append("statsdTestMetric").append(i).append(":")
.append(ThreadLocalRandom.current().nextInt(-100,100))
.append("|g|").append(attributes).append(id).append("\n");
}
payload.append("statsdTestMetric").append(i).append(":")
.append(ThreadLocalRandom.current().nextInt(-100, 100))
.append("|g|").append(attributes).append(i).append("\n");
}
buf = payload.toString().getBytes();
log.debug("Payload size: %d", buf.length);
if (buf.length >= 64000) {
throw new RuntimeException ("Reduce the number of metrics/data-points. UDP packets have size limitation of 64k");
throw new RuntimeException("Reduce the number of metrics/data-points. UDP packets have size limitation of 64k");
}
DatagramPacket packet = new DatagramPacket(buf, buf.length, ipAddress, portAddress);
socket.send(packet);
Expand Down

0 comments on commit 244335b

Please sign in to comment.