code: func exportTimestampedAggregationValue(values []core.TimestampedAggregationValue) types.MetricAggregationResult {
  	result := types.MetricAggregationResult{
  		Buckets:    make([]types.MetricAggregationBucket, 0, len(values)),
  		BucketSize: 0,
  	}
  	for _, value := range values {
  		// just use the largest bucket size, since all bucket sizes should be uniform
  		// (except for the last one, which may be smaller)
  		if result.BucketSize < value.BucketSize {
  			result.BucketSize = value.BucketSize
  		}
  
  		bucket := types.MetricAggregationBucket{
  			Timestamp: value.Timestamp,
  
  			Count: value.Count,
  
  			Average: extractMetricValue(&value.AggregationValue, core.AggregationTypeAverage),
  			Maximum: extractMetricValue(&value.AggregationValue, core.AggregationTypeMaximum),
  			Minimum: extractMetricValue(&value.AggregationValue, core.AggregationTypeMinimum),
  			Median:  extractMetricValue(&value.AggregationValue, core.AggregationTypeMedian),
  
  			Percentiles: make(map[string]types.MetricValue, 3),
  		}
  
  		if val, ok := value.Aggregations[core.AggregationTypePercentile50]; ok {
  			bucket.Percentiles["50"] = *exportMetricValue(&val)
  		}
  		if val, ok := value.Aggregations[core.AggregationTypePercentile95]; ok {
  			bucket.Percentiles["95"] = *exportMetricValue(&val)
  		}
  		if val, ok := value.Aggregations[core.AggregationTypePercentile99]; ok {
  			bucket.Percentiles["99"] = *exportMetricValue(&val)
  		}
  
  		result.Buckets = append(result.Buckets, bucket)
  	}
  	return result
  }
docs: // exportTimestampedAggregationValue converts a core.TimestampedAggregationValue into an API MetricAggregationResult