@@ -17,11 +17,13 @@ package stackdriver
1717import  (
1818	"context" 
1919	"fmt" 
20+ 	"math" 
2021	"strings" 
2122	"testing" 
2223
2324	resourcepb "github.com/census-instrumentation/opencensus-proto/gen-go/resource/v1" 
2425	"github.com/golang/protobuf/ptypes/timestamp" 
26+ 	promvalue "github.com/prometheus/prometheus/model/value" 
2527	"google.golang.org/api/option" 
2628	distributionpb "google.golang.org/genproto/googleapis/api/distribution" 
2729	labelpb "google.golang.org/genproto/googleapis/api/label" 
@@ -367,6 +369,35 @@ func TestProtoMetricToCreateTimeSeriesRequest(t *testing.T) {
367369				},
368370			},
369371		},
372+ 		{
373+ 			name : "Test staleness marker is skipped" ,
374+ 			in : & metricspb.Metric {
375+ 				MetricDescriptor : & metricspb.MetricDescriptor {
376+ 					Name :        "with_metric_descriptor_2" ,
377+ 					Description : "This is a test" ,
378+ 					Unit :        "By" ,
379+ 					LabelKeys :   []* metricspb.LabelKey {{Key : "key1" }, {Key : "key2" }, {Key : "key3" }},
380+ 				},
381+ 				Timeseries : []* metricspb.TimeSeries {
382+ 					{
383+ 						StartTimestamp : startTimestamp ,
384+ 						LabelValues :    []* metricspb.LabelValue {{}, {}, {HasValue : true , Value : "val3" }},
385+ 						Points : []* metricspb.Point {
386+ 							{
387+ 								Timestamp : endTimestamp ,
388+ 								Value : & metricspb.Point_DoubleValue {
389+ 									DoubleValue : math .Float64frombits (promvalue .StaleNaN ),
390+ 								},
391+ 							},
392+ 						},
393+ 					},
394+ 				},
395+ 			},
396+ 			statsExporter : & statsExporter {
397+ 				o : Options {ProjectID : "foo" , MapResource : DefaultMapResource },
398+ 			},
399+ 			want : nil ,
400+ 		},
370401	}
371402
372403	seenResources  :=  make (map [* resourcepb.Resource ]* monitoredrespb.MonitoredResource )
@@ -762,6 +793,20 @@ func TestProtoMetricsToMonitoringMetrics_fromProtoPoint(t *testing.T) {
762793				},
763794			},
764795		},
796+ 		{
797+ 			in : & metricspb.Point {
798+ 				Timestamp : endTimestamp ,
799+ 				Value :     & metricspb.Point_Int64Value {Int64Value : int64 (math .Float64frombits (promvalue .StaleNaN ))},
800+ 			},
801+ 			want : nil ,
802+ 		},
803+ 		{
804+ 			in : & metricspb.Point {
805+ 				Timestamp : endTimestamp ,
806+ 				Value :     & metricspb.Point_DoubleValue {DoubleValue : math .Float64frombits (promvalue .StaleNaN )},
807+ 			},
808+ 			want : nil ,
809+ 		},
765810	}
766811
767812	for  i , tt  :=  range  tests  {
0 commit comments