Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to generate suitable load in otlp and statsd metric #874

Merged

Conversation

PaurushGarg
Copy link
Member

@PaurushGarg PaurushGarg commented Oct 11, 2022

Description:
Fixes issues described in issue #771 and issue #736

Todo:

  • Analyse the impact of this change on StatsdMetricEmitter
  • Update dependent projects where OTLP metric of load-generator is used (not part of this PR).

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@PaurushGarg PaurushGarg requested a review from a team as a code owner October 11, 2022 18:24
load-generator/README.md Outdated Show resolved Hide resolved
load-generator/Dockerfile Outdated Show resolved Hide resolved
load-generator/README.md Outdated Show resolved Hide resolved
load-generator/README.md Outdated Show resolved Hide resolved
@PaurushGarg PaurushGarg requested a review from Aneurysm9 October 12, 2022 21:32
@PaurushGarg PaurushGarg changed the title Changes to generate suitable load in otlp metric Changes to generate suitable load in otlp and statsd metric Oct 14, 2022
@PaurushGarg PaurushGarg requested a review from a team October 14, 2022 16:57
case "gauge":
for(int i=0 ; i < param.getMetricCount(); i++) {
for (int id = 0; id < param.getDatapointCount(); id++) {
this.gaugeValues.add(id, ThreadLocalRandom.current().nextLong(-100, 100));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will have unintended effects no? https://docs.oracle.com/javase/8/docs/api/java/util/ArrayList.html#add-int-E-

Inserts the specified element at the specified position in this list. Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).

Every time that you call nextDatapoint, more data will be added to the array. if this gets called enough, you might become out of memory.

maybe use plain array new long[param.getDataPointCount]?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Updated.

Comment on lines 61 to 76
switch (param.getMetricType()) {
case "counter":
for(LongCounter counter: counters) {
for(int id=0 ; id < param.getDatapointCount(); id++) {
Attributes datapointAttributes = getDataPointAttributes(id);
counter.add(ThreadLocalRandom.current().nextInt(1,10), datapointAttributes);
}
}
break;
case "gauge":
for(int i=0 ; i < param.getMetricCount(); i++) {
for (int id = 0; id < param.getDatapointCount(); id++) {
this.gaugeValues.add(id, ThreadLocalRandom.current().nextLong(-100, 100));
}
}
break;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I think you could use a Template class pattern or a strategy pattern in order to make the code cleaner instead of having to deal with these two different cases. The idea is that you instantiate a different implementation based on the metric type.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not updated code with this change, as I thought it is just a simple switch case in sample-app. But do let me know if it has to be done, then I will make the necessary changes.

case "counter":
for(LongCounter counter: counters) {
for(int id=0 ; id < param.getDatapointCount(); id++) {
Attributes datapointAttributes = getDataPointAttributes(id);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you attach attributes to counters at creation time or does it have to be done here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as each datapoint has a differentiating(at least one distinct) label, so I think it has to be done here (at the time of datapoint creation).

@@ -77,22 +104,52 @@ public void setupProvider() {
GlobalOpenTelemetry.meterBuilder("aws-otel-load-generator-metric")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
GlobalOpenTelemetry.meterBuilder("aws-otel-load-generator-metric")
GlobalOpenTelemetry.meterBuilder("adot-load-generator-metric")

Copy link
Member Author

@PaurushGarg PaurushGarg Nov 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Updated.

.append("|g|").append(attributes).append(id).append("\n");
}
}
buf = payload.toString().getBytes();
DatagramPacket packet = new DatagramPacket(buf, buf.length, ipAddress, portAddress);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just fyi, udp packets have size limitation of 64k. I think it is ok to let the exception bubble up, but maybe we can proactively check what is the size of buf before calling send and raise an RuntimeException asking the user to reduce the number of metrics/datapoints.

Copy link
Member Author

@PaurushGarg PaurushGarg Nov 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks updated.

@PaurushGarg PaurushGarg added the ADOT collector ADOT Collector related issues label Nov 2, 2022
@PaurushGarg PaurushGarg merged commit d6e823d into aws-observability:terraform Nov 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ADOT collector ADOT Collector related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants