datadog: time_util portion of new tracing library#25003
Conversation
Signed-off-by: David Goffredo <david.goffredo@datadoghq.com>
Signed-off-by: David Goffredo <david.goffredo@datadoghq.com>
|
CC @envoyproxy/dependency-shepherds: Your approval is needed for changes made to |
|
/assign @jmarantz |
|
dgoffredo is not allowed to assign users. |
Signed-off-by: David Goffredo <david.goffredo@datadoghq.com>
jmarantz
left a comment
There was a problem hiding this comment.
lgtm mostly with some minor comments. still need to read the test.
| // specified `SystemTime`. Use the optionally specified | ||
| // `datadog::tracing::Clock` to read the current time. If a clock is not | ||
| // specified, then the default clock is used. | ||
| datadog::tracing::TimePoint estimateTime(SystemTime); |
There was a problem hiding this comment.
is this an estimate really? or are we just converting a SystemTime to a DataDog time?
Would it be clearer at call-sites to call this convertSystemTimeToDataDog() ?
There was a problem hiding this comment.
Yes, it's an estimate. The background is explained here as part of the original pull request (that readme will be added again in a subsequent pull request).
Envoy has a time type that, like Go's, contains both a system time point and a steady ("monotonic") time point. However, only the system time is exposed to the tracing subsystem. Not sure why.
This is problematic for the new library (dd-trace-cpp), because it uses the steady time to calculate the duration of a span (end.tick - begin.tick). So, we need to get a steady clock time from a given system clock time. The scheme is to measure the current system/steady time, compare the system part with the given system time, and then adjust the measured steady time accordingly. This is correct if the system clock has not been adjusted since the given system time was measured. It's incorrect otherwise, hence an estimate.
What do you think about all this? Is there a better way?
There was a problem hiding this comment.
sgtm thanks. The above explanation might be good to throw into the code here as a comment.
Signed-off-by: David Goffredo <david.goffredo@datadoghq.com>
jmarantz
left a comment
There was a problem hiding this comment.
looks pretty good. It'd be good to understand if we can just use MonotonicTime if that's what we need.
| datadog::tracing::TimePoint estimateTime(SystemTime wall, const datadog::tracing::Clock& clock) { | ||
| datadog::tracing::TimePoint point = clock(); | ||
| if (point.wall > wall) { | ||
| point.tick -= point.wall - wall; |
There was a problem hiding this comment.
should we also verify that the delta we are subtracting is less than point.tick?
There was a problem hiding this comment.
point.tick is a time point, while point.wall - wall is a duration, so no.
| namespace Tracers { | ||
| namespace Datadog { | ||
|
|
||
| datadog::tracing::TimePoint estimateTime(SystemTime wall) { |
There was a problem hiding this comment.
why are we not plumbing the MonotonicTime (or maybe just the TimeSource into here?
There was a problem hiding this comment.
The goal is to implement the interfaces defined in https://github.com/envoyproxy/envoy/blob/main/envoy/tracing/trace_driver.h.
There are two time points in those interfaces: Span::spawnChild and Driver::startSpan. Both take SystemTime only, without a monotonic counterpart.
If I were redesigning the interface, I would have spawnChild and startSpan take both a SystemTime and a MonotonicTime, and additionally have finishSpan take a MonotonicTime (or both, but at least the MonotonicTime).
I thought it would be inappropriate to propose to change the interface and everything that implements it.
What do you think?
There was a problem hiding this comment.
I think it's fine to push forward with this but we should also try to correct the API to get the best results. It's not that hard to change these APIs; there's probably not that much fallout, particularly if you just plumb through some additional fields and don't remove the SystemTime.
jmarantz
left a comment
There was a problem hiding this comment.
/assign-from @envoyproxy/senior-maintainers
|
@envoyproxy/senior-maintainers assignee is @yanavlasov |
|
/assign |
Signed-off-by: David Goffredo <david.goffredo@datadoghq.com>
Head branch was pushed to by a user without write access
|
/retest |
|
Retrying Azure Pipelines: |
|
I could write a test for that overload. Will do this tomorrow. |
|
/wait |
Signed-off-by: David Goffredo <david.goffredo@datadoghq.com>
|
/retest |
|
Retrying Azure Pipelines: |
|
Thanks @yanavlasov @jmarantz |
* datadog: time_util without tests Signed-off-by: David Goffredo <david.goffredo@datadoghq.com>

This is part of the initiative described in #23958.
This revision introduces a new library dependency for Datadog tracing, and adds a small component that will be used in the future when more of the new library is integrated into the Datadog tracing extension.