Skip to content

Commit

Permalink
Addressed review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Krishna Kondaka <[email protected]>
  • Loading branch information
Krishna Kondaka committed Aug 16, 2023
1 parent b4ad42e commit a4968ef
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.opensearch.dataprepper.plugins.otel.codec.OTelProtoCodec;
import org.opensearch.dataprepper.model.event.Event;
import org.opensearch.dataprepper.model.event.JacksonEvent;
import org.opensearch.dataprepper.model.trace.Span;
import org.opensearch.dataprepper.plugins.processor.aggregate.AggregateAction;
import org.opensearch.dataprepper.plugins.processor.aggregate.AggregateActionInput;
import org.opensearch.dataprepper.plugins.processor.aggregate.AggregateActionOutput;
Expand Down Expand Up @@ -64,11 +65,18 @@ private long getTimeNanos(Instant time) {
public Exemplar createExemplar(final Event event) {
long curTimeNanos = getTimeNanos(Instant.now());
Map<String, Object> attributes = event.toMap();
String spanId = null;
String traceId = null;
if (event instanceof Span) {
Span span = (Span)event;
spanId = span.getSpanId();
traceId = span.getTraceId();
}
return new DefaultExemplar(
OTelProtoCodec.convertUnixNanosToISO8601(curTimeNanos),
1.0,
event.get("spanId", String.class), // maybe null
event.get("traceId", String.class), // maybe null
spanId,
traceId,
attributes);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.opensearch.dataprepper.model.metric.JacksonHistogram;
import org.opensearch.dataprepper.model.metric.Bucket;
import org.opensearch.dataprepper.model.metric.Exemplar;
import org.opensearch.dataprepper.model.trace.Span;
import org.opensearch.dataprepper.model.metric.DefaultExemplar;
import org.opensearch.dataprepper.model.annotations.DataPrepperPlugin;
import org.opensearch.dataprepper.model.annotations.DataPrepperPluginConstructor;
Expand Down Expand Up @@ -114,12 +115,19 @@ public Exemplar createExemplar(final String id, final Event event, double value)
long curTimeNanos = getTimeNanos(Instant.now());
Map<String, Object> attributes = event.toMap();
if (Objects.nonNull(id)) {
attributes.put("exemplar_id", id);
attributes.put("exemplarId", id);
}
String spanId = null;
String traceId = null;
if (event instanceof Span) {
Span span = (Span)event;
spanId = span.getSpanId();
traceId = span.getTraceId();
}
return new DefaultExemplar(OTelProtoCodec.convertUnixNanosToISO8601(curTimeNanos),
value,
event.get("spanId", String.class), // maybe null
event.get("traceId", String.class), // maybe null
spanId,
traceId,
attributes);
}

Expand Down

0 comments on commit a4968ef

Please sign in to comment.