Skip to content

Commit

Permalink
Support remaining OpenTelemetry Metrics proto spec features (#1335)
Browse files Browse the repository at this point in the history
* Bump OTEL proto version

Signed-off-by: Kai Sternad <[email protected]>
Co-authored-by: Tomas Longo <[email protected]>
Co-authored-by: Karsten Schnitter <[email protected]>

* Support OTEL ScopeMetrics

Signed-off-by: Kai Sternad <[email protected]>
Co-authored-by: Tomas Longo <[email protected]>
Co-authored-by: Karsten Schnitter <[email protected]>

* Add support for OTEL schemaUrl

Signed-off-by: Kai Sternad <[email protected]>
Co-authored-by: Tomas Longo <[email protected]>
Co-authored-by: Karsten Schnitter <[email protected]>

* Add exemplars to metrics plugin

Signed-off-by: Kai Sternad <[email protected]>
Co-authored-by: Tomas Longo <[email protected]>
Co-authored-by: Karsten Schnitter <[email protected]>

* Add metrics flags

Signed-off-by: Kai Sternad <[email protected]>
Co-authored-by: Tomas Longo <[email protected]>
Co-authored-by: Karsten Schnitter <[email protected]>

* Add support for Exponential Histogram

Signed-off-by: Kai Sternad <[email protected]>
Co-authored-by: Tomas Longo <[email protected]>
Co-authored-by: Karsten Schnitter <[email protected]>

* Add config switch for histogram bucket calculation

Signed-off-by: Kai Sternad <[email protected]>
Co-authored-by: Tomas Longo <[email protected]>
Co-authored-by: Karsten Schnitter <[email protected]>

* Refactor Otel Metrics Proto

Signed-off-by: Kai Sternad <[email protected]>
Co-authored-by: Tomas Longo <[email protected]>
Co-authored-by: Karsten Schnitter <[email protected]>

* Change config property to snake_case

Signed-off-by: Kai Sternad <[email protected]>
Co-authored-by: Tomas Longo <[email protected]>
Co-authored-by: Karsten Schnitter <[email protected]>

* Fix JavaDoc

Signed-off-by: Kai Sternad <[email protected]>
Co-authored-by: Tomas Longo <[email protected]>
Co-authored-by: Karsten Schnitter <[email protected]>

* Remove Clock from tests

Signed-off-by: Kai Sternad <[email protected]>
Co-authored-by: Tomas Longo <[email protected]>
Co-authored-by: Karsten Schnitter <[email protected]>

* Change config parameters

- Introduce allowed max scale
- Invert histogram calculation params

Signed-off-by: Kai Sternad <[email protected]>
Co-authored-by: Tomas Longo <[email protected]>
Co-authored-by: Karsten Schnitter <[email protected]>

* Address review comments

- Remove unused import, breaking Checkstyle
- Change Exponential Histogram filter
- Add lenient to some Mockito calls
- Clarify metrics processor documentation

Signed-off-by: Kai Sternad <[email protected]>
Co-authored-by: Tomas Longo <[email protected]>
Co-authored-by: Karsten Schnitter <[email protected]>

* Fix OtelMetricsRawProcessorConfigTest

Signed-off-by: Kai Sternad <[email protected]>
Co-authored-by: Tomas Longo <[email protected]>
Co-authored-by: Karsten Schnitter <[email protected]>

* Change ExponentialHistogram Bucket Calculation

- Precompute all possible bucket bounds
- Consider negative offset

Signed-off-by: Kai Sternad <[email protected]>
Co-authored-by: Tomas Longo <[email protected]>
Co-authored-by: Karsten Schnitter <[email protected]>

* Fix e2e otel dependency coordinates

Signed-off-by: Kai Sternad <[email protected]>
Co-authored-by: Tomas Longo <[email protected]>
Co-authored-by: Karsten Schnitter <[email protected]>

* Fix dependency coordinate for otel

Signed-off-by: Kai Sternad <[email protected]>

Signed-off-by: Kai Sternad <[email protected]>
Co-authored-by: Kai Sternad <[email protected]>
Co-authored-by: Tomas Longo <[email protected]>
Co-authored-by: Karsten Schnitter <[email protected]>
  • Loading branch information
4 people authored Nov 4, 2022
1 parent 0d1a378 commit 0c7b7cb
Show file tree
Hide file tree
Showing 41 changed files with 3,113 additions and 164 deletions.
2 changes: 1 addition & 1 deletion build-resources.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
ext.versionMap = [
junitJupiter : '5.8.2',
mockito : '3.11.2',
opentelemetryProto : '1.7.1-alpha',
opentelemetryProto : '0.16.0-alpha',
opensearchVersion : '1.3.5',
armeria: '1.19.0',
armeriaGrpc: '1.19.0',
Expand Down
2 changes: 2 additions & 0 deletions data-prepper-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ dependencies {
testImplementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml'
implementation "org.apache.commons:commons-lang3:3.12.0"
testImplementation project(':data-prepper-test-common')
testImplementation 'org.skyscreamer:jsonassert:1.5.0'
testImplementation 'commons-io:commons-io:2.11.0'
}

jacocoTestCoverageVerification {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

package org.opensearch.dataprepper.model.metric;

import java.util.Map;

/**
* The default implementation of {@link Exemplar}
*
* @since 1.4
*/
public class DefaultExemplar implements Exemplar {

private String time;
private Double value;
private Map<String, Object> attributes;
private String spanId;
private String traceId;

// required for serialization
DefaultExemplar() {}

public DefaultExemplar(String time, Double value, String spanId, String traceId, Map<String, Object> attributes) {
this.time = time;
this.value = value;
this.spanId = spanId;
this.traceId = traceId;
this.attributes = attributes;
}

@Override
public String getTime() {
return time;
}

@Override
public Double getValue() {
return value;
}

@Override
public Map<String, Object> getAttributes() {
return attributes;
}

@Override
public String getSpanId() {
return spanId;
}

@Override
public String getTraceId() {
return traceId;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

package org.opensearch.dataprepper.model.metric;

import java.util.Map;

/**
* A representation of an exemplar which is a sample input measurement.
* It may contain the span and trace id of a metric event.
*
* @since 1.4
*/
public interface Exemplar {

/**
* Gets the string encoded value of time_unix_nano
* @return the time value
* @since 1.4
*/
String getTime();


/**
* Gets the value for the exemplar
* @return the value
* @since 1.4
*/
Double getValue();

/**
* Gets a collection of key-value pairs related to the exemplar.
*
* @return A map of attributes
* @since 1.4
*/
Map<String, Object> getAttributes();

/**
* Gets the span id of this exemplar.
*
* @return the span id
* @since 1.4
*/
String getSpanId();

/**
* Gets the trace id of this exemplar.
*
* @return the trace id
* @since 1.4
*/
String getTraceId();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

package org.opensearch.dataprepper.model.metric;

import java.util.List;

public interface ExponentialHistogram 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 aggregation temporality for the histogram
*
* @return the aggregation temporality
* @since 1.4
*/
String getAggregationTemporality();

/**
* Gets the positive range of exponential buckets
*
* @return the buckets
* @since 1.4
*/
List<? extends Bucket> getPositiveBuckets();

/**
* Gets the negative range of exponential buckets
*
* @return the buckets
* @since 1.4
*/
List<? extends Bucket> getNegativeBuckets();


/**
* Gets the positive range of exponential bucket counts
*
* @return the buckets
* @since 1.4
*/
List<Long> getNegative();


/**
* Gets the negative range of exponential bucket counts
*
* @return the buckets
* @since 1.4
*/
List<Long> getPositive();

/**
* Gets the zero count of events
*
* @return the zero count
* @since 1.4
*/
Long getZeroCount();

/**
* Gets the scale for the histogram
*
* @return the scale
* @since 1.4
*/
Integer getScale();

/**
* Gets the offset for negative buckets
*
* @return the offset
* @since 1.4
*/
Integer getNegativeOffset();


/**
* Gets the offset for positive buckets
*
* @return the offset
* @since 1.4
*/
Integer getPositiveOffset();
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,26 @@ public interface Histogram extends Metric {
String getAggregationTemporality();

/**
* Gets the actual buckets for a histogram
* Gets the computed buckets for a histogram
*
* @return the buckets
* @since 1.4
*/
List<? extends Bucket> getBuckets();

/**
* Gets bucket counts for a histogram
*
* @return the bucket values
* @since 1.4
*/
List<Long> getBucketCountsList();

/**
* Gets the explicit bounds list for a histogram
*
* @return the bounds
* @since 1.4
*/
List<Double> getExplicitBoundsList();
}
Loading

0 comments on commit 0c7b7cb

Please sign in to comment.