process: fix windows_process_start_time_seconds_timestamp return relative time on Windows Server 2019 (#2137)

This commit is contained in:
Jan-Otto Kröpke
2025-07-20 02:14:17 +02:00
committed by GitHub
parent 255b01f610
commit f0591d85cd

View File

@@ -144,7 +144,12 @@ func (c *Collector) collectWorker() {
name, pidString, parentPID, strconv.Itoa(int(processGroupID)), processOwner, cmdLine,
)
startTime := float64(time.Now().UnixMicro())/1e6 - data.ElapsedTime
startTime := data.ElapsedTime
if c.config.CounterVersion == 2 {
// For V2, the ElapsedTime is in seconds, so we need to convert it to a timestamp.
// The start time is the current time minus the elapsed time.
startTime = float64(time.Now().UnixMicro())/1e6 - data.ElapsedTime
}
ch <- prometheus.MustNewConstMetric(
c.startTime,