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.
Change the codec's name to otel_logs (opensearch-project#5028)
Signed-off-by: Daniel Li <[email protected]>
- Loading branch information
Showing
6 changed files
with
96 additions
and
36 deletions.
There are no files selected for viewing
22 changes: 0 additions & 22 deletions
22
...common/src/main/java/org/opensearch/dataprepper/plugins/otel/codec/OTLPJsonLogsCodec.java
This file was deleted.
Oops, something went wrong.
34 changes: 34 additions & 0 deletions
34
...ommon/src/main/java/org/opensearch/dataprepper/plugins/otel/codec/OTelLogsInputCodec.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,34 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.dataprepper.plugins.otel.codec; | ||
|
||
import org.opensearch.dataprepper.model.annotations.DataPrepperPlugin; | ||
import org.opensearch.dataprepper.model.annotations.DataPrepperPluginConstructor; | ||
import org.opensearch.dataprepper.model.codec.InputCodec; | ||
import org.opensearch.dataprepper.model.event.Event; | ||
import org.opensearch.dataprepper.model.record.Record; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.util.Objects; | ||
import java.util.function.Consumer; | ||
|
||
@DataPrepperPlugin(name = "otel_logs", pluginType = InputCodec.class, pluginConfigurationType = OTelLogsInputCodecConfig.class) | ||
public class OTelLogsInputCodec implements InputCodec { | ||
private final OTelLogsInputCodecConfig config; | ||
|
||
@DataPrepperPluginConstructor | ||
public OTelLogsInputCodec(final OTelLogsInputCodecConfig config) { | ||
Objects.requireNonNull(config); | ||
this.config = config; | ||
} | ||
public void parse(InputStream inputStream, Consumer<Record<Event>> eventConsumer) throws IOException { | ||
if (OTelLogsInputCodecConfig.JSON_FORMAT.equals(config.getFormat())) { | ||
OTelLogsJsonDecoder decoder = new OTelLogsJsonDecoder(); | ||
decoder.parse(inputStream, null, eventConsumer); | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...src/main/java/org/opensearch/dataprepper/plugins/otel/codec/OTelLogsInputCodecConfig.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,34 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.dataprepper.plugins.otel.codec; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import jakarta.validation.constraints.AssertTrue; | ||
|
||
/** | ||
* Configuration class for {@link OTelLogsInputCodec}. | ||
*/ | ||
public class OTelLogsInputCodecConfig { | ||
static final String JSON_FORMAT = "json"; | ||
|
||
@JsonProperty("format") | ||
private String format = JSON_FORMAT; | ||
|
||
/** | ||
* The format of the OTel logs. | ||
* "json" by default. | ||
* @return The OTel logs format. | ||
*/ | ||
public String getFormat() { | ||
return format; | ||
} | ||
|
||
@AssertTrue(message = "format must be json.") | ||
boolean isValidFormat() { | ||
return JSON_FORMAT.equals(format); | ||
} | ||
|
||
} |
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