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

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

The newest version!
package com.wavefront.ingester;

import wavefront.report.ReportMetric;

import javax.annotation.Nullable;
import java.util.List;
import java.util.function.Supplier;

/**
 * Graphite decoder that takes in a point of the type:
 *
 * [metric] [value] [timestamp] [annotations]
 *
 * @author Clement Pang ([email protected]).
 */
public class ReportMetricDecoder implements ReportableEntityDecoder {
  private static final AbstractIngesterFormatter FORMAT =
      ReportMetricIngesterFormatter.newBuilder().
          text(ReportMetric::setMetric).
          value(ReportMetric::setValue).
          optionalTimestamp(ReportMetric::setTimestamp).
          annotationList(ReportMetric::setAnnotations).
          build();
  private final Supplier hostNameSupplier;
  private List customSourceTags;

  public ReportMetricDecoder(@Nullable Supplier hostNameSupplier,
                             List customSourceTags) {
    this.hostNameSupplier = hostNameSupplier;
    this.customSourceTags = customSourceTags;
  }

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy