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

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

The newest version!
package com.wavefront.ingester;

import java.util.Collections;
import java.util.List;
import java.util.function.Supplier;

import wavefront.report.ReportMetric;

/**
 * Decoder for WFTop data format (Spy API stream):
 *
 * [metric] source=[source] [timestamp] [value] [annotations]
 *
 * @author [email protected]
 */
public class SpyApiMetricDecoder implements ReportableEntityDecoder {
  private static final AbstractIngesterFormatter FORMAT =
      ReportMetricIngesterFormatter.newBuilder().
          text(ReportMetric::setMetric).
          annotationList(ReportMetric::setAnnotations, 1).
          timestamp(ReportMetric::setTimestamp).
          value(ReportMetric::setValue).
          annotationList(ReportMetric::getAnnotations, ReportMetric::setAnnotations).
          build();
  private final Supplier hostNameSupplier = () -> "default";

  @Override
  public void decode(String msg, List out, String customerId, IngesterContext ctx) {
    ReportMetric point = FORMAT.drive(msg, hostNameSupplier, customerId, Collections.emptyList(),null, null,
            null, null, null, null,  ctx);
    if (out != null) {
      out.add(point);
    }
  }

  @Override
  public void decode(String msg, List out) {
    throw new UnsupportedOperationException("Extracting customer ID is not supported!");
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy