-
Notifications
You must be signed in to change notification settings - Fork 210
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into tst/trace-event-migration-backward-compatibi…
…lity-e2e-tests Signed-off-by: Qi Chen <[email protected]>
- Loading branch information
Showing
51 changed files
with
4,481 additions
and
6 deletions.
There are no files selected for viewing
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
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
35 changes: 35 additions & 0 deletions
35
data-prepper-api/src/main/java/com/amazon/dataprepper/model/metric/Bucket.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,35 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package com.amazon.dataprepper.model.metric; | ||
|
||
/** | ||
* Represents a bucket of a {@link Histogram}. | ||
* . | ||
* @since 1.4 | ||
*/ | ||
public interface Bucket { | ||
|
||
/** | ||
* Gets the lower bound of the bucket | ||
* @return the min | ||
* @since 1.4 | ||
*/ | ||
Double getMin(); | ||
|
||
/** | ||
* Gets the upper bound of the bucket | ||
* @return the max | ||
* @since 1.4 | ||
*/ | ||
Double getMax(); | ||
|
||
/** | ||
* Gets the number of events in a bucket | ||
* @return the count | ||
* @since 1.4 | ||
*/ | ||
Long getCount(); | ||
} |
42 changes: 42 additions & 0 deletions
42
data-prepper-api/src/main/java/com/amazon/dataprepper/model/metric/DefaultBucket.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 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package com.amazon.dataprepper.model.metric; | ||
|
||
/** | ||
* The default implementation of {@link Bucket}, measurement within a {@link Histogram} | ||
* | ||
* @since 1.4 | ||
*/ | ||
public class DefaultBucket implements Bucket { | ||
|
||
private Double min; | ||
private Double max; | ||
private Long count; | ||
|
||
// required for serialization | ||
DefaultBucket() {} | ||
|
||
public DefaultBucket(Double min, Double max, Long count) { | ||
this.min = min; | ||
this.max = max; | ||
this.count = count; | ||
} | ||
|
||
@Override | ||
public Double getMin() { | ||
return min; | ||
} | ||
|
||
@Override | ||
public Double getMax() { | ||
return max; | ||
} | ||
|
||
@Override | ||
public Long getCount() { | ||
return count; | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
data-prepper-api/src/main/java/com/amazon/dataprepper/model/metric/DefaultQuantile.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,35 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package com.amazon.dataprepper.model.metric; | ||
|
||
/** | ||
* The default implementation of {@link Quantile}, measurement within a {@link Summary} | ||
* | ||
* @since 1.4 | ||
*/ | ||
public class DefaultQuantile implements Quantile { | ||
private Double quantile; | ||
private Double value; | ||
|
||
// required for serialization | ||
DefaultQuantile() {} | ||
|
||
public DefaultQuantile(Double quantile, Double value) { | ||
this.quantile = quantile; | ||
this.value = value; | ||
} | ||
|
||
@Override | ||
public Double getValue() { | ||
return value; | ||
} | ||
|
||
@Override | ||
public Double getQuantile() { | ||
return quantile; | ||
} | ||
} | ||
|
20 changes: 20 additions & 0 deletions
20
data-prepper-api/src/main/java/com/amazon/dataprepper/model/metric/Gauge.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,20 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package com.amazon.dataprepper.model.metric; | ||
|
||
/** | ||
* A gauge event in Data Prepper represents a metric event. | ||
* @since 1.4 | ||
*/ | ||
public interface Gauge extends Metric { | ||
|
||
/** | ||
* Gets the value for a gauge | ||
* @return the value | ||
* @since 1.4 | ||
*/ | ||
Double getValue(); | ||
} |
65 changes: 65 additions & 0 deletions
65
data-prepper-api/src/main/java/com/amazon/dataprepper/model/metric/Histogram.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,65 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package com.amazon.dataprepper.model.metric; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* A Histogram event | ||
* | ||
* @since 1.4 | ||
*/ | ||
public interface Histogram extends Metric { | ||
|
||
/** | ||
* Gets the sum for the histogram | ||
* | ||
* @return the sum of the values in the population | ||
* @since 1.4 | ||
*/ | ||
Double getSum(); | ||
|
||
|
||
/** | ||
* Gets the count of the histogram | ||
* @return the count, must be equal to the sum of the "count" fields in buckets | ||
* @since 1.4 | ||
*/ | ||
Long getCount(); | ||
|
||
/** | ||
* Gets the bucket count for the histogram | ||
* | ||
* @return the bucket count | ||
* @since 1.4 | ||
*/ | ||
Integer getBucketCount(); | ||
|
||
/** | ||
* Gets the number of explicit bounds for the histogram | ||
* | ||
* @return the number of bounds | ||
* @since 1.4 | ||
*/ | ||
Integer getExplicitBoundsCount(); | ||
|
||
/** | ||
* Gets the aggregation temporality for the histogram | ||
* | ||
* @return the aggregation temporality | ||
* @since 1.4 | ||
*/ | ||
String getAggregationTemporality(); | ||
|
||
/** | ||
* Gets the actual buckets for a histogram | ||
* | ||
* @return the buckets | ||
* @since 1.4 | ||
*/ | ||
List<? extends Bucket> getBuckets(); | ||
|
||
} |
88 changes: 88 additions & 0 deletions
88
data-prepper-api/src/main/java/com/amazon/dataprepper/model/metric/JacksonGauge.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,88 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package com.amazon.dataprepper.model.metric; | ||
|
||
import com.amazon.dataprepper.model.event.EventType; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
|
||
import static com.google.common.base.Preconditions.checkArgument; | ||
|
||
/** | ||
* A Jackson implementation for {@link Gauge}. | ||
* | ||
* @since 1.4 | ||
*/ | ||
public class JacksonGauge extends JacksonMetric implements Gauge { | ||
|
||
private static final String VALUE_KEY = "value"; | ||
|
||
private static final List<String> REQUIRED_KEYS = new ArrayList<>(); | ||
private static final List<String> REQUIRED_NON_EMPTY_KEYS = Arrays.asList(NAME_KEY, KIND_KEY, TIME_KEY); | ||
private static final List<String> REQUIRED_NON_NULL_KEYS = Collections.singletonList(VALUE_KEY); | ||
|
||
|
||
protected JacksonGauge(Builder builder) { | ||
super(builder); | ||
checkArgument(this.getMetadata().getEventType().equals(EventType.METRIC.toString()), "eventType must be of type Metric"); | ||
} | ||
|
||
public static Builder builder() { | ||
return new Builder(); | ||
} | ||
|
||
@Override | ||
public Double getValue() { | ||
return this.get(VALUE_KEY, Double.class); | ||
} | ||
|
||
/** | ||
* Builder for creating {@link JacksonGauge} | ||
* | ||
* @since 1.4 | ||
*/ | ||
public static class Builder extends JacksonMetric.Builder<JacksonGauge.Builder> { | ||
|
||
@Override | ||
public Builder getThis() { | ||
return this; | ||
} | ||
|
||
/** | ||
* Sets the value of the gauge | ||
* @param value the value of the gauge | ||
* @since 1.4 | ||
*/ | ||
public Builder withValue(final Double value) { | ||
if (value != null) { | ||
data.put(VALUE_KEY, value); | ||
} | ||
return this; | ||
} | ||
|
||
/** | ||
* Returns a newly created {@link JacksonGauge} | ||
* @return a JacksonGauge | ||
* @since 1.4 | ||
*/ | ||
public JacksonGauge build() { | ||
this.withEventKind(Metric.KIND.GAUGE.toString()); | ||
this.withData(data); | ||
this.withEventType(EventType.METRIC.toString()); | ||
checkAndSetDefaultValues(); | ||
new ParameterValidator().validate(REQUIRED_KEYS, REQUIRED_NON_EMPTY_KEYS, REQUIRED_NON_NULL_KEYS, data); | ||
return new JacksonGauge(this); | ||
} | ||
|
||
private void checkAndSetDefaultValues() { | ||
data.computeIfAbsent(ATTRIBUTES_KEY, k -> new HashMap<>()); | ||
} | ||
} | ||
} |
Oops, something went wrong.