@@ -38,21 +38,22 @@ type sampleBuilder struct {
3838// the remainder of the input.
3939func (b * sampleBuilder ) next (ctx context.Context , samples []tsdb.RefSample ) (* monitoring_pb.TimeSeries , uint64 , []tsdb.RefSample , error ) {
4040 sample := samples [0 ]
41+ tailSamples := samples [1 :]
4142
4243 entry , ok , err := b .series .get (ctx , sample .Ref )
4344 if err != nil {
4445 return nil , 0 , samples , errors .Wrap (err , "get series information" )
4546 }
4647 if ! ok {
47- return nil , 0 , samples [ 1 :] , nil
48+ return nil , 0 , tailSamples , nil
4849 }
4950
5051 if entry .tracker != nil {
5152 entry .tracker .newPoint (ctx , entry .lset , sample .T , sample .V )
5253 }
5354
5455 if ! entry .exported {
55- return nil , 0 , samples [ 1 :] , nil
56+ return nil , 0 , tailSamples , nil
5657 }
5758 // Get a shallow copy of the proto so we can overwrite the point field
5859 // and safely send it into the remote queues.
@@ -72,7 +73,7 @@ func (b *sampleBuilder) next(ctx context.Context, samples []tsdb.RefSample) (*mo
7273 var v float64
7374 resetTimestamp , v , ok = b .series .getResetAdjusted (sample .Ref , sample .T , sample .V )
7475 if ! ok {
75- return nil , 0 , samples [ 1 :] , nil
76+ return nil , 0 , tailSamples , nil
7677 }
7778 point .Interval .StartTime = getTimestamp (resetTimestamp )
7879 point .Value = & monitoring_pb.TypedValue {Value : & monitoring_pb.TypedValue_DoubleValue {v }}
@@ -86,46 +87,45 @@ func (b *sampleBuilder) next(ctx context.Context, samples []tsdb.RefSample) (*mo
8687 var v float64
8788 resetTimestamp , v , ok = b .series .getResetAdjusted (sample .Ref , sample .T , sample .V )
8889 if ! ok {
89- return nil , 0 , samples [ 1 :] , nil
90+ return nil , 0 , tailSamples , nil
9091 }
9192 point .Interval .StartTime = getTimestamp (resetTimestamp )
9293 point .Value = & monitoring_pb.TypedValue {Value : & monitoring_pb.TypedValue_DoubleValue {v }}
9394 case metricSuffixCount :
9495 var v float64
9596 resetTimestamp , v , ok = b .series .getResetAdjusted (sample .Ref , sample .T , sample .V )
9697 if ! ok {
97- return nil , 0 , samples [ 1 :] , nil
98+ return nil , 0 , tailSamples , nil
9899 }
99100 point .Interval .StartTime = getTimestamp (resetTimestamp )
100101 point .Value = & monitoring_pb.TypedValue {Value : & monitoring_pb.TypedValue_Int64Value {int64 (v )}}
101102 case "" : // Actual quantiles.
102103 point .Value = & monitoring_pb.TypedValue {Value : & monitoring_pb.TypedValue_DoubleValue {sample .V }}
103104 default :
104- return nil , 0 , samples [ 1 :] , errors .Errorf ("unexpected metric name suffix %q" , entry .suffix )
105+ return nil , 0 , tailSamples , errors .Errorf ("unexpected metric name suffix %q" , entry .suffix )
105106 }
106107
107108 case textparse .MetricTypeHistogram :
108109 // We pass in the original lset for matching since Prometheus's target label must
109110 // be the same as well.
110111 var v * distribution_pb.Distribution
111- v , resetTimestamp , samples , err = b .buildDistribution (ctx , entry .metadata .Metric , entry .lset , samples )
112+ v , resetTimestamp , tailSamples , err = b .buildDistribution (ctx , entry .metadata .Metric , entry .lset , samples )
112113 if v == nil || err != nil {
113- return nil , 0 , samples , err
114+ return nil , 0 , tailSamples , err
114115 }
115116 point .Interval .StartTime = getTimestamp (resetTimestamp )
116117 point .Value = & monitoring_pb.TypedValue {
117118 Value : & monitoring_pb.TypedValue_DistributionValue {v },
118119 }
119- return & ts , 0 , samples , nil
120120
121121 default :
122122 return nil , 0 , samples [1 :], errors .Errorf ("unexpected metric type %s" , entry .metadata .Type )
123123 }
124124
125125 if ! b .series .updateSampleInterval (entry .hash , resetTimestamp , sample .T ) {
126- return nil , 0 , samples [ 1 :] , nil
126+ return nil , 0 , tailSamples , nil
127127 }
128- return & ts , entry .hash , samples [ 1 :] , nil
128+ return & ts , entry .hash , tailSamples , nil
129129}
130130
131131const (
0 commit comments