Skip to content

Commit

Permalink
Update Prepper plugins to use Processor (opensearch-project#1686)
Browse files Browse the repository at this point in the history
* Update prepper to processor for StringPrepper
* Update prepper to processor for GrokPrepper
* Update prepper to processor for OTelTraceGroupPrepper
* Update prepper to processor for OTelTraceRawPrepper
* Update prepper to processor for NoOpPrepper
* Update prepper to processor in readme files

Signed-off-by: Hai Yan <[email protected]>
  • Loading branch information
oeyh authored and engechas committed Sep 12, 2022
1 parent f298605 commit 9074a22
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@

import com.amazon.dataprepper.model.annotations.DataPrepperPlugin;
import com.amazon.dataprepper.model.event.Event;
import com.amazon.dataprepper.model.prepper.Prepper;
import com.amazon.dataprepper.model.processor.Processor;
import com.amazon.dataprepper.model.record.Record;

import java.util.Collection;

@DataPrepperPlugin(name = "no-op", pluginType = Prepper.class)
@DataPrepperPlugin(name = "no-op", pluginType = Processor.class)
public class NoOpPrepper implements Processor<Record<Event>, Record<Event>> {

public NoOpPrepper() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import com.amazon.dataprepper.model.configuration.PluginSetting;
import com.amazon.dataprepper.model.event.Event;
import com.amazon.dataprepper.model.event.JacksonEvent;
import com.amazon.dataprepper.model.prepper.Prepper;
import com.amazon.dataprepper.model.processor.Processor;
import com.amazon.dataprepper.model.record.Record;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
Expand All @@ -24,11 +24,11 @@
import java.util.stream.Collectors;

/**
* An simple String implementation of {@link Prepper} which generates new Records with upper case or lowercase content. The current
* A simple String implementation of {@link Processor} which generates new Records with uppercase or lowercase content. The current
* simpler implementation does not handle errors (if any).
*/
@DataPrepperPlugin(name = "string_converter", pluginType = Prepper.class, pluginConfigurationType = StringPrepper.Configuration.class)
public class StringPrepper implements Prepper<Record<Event>, Record<Event>> {
@DataPrepperPlugin(name = "string_converter", pluginType = Processor.class, pluginConfigurationType = StringPrepper.Configuration.class)
public class StringPrepper implements Processor<Record<Event>, Record<Event>> {
private static Logger LOG = LoggerFactory.getLogger(StringPrepper.class);
private final ObjectMapper objectMapper = new ObjectMapper();
private final TypeReference<Map<String, Object>> mapTypeReference = new TypeReference<Map<String, Object>>() {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import com.amazon.dataprepper.model.annotations.SingleThread;
import com.amazon.dataprepper.model.configuration.PluginSetting;
import com.amazon.dataprepper.model.event.Event;
import com.amazon.dataprepper.model.prepper.AbstractPrepper;
import com.amazon.dataprepper.model.prepper.Prepper;
import com.amazon.dataprepper.model.processor.AbstractProcessor;
import com.amazon.dataprepper.model.processor.Processor;
import com.amazon.dataprepper.model.record.Record;
import io.micrometer.core.instrument.Counter;
import io.micrometer.core.instrument.Timer;
Expand Down Expand Up @@ -52,8 +52,8 @@


@SingleThread
@DataPrepperPlugin(name = "grok", pluginType = Prepper.class)
public class GrokPrepper extends AbstractPrepper<Record<Event>, Record<Event>> {
@DataPrepperPlugin(name = "grok", pluginType = Processor.class)
public class GrokPrepper extends AbstractProcessor<Record<Event>, Record<Event>> {

private static final Logger LOG = LoggerFactory.getLogger(GrokPrepper.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

import com.amazon.dataprepper.model.annotations.DataPrepperPlugin;
import com.amazon.dataprepper.model.configuration.PluginSetting;
import com.amazon.dataprepper.model.prepper.AbstractPrepper;
import com.amazon.dataprepper.model.prepper.Prepper;
import com.amazon.dataprepper.model.processor.AbstractProcessor;
import com.amazon.dataprepper.model.processor.Processor;
import com.amazon.dataprepper.model.record.Record;
import com.amazon.dataprepper.plugins.prepper.oteltracegroup.model.TraceGroup;
import com.fasterxml.jackson.core.JsonProcessingException;
Expand Down Expand Up @@ -42,8 +42,8 @@
import java.util.Set;
import java.util.stream.Stream;

@DataPrepperPlugin(name = "otel_trace_group_prepper", pluginType = Prepper.class)
public class OTelTraceGroupPrepper extends AbstractPrepper<Record<String>, Record<String>> {
@DataPrepperPlugin(name = "otel_trace_group_prepper", pluginType = Processor.class)
public class OTelTraceGroupPrepper extends AbstractProcessor<Record<String>, Record<String>> {

public static final String RECORDS_IN_MISSING_TRACE_GROUP = "recordsInMissingTraceGroup";
public static final String RECORDS_OUT_FIXED_TRACE_GROUP = "recordsOutFixedTraceGroup";
Expand Down
2 changes: 1 addition & 1 deletion data-prepper-plugins/otel-trace-raw-prepper/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ prepper:
* `trace_flush_interval`: An `int` represents the time interval in seconds to flush all the descendant spans without any root span. Default to 180.

## Metrics
Apart from common metrics in [AbstractPrepper](https://github.com/opensearch-project/data-prepper/blob/main/data-prepper-api/src/main/java/com/amazon/dataprepper/model/prepper/AbstractPrepper.java), otel-trace-raw-prepper introduces the following custom metrics.
Apart from common metrics in [AbstractProcessor](https://github.com/opensearch-project/data-prepper/blob/main/data-prepper-api/src/main/java/com/amazon/dataprepper/model/processor/AbstractProcessor.java), otel-trace-raw-prepper introduces the following custom metrics.

### Counter
- `spanProcessingErrors`: records the number of processing exceptions for invalid spans.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

import com.amazon.dataprepper.model.annotations.DataPrepperPlugin;
import com.amazon.dataprepper.model.configuration.PluginSetting;
import com.amazon.dataprepper.model.prepper.AbstractPrepper;
import com.amazon.dataprepper.model.prepper.Prepper;
import com.amazon.dataprepper.model.processor.AbstractProcessor;
import com.amazon.dataprepper.model.processor.Processor;
import com.amazon.dataprepper.model.record.Record;
import com.amazon.dataprepper.plugins.prepper.oteltrace.model.OTelProtoHelper;
import com.amazon.dataprepper.plugins.prepper.oteltrace.model.RawSpan;
Expand Down Expand Up @@ -39,8 +39,8 @@
import java.util.concurrent.locks.ReentrantLock;


@DataPrepperPlugin(name = "otel_trace_raw_prepper", pluginType = Prepper.class)
public class OTelTraceRawPrepper extends AbstractPrepper<Record<ExportTraceServiceRequest>, Record<String>> {
@DataPrepperPlugin(name = "otel_trace_raw_prepper", pluginType = Processor.class)
public class OTelTraceRawPrepper extends AbstractProcessor<Record<ExportTraceServiceRequest>, Record<String>> {
private static final long SEC_TO_MILLIS = 1_000L;
private static final Logger LOG = LoggerFactory.getLogger(OTelTraceRawPrepper.class);

Expand Down
2 changes: 1 addition & 1 deletion data-prepper-plugins/service-map-stateful/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ processor:
* window_duration(Optional) => An `int` represents the fixed time window in seconds to evaluate service-map relationships. Default is ```180```.

## Metrics
Besides common metrics in [AbstractPrepper](https://github.com/opensearch-project/data-prepper/blob/main/data-prepper-api/src/main/java/com/amazon/dataprepper/model/prepper/AbstractPrepper.java), service-map-stateful prepper introduces the following custom metrics.
Besides common metrics in [AbstractProcessor](https://github.com/opensearch-project/data-prepper/blob/main/data-prepper-api/src/main/java/com/amazon/dataprepper/model/processor/AbstractProcessor.java), service-map-stateful prepper introduces the following custom metrics.

### Gauge
- `spansDbSize`: measures total spans byte sizes in MapDB across the current and previous window durations.
Expand Down

0 comments on commit 9074a22

Please sign in to comment.