Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
### New features

### Enhancements
- Rename the camera profiling file to make the timestamp of the profiling files readable. ([#434](https://github.com/KindlingProject/kindling/pull/434))
- When using the file writer in `cameraexporter`, we rotate files in chronological order now and rotate half of files one time. ([#420](https://github.com/KindlingProject/kindling/pull/420))
- Support to identify the MySQL protocol with statements `commit` and `set`. ([#417](https://github.com/KindlingProject/kindling/pull/417))

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package cameraexporter

import (
"strconv"
"time"
)

func getDateString(timestamp int64) string {
timeUnix := time.Unix(0, timestamp)
year, month, day := timeUnix.Date()
hour, minute, second := timeUnix.Clock()
nano := timestamp % 1e9
return dateToString(year) + dateToString(int(month)) + dateToString(day) +
dateToString(hour) + dateToString(minute) + dateToString(second) +
"." + dateToString(int(nano))
}

func dateToString(date int) string {
if date >= 0 && date <= 9 {
return "0" + strconv.FormatInt(int64(date), 10)
} else {
return strconv.FormatInt(int64(date), 10)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package cameraexporter

import (
"testing"

"github.com/stretchr/testify/assert"
)

func TestGetDateString(t *testing.T) {
nanoseconds := 1672887314101975422
dateString := getDateString(int64(nanoseconds))
assert.Equal(t, "20230105105514.101975422", dateString)
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func getFileName(protocol string, contentKey string, timestamp uint64, isServer
isServerString = "false"
}
encodedContent := base64.URLEncoding.EncodeToString([]byte(contentKey))
return protocol + "_" + encodedContent + "_" + strconv.FormatUint(timestamp, 10) + "_" + isServerString
return getDateString(int64(timestamp)) + "_" + protocol + "_" + encodedContent + "_" + isServerString
}

func (fw *fileWriter) writeTrace(group *model.DataGroup) {
Expand Down