Skip to content

Commit

Permalink
[ClickHouse org] Prevent inserting logs with timestamp=epoch
Browse files Browse the repository at this point in the history
When the pipeline fails to parse a timestamp, just use the observed timestamp rather than 1970
  • Loading branch information
RoryCrispin committed Jan 10, 2024
1 parent 2a5822e commit 8ef725a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion exporter/clickhouseexporter/exporter_logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,12 @@ func (e *logsExporter) pushLogsData(ctx context.Context, ld plog.Logs) error {
for k := 0; k < rs.Len(); k++ {
r := rs.At(k)
logAttr := attributesToMap(r.Attributes())
insertTimestamp := r.Timestamp()
if insertTimestamp == 0 {
insertTimestamp = r.ObservedTimestamp()
}
_, err = statement.ExecContext(ctx,
r.Timestamp().AsTime(),
insertTimestamp.AsTime(),
traceutil.TraceIDToHexOrEmptyString(r.TraceID()),
traceutil.SpanIDToHexOrEmptyString(r.SpanID()),
uint32(r.Flags()),
Expand Down

0 comments on commit 8ef725a

Please sign in to comment.