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

Increase domain for model.TimeAsEpochMicroseconds #730

Closed
wants to merge 1 commit into from

Conversation

vprithvi
Copy link
Contributor

@vprithvi vprithvi commented Mar 7, 2018

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

@vprithvi
Copy link
Contributor Author

vprithvi commented Mar 7, 2018

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>
@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling d26d691 on support-large-time into cce04e7 on master.

Copy link
Contributor

@black-adder black-adder left a 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

Copy link
Member

@yurishkuro yurishkuro left a 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)
Copy link
Member

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 {
Copy link
Member

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 {}

@pavolloffay
Copy link
Member

@vprithvi could you please push the branch to your fork and remove this branch?

@vprithvi vprithvi closed this Mar 2, 2020
@vprithvi vprithvi deleted the support-large-time branch March 2, 2020 13:40
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

Successfully merging this pull request may close these issues.

5 participants