Skip to content

Commit

Permalink
Use standard way to convert from time.Time to proto Timestamp (#2548)
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
  • Loading branch information
bogdandrutu authored Mar 5, 2021
1 parent 8b68f72 commit 040c856
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 4 deletions.
3 changes: 2 additions & 1 deletion exporter/carbonexporter/exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import (
"go.opentelemetry.io/collector/testutil/metricstestutil"
"go.opentelemetry.io/collector/translator/internaldata"
"go.uber.org/zap"
"google.golang.org/protobuf/types/known/timestamppb"
)

func TestNew(t *testing.T) {
Expand Down Expand Up @@ -299,7 +300,7 @@ func generateLargeBatch() pdata.Metrics {
time.Now(),
[]string{"v0", "v1"},
&metricspb.Point{
Timestamp: metricstestutil.Timestamp(ts),
Timestamp: timestamppb.New(ts),
Value: &metricspb.Point_Int64Value{Int64Value: int64(i)},
},
),
Expand Down
1 change: 1 addition & 0 deletions exporter/carbonexporter/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ require (
go.opentelemetry.io/collector v0.21.1-0.20210303005052-9c476019fc0f
go.uber.org/zap v1.16.0
google.golang.org/grpc/examples v0.0.0-20200728194956-1c32b02682df // indirect
google.golang.org/protobuf v1.25.0
)
3 changes: 2 additions & 1 deletion exporter/carbonexporter/metricdata_to_plaintext_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/testutil/metricstestutil"
"go.opentelemetry.io/collector/translator/internaldata"
"google.golang.org/protobuf/types/known/timestamppb"
)

func Test_sanitizeTagKey(t *testing.T) {
Expand Down Expand Up @@ -154,7 +155,7 @@ func Test_metricDataToPlaintext(t *testing.T) {
int64Val := int64(123)
expectedInt64ValStr := "123"
int64Pt := &metricspb.Point{
Timestamp: metricstestutil.Timestamp(tsUnix),
Timestamp: timestamppb.New(tsUnix),
Value: &metricspb.Point_Int64Value{Int64Value: int64Val},
}

Expand Down
3 changes: 2 additions & 1 deletion exporter/splunkhecexporter/exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import (
"go.opentelemetry.io/collector/translator/conventions"
"go.opentelemetry.io/collector/translator/internaldata"
"go.uber.org/zap"
"google.golang.org/protobuf/types/known/timestamppb"

"github.com/open-telemetry/opentelemetry-collector-contrib/internal/splunk"
)
Expand Down Expand Up @@ -181,7 +182,7 @@ func generateLargeBatch() internaldata.MetricsData {
time.Now(),
[]string{"v0", "v1"},
&metricspb.Point{
Timestamp: metricstestutil.Timestamp(ts),
Timestamp: timestamppb.New(ts),
Value: &metricspb.Point_Int64Value{Int64Value: int64(i)},
},
),
Expand Down
1 change: 1 addition & 0 deletions exporter/splunkhecexporter/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ require (
go.opentelemetry.io/collector v0.21.1-0.20210303005052-9c476019fc0f
go.uber.org/zap v1.16.0
google.golang.org/grpc/examples v0.0.0-20200728194956-1c32b02682df // indirect
google.golang.org/protobuf v1.25.0

)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/golang/protobuf/ptypes/timestamp"
"go.opentelemetry.io/collector/testutil/metricstestutil"
"go.opentelemetry.io/collector/translator/internaldata"
"google.golang.org/protobuf/types/known/timestamppb"
)

// GenerateDummyMetrics generates two dummy metrics
Expand All @@ -46,7 +47,7 @@ func createGaugeIntMetric(i int) *metricspb.Metric {
time.Now(),
[]string{"label_value_0", "label_value_1"},
&metricspb.Point{
Timestamp: metricstestutil.Timestamp(ts),
Timestamp: timestamppb.New(ts),
Value: &metricspb.Point_Int64Value{Int64Value: int64(i)},
},
),
Expand Down
1 change: 1 addition & 0 deletions receiver/awsecscontainermetricsreceiver/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ require (
github.com/stretchr/testify v1.7.0
go.opentelemetry.io/collector v0.21.1-0.20210303005052-9c476019fc0f
go.uber.org/zap v1.16.0
google.golang.org/protobuf v1.25.0
)

0 comments on commit 040c856

Please sign in to comment.