You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feature: createSpan should use event time instead of processing time #126
There may be micro difference betweentime.Now() and the time when connection closed, the former is the processing time, and the latter is the event time. The duration between these two timestamps is used for agent handling.
Here is my idea.
eBPF program can get the time since boot, by calling bpf_ktime_get_boot_ns. We can record it as event_ktime.
GoLang program can also get the time since boot, by wrapping the clock_gettime syscall. We can record it as process_ktime. Here is a GoLang demo:
func getMonotonicTime() {
const CLOCK_MONOTONIC = 1 // CLOCK_MONOTONIC is the identifier for the monotonic clock in Linux.
var ts syscall.Timespec
_, _, errCode := syscall.Syscall(syscall.SYS_CLOCK_GETTIME, CLOCK_MONOTONIC, uintptr(unsafe.Pointer(&ts)), 0)
if errCode != 0 {
fmt.Printf("Failed to call SYS_CLOCK_GETTIME.\n")
return
}
fmt.Printf("Monotonic time since boot is: %d seconds, %d nanoseconds.\n", ts.Sec, ts.Nsec)
duration, err := time.ParseDuration(fmt.Sprintf("%ds%dns", ts.Sec, ts.Nsec))
if err != nil {
return
}
fmt.Printf("That's about %d minutes\n", int(duration.Minutes()))
}
Obviously GoLang program can get the well clock time through the now() function. We can record it as process_time.
So the accurate well clock time when l7_event emitted from the tracepiont event_time = process_time - process_ktime + event_ktime.
Activity
StLeoX commentedon Nov 28, 2024
Here is my idea.
eBPF program can get the time since boot, by calling
bpf_ktime_get_boot_ns. We can record it asevent_ktime.GoLang program can also get the time since boot, by wrapping the
clock_gettimesyscall. We can record it asprocess_ktime. Here is a GoLang demo:Obviously GoLang program can get the well clock time through the
now()function. We can record it asprocess_time.So the accurate well clock time when
l7_eventemitted from the tracepiontevent_time = process_time - process_ktime + event_ktime.