-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Increase domain for model.TimeAsEpochMicroseconds #730
Conversation
589e8f3
to
4bd8e2d
Compare
On another note, what do you think about also adding warnings when converting representation formats (model to thrift/ thrift to model, etc) when current time and span time differ by more than a week? |
Use `time.Unix()` instead of `time.UnixNano()` when the input exceeds the domain of `time.UnixNano()` Signed-off-by: Prithvi Raj <p.r@uber.com>
4bd8e2d
to
d26d691
Compare
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.
Yes, having a warning for this would be SUPER useful so that we can catch the evil doers who do this
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.
+1 to Won's comment - not good to silently change the data. The cause of the issue seems to be bad instrumentation clients that are sending invalid micros, so best way would be to handle this on ingestion and try to recover (the value is most likely 1000x than needed), as well as capture a warning in the span.
// represented by an int64(less than year 1678 or greater than year 2262) | ||
return uint64(t.UnixNano() / 1000) | ||
} | ||
return uint64(t.Unix() * 1e6) |
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.
not sure I follow - doesn't this just truncate to full seconds? Isn't there a way to retrieve the sub-second digits, maybe without using UnixNanos()?
@@ -26,7 +26,12 @@ func EpochMicrosecondsAsTime(ts uint64) time.Time { | |||
// TimeAsEpochMicroseconds converts time.Time to microseconds since epoch, | |||
// which is the format the StartTime field is stored in the Span. | |||
func TimeAsEpochMicroseconds(t time.Time) uint64 { | |||
return uint64(t.UnixNano() / 1000) | |||
if t.Year() > 1678 && t.Year() < 2262 { |
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.
if y := t.Year(); y > 1678 && y < 2262 {}
@vprithvi could you please push the branch to your fork and remove this branch? |
Use
time.Unix()
instead oftime.UnixNano()
when the input exceeds the domain oftime.UnixNano()
Signed-off-by: Prithvi Raj p.r@uber.com