forked from opensearch-project/data-prepper
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for OTEL metrics source to use Kafka buffer (opensearch-p…
…roject#3539) * Add support for OTEL metrics source to use Kafka buffer Signed-off-by: Krishna Kondaka <[email protected]> * Added tests and fixed test failures Signed-off-by: Krishna Kondaka <[email protected]> --------- Signed-off-by: Krishna Kondaka <[email protected]> Co-authored-by: Krishna Kondaka <[email protected]>
- Loading branch information
Showing
16 changed files
with
626 additions
and
250 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
286 changes: 52 additions & 234 deletions
286
...ava/org/opensearch/dataprepper/plugins/processor/otelmetrics/OTelMetricsRawProcessor.java
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
39 changes: 39 additions & 0 deletions
39
...common/src/main/java/org/opensearch/dataprepper/plugins/otel/codec/OTelMetricDecoder.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,39 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.dataprepper.plugins.otel.codec; | ||
|
||
import io.opentelemetry.proto.collector.metrics.v1.ExportMetricsServiceRequest; | ||
import org.opensearch.dataprepper.model.codec.ByteDecoder; | ||
import org.opensearch.dataprepper.model.record.Record; | ||
import org.opensearch.dataprepper.model.event.Event; | ||
import org.opensearch.dataprepper.model.event.JacksonEvent; | ||
import org.opensearch.dataprepper.model.metric.Metric; | ||
|
||
|
||
import java.util.Collection; | ||
import java.util.concurrent.atomic.AtomicInteger; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.util.function.Consumer; | ||
|
||
|
||
public class OTelMetricDecoder implements ByteDecoder { | ||
private final OTelProtoCodec.OTelProtoDecoder otelProtoDecoder; | ||
public OTelMetricDecoder() { | ||
otelProtoDecoder = new OTelProtoCodec.OTelProtoDecoder(); | ||
} | ||
public void parse(InputStream inputStream, Consumer<Record<Event>> eventConsumer) throws IOException { | ||
ExportMetricsServiceRequest request = ExportMetricsServiceRequest.parseFrom(inputStream); | ||
AtomicInteger droppedCounter = new AtomicInteger(0); | ||
Collection<Record<? extends Metric>> records = | ||
otelProtoDecoder.parseExportMetricsServiceRequest(request, droppedCounter, OTelProtoCodec.DEFAULT_EXPONENTIAL_HISTOGRAM_MAX_ALLOWED_SCALE, true, true, false); | ||
for (Record<? extends Metric> record: records) { | ||
final JacksonEvent event = JacksonEvent.fromEvent(record.getData()); | ||
eventConsumer.accept(new Record<>(event)); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.