All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.wavefront.ingester.EventDecoder Maven / Gradle / Ivy

package com.wavefront.ingester;

import com.google.common.collect.ImmutableList;
import wavefront.report.ReportEvent;

import java.util.List;

import static com.wavefront.ingester.AbstractIngesterFormatter.EVENT_LITERAL;

/**
 * Event decoder that takes in data in the following format:
 *
 * { @Event } startTimeMillis [endTimeMillis] eventName [annotations]
 *
 * @author [email protected]
 */
public class EventDecoder implements ReportableEntityDecoder {

  private static final AbstractIngesterFormatter FORMAT =
      EventIngesterFormatter.newBuilder().
          caseSensitiveLiterals(ImmutableList.of(EVENT_LITERAL)).
          timestamp(ReportEvent::setStartTime).
          optionalTimestamp(ReportEvent::setEndTime).
          text(ReportEvent::setName).
          annotationMultimap(ReportEvent::setDimensions).
          build();

  @Override
  public void decode(String msg, List out, String customerId, IngesterContext ctx) {
    ReportEvent event = FORMAT.drive(msg, null, "default", null, null, null, null, null,null, null, ctx);
    if (out != null) {
      out.add(event);
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy