Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,22 @@ private static TestCaseSupplier makeSupplier(TestCaseSupplier.TypedDataSupplier
if (dataRows.size() < 2) {
matcher = Matchers.nullValue();
} else {
// TODO: check the value?
matcher = Matchers.allOf(Matchers.greaterThanOrEqualTo(0.0), Matchers.lessThan(Double.POSITIVE_INFINITY));
var maxrate = switch (fieldTypedData.type().widenSmallNumeric()) {
case INTEGER, COUNTER_INTEGER -> dataRows.stream().mapToInt(v -> (Integer) v).max().orElse(0);
case LONG, COUNTER_LONG -> dataRows.stream().mapToLong(v -> (Long) v).max().orElse(0L);
case DOUBLE, COUNTER_DOUBLE -> dataRows.stream().mapToDouble(v -> (Double) v).max().orElse(0.0);
default -> throw new IllegalStateException("Unexpected value: " + fieldTypedData.type());
};
var minrate = switch (fieldTypedData.type().widenSmallNumeric()) {
case INTEGER, COUNTER_INTEGER -> dataRows.stream().mapToInt(v -> (Integer) v).min().orElse(0);
case LONG, COUNTER_LONG -> dataRows.stream().mapToLong(v -> (Long) v).min().orElse(0L);
case DOUBLE, COUNTER_DOUBLE -> dataRows.stream().mapToDouble(v -> (Double) v).min().orElse(0.0);
default -> throw new IllegalStateException("Unexpected value: " + fieldTypedData.type());
};
// If the minrate is greater than 0, we need to adjust the maxrate accordingly
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting.. I would've thought that counters are INTEGER or LONG, and only COUNTER_INTEGER and COUNTER_LONG can be input to rate. Also, I haven't thought about negative values - though OTLP has the notion of up/down counters:

https://opentelemetry.io/docs/specs/otel/metrics/supplementary-guidelines/#instrument-selection

Maybe we should restrict the current rate implementation to non-negative counter values and check for that? @dnhatn for thoughts.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should restrict the current rate implementation to non-negative counter values and check for that?

I think the current rate implementation does not work correctly with up/down counters.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hm there's no check for negative values, though.. Shall we add a check and error out, if a negative counter value is detected?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hi team! how would these address changes to my PR? what should we address here?

Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need to address the issue here.

minrate = Math.min(minrate, 0);
maxrate = Math.max(maxrate, maxrate - minrate);
matcher = Matchers.allOf(Matchers.greaterThanOrEqualTo(minrate), Matchers.lessThanOrEqualTo(maxrate));
}
return new TestCaseSupplier.TestCase(
List.of(fieldTypedData, timestampsField),
Expand Down