-
Notifications
You must be signed in to change notification settings - Fork 20
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
feature/add_influx_timestamp #24
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,10 +17,21 @@ defmodule Fluxter.Packet do | |
] | ||
end | ||
|
||
def build(header, name, tags, fields) do | ||
def build(header, name, tags, fields, unix_timestamp_ms) do | ||
tags = encode_tags(tags) | ||
fields = encode_fields(fields) | ||
[header, encode_key(name), tags, ?\s, fields] | ||
|
||
case is_nil(unix_timestamp_ms) do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jbavari then why not use |
||
true -> [header, encode_key(name), tags, ?\s, fields] | ||
false -> | ||
# Convert time to nanoseconds, which is the precision influxdb uses | ||
unix_timestamp_nano_secs = unix_timestamp_ms | ||
|> Kernel.*(1_000_000) | ||
|> Integer.to_string() | ||
|
||
[header, encode_key(name), tags, ?\s, fields, ?\s, | ||
unix_timestamp_nano_secs] | ||
end | ||
end | ||
|
||
defp encode_tags([]), do: "" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be a braking change. Why not add default value for
timestamp_milli_secs
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hauleth is right—we need to have a default value, otherwise all existing code will be broken.