influxdb-client-go
influxdb-client-go copied to clipboard
Automatically set time on WritePoint
Proposal:
Automatically set the time to the current time in write.Point if the time hasn't already been set when a call to writeAPI.WritePoint is made
Current behavior:
The time is assumed to be zero and writes to influxdb silently fail when SetTime isn't used
Desired behavior:
Automatically set the time to the current time in write.Point if the time hasn't already been set
Alternatives considered:
NewPointorNewPointWithMeasurementcould automatically set the time to the current time
Use case: Make it a little less verbose to write points and stop failing silently
@shreyas44, thanks for using this client. When the timestamp is not set, a timestamp is not added to the line protocol, and the server assigns timestamps automatically. If you set the log level to Debug (3), the log will show what is exactly sent.
Why do you think write silently fails?
How are you checking data is written?
When the timestamp is not set, a timestamp is not added to the line protocol, and the server assigns timestamps automatically.
Oh I see, didn't know that.
How are you checking data is written?
I write a bunch of points (~1000) to influxdb over a couple of seconds and count the number of results in the last few minutes using flux. The count is usually in single digits. Maybe if I don't check for points within a time period, I should see the expected 1000?
When you write a batch of points without timestamp and several points have the same tags, it can happen that the server will assign the same timestamp because the highest resolution is nanoseconds. It can lead to overwriting of points. Try assigning different timestamps.
When you write a batch of points without timestamp and several points have the same tags, it can happen that the server will assign the same timestamp because the highest resolution is nanoseconds. It can lead to overwriting of points.
You might be right. This issue doesn't pop up when writing each point synchronously without explicitly setting the time.
I still think it'd be a good idea to automatically set the time to the current time in write.Point if the time hasn't already been set when a call to writeAPI.WritePoint is made. It seems like a better default than the current behaviour which can yield unexpected results.