-
Notifications
You must be signed in to change notification settings - Fork 825
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
How to represent timestamps? #19
Comments
More granularity better :) I would go with something that has ns but not available us is good. |
Another option is to use a tuple type of |
Here is a quick summary of the differences between a
What is the use case for granularity higher than 0.2µs? |
In general I think I would vote for a tuple representation internally and accept both a tuple or a |
To clarify my above comment, the |
One of the weirdnesses with using |
In any case we would always have 0.2µs precision since the result from |
Well, to convert a Anyway, I'm fine with epoch millis everywhere and I think I'm convinced we should just go with that for simplicity. |
This would mean a change of how the time is reported though. It means I think it's worth a discussion if that makes high precision possible with |
This was discussed at today's SIG meeting, and for now a This is (potentially) temporary however and we still need to discuss what would be the best approach. One discussion that probably needs to happen in the specification repository first is whether |
Opened open-telemetry/opentelemetry-specification#139 to discuss end time VS duration and making the timestamps available on the cross-language API. |
I like the idea of just picking epoch millis and moving on for now. But to clarify a bit of what I meant - what I was envisioning was that both the start and end times would be in Only when they need to be converted to epoch timestamps when sent to an exporter would they become 0.2 microsecond accuracy relative to the epoch, but they would still all be nanosecond-accuracy relative to each other (true for both start and end times and for trace annotations). By making storing start time and duration, we make the end time be nanosecond precise, but the start time is still just the 0.2 microsecond precision relative to other spans/events in the process for the request (portion of the overall trace). |
I like this idea a lot. However, this may not be possible in other languages. How should this be described in the spec? |
Well, most other languages just have nice nanosecond-level timestamps, or at least native 64-bit ints that could make representing a nanosecond-level epoch time easy :( If we were going to write something in the specs for this, my sense would be to say that implementations may choose to use a monotonic clock timestamp for span start/end times and event times if that helps improve accuracy or ease of use. So that for Node/browser we could use the One thing we could also do is keep the |
Closed via #206 |
The OpenCensus Node project used
Date
for span start/end times (code link). That has the downside of only only having millisecond accuracy. OpenTracing JS usesnumber
for milliseconds since the epoch (code link), which currently has ~microsecond accuracy - you can confirm that by testingDate.now() + 0.001
vs.Date.now() + 0.0001
.I think microsecond accuracy is pretty good, but perhaps for some high performance processes you might want higher accuracy, and I think since we are designing this from the ground up, we should ask the question.
Here's an alternative: we use timestamps from the
performance.now()
clock, which Node 8+ supports, and which also has broad browser support even from IE 10+.Those timestamps can have nanosecond accuracy for processes that have been running for less than about 90 days (try running
90*365*24*3600*1000 + 1e-6
to check the accuracy).We would need to convert those timestamps into a format that the exporter expects in a careful way to preserve the accuracy, see for example [this function]
(https://github.com/census-instrumentation/opencensus-web/blob/82464ed231ad829a7a8a72eab17e95577aa813d0/packages/opencensus-web-core/src/common/time-util.ts#L37) that converts a high-accuracy
performance.now
timestamp and a high-accuracy origin time into a nano-second accuracy ISO date string.If we just want to do
number
as millis since the epoch, I'm fine with that too! But wanted to at least open this for discussion. I think use ofperformance.now
as a clock function would be nice either way since it's one less incompatibility between Node and the browser we have to think about.The text was updated successfully, but these errors were encountered: