forked from opensearch-project/OpenSearch
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Metric Framework] Adds support for Histogram metric (opensearch-proj…
…ect#12062) * [Metric Framework] Adds support for Histogram metric Signed-off-by: Gagan Juneja <[email protected]> * Adds test Signed-off-by: Gagan Juneja <[email protected]> * Addresses review comments Signed-off-by: Gagan Juneja <[email protected]> * Adds change log Signed-off-by: Gagan Juneja <[email protected]> * Fixed spotless Signed-off-by: Gagan Juneja <[email protected]> * Fixes javadoc Signed-off-by: Gagan Juneja <[email protected]> * Fixes javadoc Signed-off-by: Gagan Juneja <[email protected]> * Fixes test Signed-off-by: Gagan Juneja <[email protected]> * Removes explicit approach Signed-off-by: Gagan Juneja <[email protected]> * Removes explicit approach Signed-off-by: Gagan Juneja <[email protected]> * Addresses review comments Signed-off-by: Gagan Juneja <[email protected]> --------- Signed-off-by: Gagan Juneja <[email protected]> Co-authored-by: Gagan Juneja <[email protected]>
- Loading branch information
1 parent
c51818a
commit a4bc4af
Showing
14 changed files
with
242 additions
and
0 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
35 changes: 35 additions & 0 deletions
35
libs/telemetry/src/main/java/org/opensearch/telemetry/metrics/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,35 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.telemetry.metrics; | ||
|
||
import org.opensearch.common.annotation.ExperimentalApi; | ||
import org.opensearch.telemetry.metrics.tags.Tags; | ||
|
||
/** | ||
* Histogram records the value for an existing metric. | ||
* {@opensearch.experimental} | ||
*/ | ||
@ExperimentalApi | ||
public interface Histogram { | ||
|
||
/** | ||
* record value. | ||
* @param value value to be added. | ||
*/ | ||
void record(double value); | ||
|
||
/** | ||
* record value along with the attributes. | ||
* | ||
* @param value value to be added. | ||
* @param tags attributes/dimensions of the metric. | ||
*/ | ||
void record(double value, Tags tags); | ||
|
||
} |
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
38 changes: 38 additions & 0 deletions
38
libs/telemetry/src/main/java/org/opensearch/telemetry/metrics/noop/NoopHistogram.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,38 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.telemetry.metrics.noop; | ||
|
||
import org.opensearch.common.annotation.InternalApi; | ||
import org.opensearch.telemetry.metrics.Histogram; | ||
import org.opensearch.telemetry.metrics.tags.Tags; | ||
|
||
/** | ||
* No-op {@link Histogram} | ||
* {@opensearch.internal} | ||
*/ | ||
@InternalApi | ||
public class NoopHistogram implements Histogram { | ||
|
||
/** | ||
* No-op Histogram instance | ||
*/ | ||
public final static NoopHistogram INSTANCE = new NoopHistogram(); | ||
|
||
private NoopHistogram() {} | ||
|
||
@Override | ||
public void record(double value) { | ||
|
||
} | ||
|
||
@Override | ||
public void record(double value, Tags tags) { | ||
|
||
} | ||
} |
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
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
40 changes: 40 additions & 0 deletions
40
plugins/telemetry-otel/src/main/java/org/opensearch/telemetry/metrics/OTelHistogram.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,40 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.telemetry.metrics; | ||
|
||
import org.opensearch.telemetry.OTelAttributesConverter; | ||
import org.opensearch.telemetry.metrics.tags.Tags; | ||
|
||
import io.opentelemetry.api.metrics.DoubleHistogram; | ||
|
||
/** | ||
* OTel aware implementation {@link Histogram} | ||
*/ | ||
class OTelHistogram implements Histogram { | ||
|
||
private final DoubleHistogram otelDoubleHistogram; | ||
|
||
/** | ||
* Constructor | ||
* @param otelDoubleCounter delegate counter. | ||
*/ | ||
public OTelHistogram(DoubleHistogram otelDoubleCounter) { | ||
this.otelDoubleHistogram = otelDoubleCounter; | ||
} | ||
|
||
@Override | ||
public void record(double value) { | ||
otelDoubleHistogram.record(value); | ||
} | ||
|
||
@Override | ||
public void record(double value, Tags tags) { | ||
otelDoubleHistogram.record(value, OTelAttributesConverter.convert(tags)); | ||
} | ||
} |
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
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