Skip to content

Commit

Permalink
[receiver/fluentforward] Add case to handle uint64 timestamp (#13868)
Browse files Browse the repository at this point in the history
case added to handle uint64 timestamp
  • Loading branch information
bhogayatakb authored Sep 29, 2022
1 parent 0388916 commit d6c3f1a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
2 changes: 2 additions & 0 deletions receiver/fluentforwardreceiver/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ func parseToAttributeValue(val interface{}, dest pcommon.Value) {

func timeFromTimestamp(ts interface{}) (time.Time, error) {
switch v := ts.(type) {
case uint64:
return time.Unix(int64(v), 0), nil
case int64:
return time.Unix(v, 0), nil
case *eventTimeExt:
Expand Down
11 changes: 0 additions & 11 deletions receiver/fluentforwardreceiver/conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,17 +165,6 @@ func TestMessageEventConversionWithErrors(t *testing.T) {
require.NotNil(t, err)
})
}

t.Run("Invalid timestamp type uint", func(t *testing.T) {
in := make([]byte, len(b))
copy(in, b)
in[8] = 0xcd
reader := msgp.NewReader(bytes.NewReader(in))

var event MessageEventLogRecord
err := event.DecodeMsg(reader)
require.NotNil(t, err)
})
}

func TestForwardEventConversionWithErrors(t *testing.T) {
Expand Down
16 changes: 16 additions & 0 deletions unreleased/fluentforwardreceiver-uint64-fix.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: bug_fix

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: fluentforwardreceiver

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: added case to handle uint64 timestamp

# One or more tracking issues related to the change
issues: [ 11435 ]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

0 comments on commit d6c3f1a

Please sign in to comment.