1
0
Fork 0

Added integration support for DataDog APM Tracing

This commit is contained in:
Alex Antonov 2018-06-28 11:40:04 -05:00 committed by Traefiker Bot
parent ba8c9295ac
commit 3192307d59
61 changed files with 9999 additions and 5 deletions

View file

@ -0,0 +1,35 @@
package tracer
import (
"log"
"time"
"golang.org/x/sys/windows"
)
// This method is more precise than the go1.8 time.Now on Windows
// See https://msdn.microsoft.com/en-us/library/windows/desktop/hh706895(v=vs.85).aspx
// It is however ~10x slower and requires Windows 8+.
func highPrecisionNow() int64 {
var ft windows.Filetime
windows.GetSystemTimePreciseAsFileTime(&ft)
return ft.Nanoseconds()
}
func lowPrecisionNow() int64 {
return time.Now().UTC().UnixNano()
}
var now func() int64
// If GetSystemTimePreciseAsFileTime is not available we default to the less
// precise implementation based on time.Now()
func init() {
if err := windows.LoadGetSystemTimePreciseAsFileTime(); err != nil {
log.Printf("Unable to load high precison timer, defaulting to time.Now()")
now = lowPrecisionNow
} else {
log.Printf("Using high precision timer")
now = highPrecisionNow
}
}