func()

in opentelemetry_collector/receiver/dockerstats/scraper.go [249:270]


func (s *scraper) readContainerInfo(ctx context.Context, id string) (containerInfo, error) {
	var info containerInfo

	c, err := s.docker.ContainerInspect(ctx, id)
	if err != nil {
		return info, fmt.Errorf("failed to retrieve container info: %v", err)
	}
	info.restartCount = int64(c.RestartCount)
	info.cpuLimit = c.HostConfig.NanoCPUs

	t, err := time.Parse(time.RFC3339Nano, c.State.StartedAt)
	if err != nil {
		return info, fmt.Errorf("failed to parse container start time (%s): %v", c.State.StartedAt, err)
	}
	now := s.now()
	if t.After(now) {
		return info, fmt.Errorf("invalid container start time %v, should be <= current time %v", t, now)
	}
	info.uptime = now.Sub(t)

	return info, nil
}