Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically set time on WritePoint #342

Open
shreyas44 opened this issue Jul 14, 2022 · 5 comments
Open

Automatically set time on WritePoint #342

shreyas44 opened this issue Jul 14, 2022 · 5 comments

Comments

@shreyas44
Copy link

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:

  • NewPoint or NewPointWithMeasurement could automatically set the time to the current time

Use case:
Make it a little less verbose to write points and stop failing silently

@vlastahajek
Copy link
Contributor

@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?

@shreyas44
Copy link
Author

shreyas44 commented Jul 14, 2022

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?

@vlastahajek
Copy link
Contributor

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.

@shreyas44
Copy link
Author

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.

@shreyas44
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants