func()

in components/google-built-opentelemetry-collector/exporter/googleservicecontrolexporter/exporter.go [385:419]


func (e *MetricsExporter) createNumericMetricValues(points pmetric.NumberDataPointSlice, aggr pmetric.AggregationTemporality) ([]*scpb.MetricValue, time.Time) {
	var earliestStart time.Time
	ret := make([]*scpb.MetricValue, points.Len())

	for i := 0; i < points.Len(); i++ {
		point := points.At(i)
		start := point.StartTimestamp().AsTime()
		end := point.Timestamp().AsTime()

		start, end = e.getStartEndTimes(aggr, start, end)

		if earliestStart.IsZero() || start.Before(earliestStart) {
			earliestStart = start
		}

		mv := &scpb.MetricValue{
			Labels:    attributesToStringMap(point.Attributes()),
			StartTime: timestamppb.New(start),
			EndTime:   timestamppb.New(end),
		}

		switch point.ValueType() {
		case pmetric.NumberDataPointValueTypeInt:
			v := point.IntValue()
			mv.Value = &scpb.MetricValue_Int64Value{v}
		case pmetric.NumberDataPointValueTypeDouble:
			v := point.DoubleValue()
			mv.Value = &scpb.MetricValue_DoubleValue{v}
		}

		ret[i] = mv
	}

	return ret, earliestStart
}