From 4a163beaa103fd57b4cf6e07dc19781ab2fda4a9 Mon Sep 17 00:00:00 2001 From: Tyler Yahn Date: Tue, 23 Feb 2021 11:38:23 -0800 Subject: [PATCH] Fix stdout TestStdoutTimestamp failure with sleep (#1572) * Fix stdout TestStdoutTimestamp failure with sleep Ensure the test condition is valid by introducing minimal sleep durations before and after a timestamp is measured. Resolves #1571 * Add changes to changelog Co-authored-by: Anthony Mirabella --- CHANGELOG.md | 4 ++++ exporters/stdout/metric_test.go | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d94d7fdedf..c5739741d35 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - Removed attempt to resample spans upon changing the span name with `span.SetName()`. (#1545) +### Fixed + +- The sequential timing check of timestamps in the stdout exporter are now setup explicitly to be sequential (#1571). (#1572) + ## [0.17.0] - 2020-02-12 ### Changed diff --git a/exporters/stdout/metric_test.go b/exporters/stdout/metric_test.go index 43e8aee9597..af390a73c04 100644 --- a/exporters/stdout/metric_test.go +++ b/exporters/stdout/metric_test.go @@ -85,6 +85,8 @@ func TestStdoutTimestamp(t *testing.T) { } before := time.Now() + // Ensure the timestamp is after before. + time.Sleep(time.Nanosecond) checkpointSet := metrictest.NewCheckpointSet(testResource) @@ -102,6 +104,8 @@ func TestStdoutTimestamp(t *testing.T) { t.Fatal("Unexpected export error: ", err) } + // Ensure the timestamp is before after. + time.Sleep(time.Nanosecond) after := time.Now() var printed []interface{}