Skip to content

Commit 0a8a1dc

Browse files
authored
Cleanup usage of TimestampUnixNanos and its API (#2549)
Updates #2488 Important Changes: * Rename pdata.TimestampUnixNanos to pdata.Timestamp * Remove pdata.TimestampUnixNanos and helpers, move them of the pdata.Timestamp type. * Fix bug around IsZero, this function should return true if the time is January 1, year 1, 00:00:00 UTC not epoch. Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
1 parent b613d21 commit 0a8a1dc

File tree

70 files changed

+336
-374
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+336
-374
lines changed

cmd/pdatagen/internal/base_fields.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ func (pf *primitiveField) generateCopyToValue(sb *strings.Builder) {
240240

241241
var _ baseField = (*primitiveField)(nil)
242242

243-
// Types that has defined a custom type (e.g. "type TimestampUnixNano uint64")
243+
// Types that has defined a custom type (e.g. "type Timestamp uint64")
244244
type primitiveTypedField struct {
245245
fieldName string
246246
originFieldName string

cmd/pdatagen/internal/common_structs.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,28 +75,28 @@ var instrumentationLibraryField = &messageValueField{
7575
var startTimeField = &primitiveTypedField{
7676
fieldName: "StartTime",
7777
originFieldName: "StartTimeUnixNano",
78-
returnType: "TimestampUnixNano",
78+
returnType: "Timestamp",
7979
rawType: "uint64",
80-
defaultVal: "TimestampUnixNano(0)",
81-
testVal: "TimestampUnixNano(1234567890)",
80+
defaultVal: "Timestamp(0)",
81+
testVal: "Timestamp(1234567890)",
8282
}
8383

8484
var timeField = &primitiveTypedField{
8585
fieldName: "Timestamp",
8686
originFieldName: "TimeUnixNano",
87-
returnType: "TimestampUnixNano",
87+
returnType: "Timestamp",
8888
rawType: "uint64",
89-
defaultVal: "TimestampUnixNano(0)",
90-
testVal: "TimestampUnixNano(1234567890)",
89+
defaultVal: "Timestamp(0)",
90+
testVal: "Timestamp(1234567890)",
9191
}
9292

9393
var endTimeField = &primitiveTypedField{
9494
fieldName: "EndTime",
9595
originFieldName: "EndTimeUnixNano",
96-
returnType: "TimestampUnixNano",
96+
returnType: "Timestamp",
9797
rawType: "uint64",
98-
defaultVal: "TimestampUnixNano(0)",
99-
testVal: "TimestampUnixNano(1234567890)",
98+
defaultVal: "Timestamp(0)",
99+
testVal: "Timestamp(1234567890)",
100100
}
101101

102102
var attributes = &sliceField{

cmd/pdatagen/internal/log_structs.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@ var logRecord = &messageValueStruct{
8888
&primitiveTypedField{
8989
fieldName: "Timestamp",
9090
originFieldName: "TimeUnixNano",
91-
returnType: "TimestampUnixNano",
91+
returnType: "Timestamp",
9292
rawType: "uint64",
93-
defaultVal: "TimestampUnixNano(0)",
94-
testVal: "TimestampUnixNano(1234567890)",
93+
defaultVal: "Timestamp(0)",
94+
testVal: "Timestamp(1234567890)",
9595
},
9696
traceIDField,
9797
spanIDField,

consumer/pdata/common.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,10 @@ package pdata
1919

2020
import (
2121
"sort"
22-
"time"
2322

2423
otlpcommon "go.opentelemetry.io/collector/internal/data/protogen/common/v1"
2524
)
2625

27-
// TimestampUnixNano is a time specified as UNIX Epoch time in nanoseconds since
28-
// 00:00:00 UTC on 1 January 1970.
29-
type TimestampUnixNano uint64
30-
31-
func (ts TimestampUnixNano) String() string {
32-
return time.Unix(0, int64(ts)).String()
33-
}
34-
3526
// AttributeValueType specifies the type of AttributeValue.
3627
type AttributeValueType int
3728

consumer/pdata/generated_log.go

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

consumer/pdata/generated_log_test.go

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

consumer/pdata/generated_metrics.go

Lines changed: 36 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)