当前位置: 首页>>代码示例>>Java>>正文


Java MetricDatum.setDimensions方法代码示例

本文整理汇总了Java中com.amazonaws.services.cloudwatch.model.MetricDatum.setDimensions方法的典型用法代码示例。如果您正苦于以下问题:Java MetricDatum.setDimensions方法的具体用法?Java MetricDatum.setDimensions怎么用?Java MetricDatum.setDimensions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.amazonaws.services.cloudwatch.model.MetricDatum的用法示例。


在下文中一共展示了MetricDatum.setDimensions方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: makeDatum

import com.amazonaws.services.cloudwatch.model.MetricDatum; //导入方法依赖的package包/类
private MetricDatum makeDatum(
        final String id,
        final String name,
        final double sum,
        final double min,
        final double max,
        final int count,
        final StandardUnit unit)
{
    MetricDatum md = new MetricDatum().withMetricName(name).withUnit(unit);

    final StatisticSet statSet = new StatisticSet()
            .withSampleCount(Double.valueOf(count))
            .withSum(sum)
            .withMinimum(min)
            .withMaximum(max);
    md.setStatisticValues(statSet);

    List<Dimension> dimensions = new ArrayList<>(1);
    Dimension trace = new Dimension().withName(ContextData.ID.name).withValue(id);

    dimensions.add(trace);
    md.setDimensions(dimensions);

    return md;
}
 
开发者ID:awslabs,项目名称:swage,代码行数:27,代码来源:CloudWatchRecorderTest.java

示例2: getDatum

import com.amazonaws.services.cloudwatch.model.MetricDatum; //导入方法依赖的package包/类
public MetricDatum getDatum() {
    MetricDatum md = new MetricDatum();
    md.setMetricName(name);
    md.setUnit(unit);
    md.setDimensions(dimensions);
    return md;
}
 
开发者ID:awslabs,项目名称:swage,代码行数:8,代码来源:MetricDataAggregator.java

示例3: write

import com.amazonaws.services.cloudwatch.model.MetricDatum; //导入方法依赖的package包/类
@Override
public void write(ArrayList<Stat> stats, long invokeTimeMs, Set<Tag> tags) {
  Date dt = new Date();
  dt.setTime(invokeTimeMs);

  Collection<Dimension> parentDims = tagsToDimensions(tags);
  List<MetricDatum> metrics = new ArrayList<MetricDatum>();

  /*
   * Create CW metric objects from bender internal Stat objects
   */
  for (Stat stat : stats) {
    /*
     * Dimension are CW's version of metric tags. A conversion must be done.
     */
    Collection<Dimension> metricDims = tagsToDimensions(stat.getTags());
    metricDims.addAll(parentDims);

    MetricDatum metric = new MetricDatum();
    metric.setMetricName(stat.getName());
    // TODO: add units to Stat object SYSTEMS-870
    metric.setUnit(StandardUnit.None);
    metric.setTimestamp(dt);
    metric.setDimensions(metricDims);
    metric.setValue((double) stat.getValue());

    metrics.add(metric);
  }

  /*
   * Not very well documented in java docs but CW only allows 20 metrics at a time.
   */
  List<List<MetricDatum>> chunks = ListUtils.partition(metrics, 20);
  for (List<MetricDatum> chunk : chunks) {
    PutMetricDataRequest req = new PutMetricDataRequest();
    req.withMetricData(chunk);
    req.setNamespace(namespace);

    this.client.putMetricData(req);
  }
}
 
开发者ID:Nextdoor,项目名称:bender,代码行数:42,代码来源:CloudwatchReporter.java


注:本文中的com.amazonaws.services.cloudwatch.model.MetricDatum.setDimensions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。