func (p *ACIProvider) GetStatsSummary(ctx context.Context) (summary *stats.Summary, err error) {
	ctx, span := trace.StartSpan(ctx, "GetSummaryStats")
	defer span.End()
	ctx = addAzureAttributes(ctx, span, p)
	p.metricsSync.Lock()
	defer p.metricsSync.Unlock()
	log.G(ctx).Debug("acquired metrics mutex")
	if time.Since(p.metricsSyncTime) < time.Minute {
		span.WithFields(ctx, log.Fields{
			"preCachedResult":        true,
			"cachedResultSampleTime": p.metricsSyncTime.String(),
		})
		return p.lastMetric, nil
	}
	ctx = span.WithFields(ctx, log.Fields{
		"preCachedResult":        false,
		"cachedResultSampleTime": p.metricsSyncTime.String(),
	})
	select {
	case <-ctx.Done():
		return nil, ctx.Err()
	default:
	}
	defer func() {
		if err != nil {
			return
		}
		p.lastMetric = summary
		p.metricsSyncTime = time.Now()
	}()
	pods := p.resourceManager.GetPods()
	var errGroup errgroup.Group
	chResult := make(chan stats.PodStats, len(pods))
	end := time.Now()
	start := end.Add(-1 * time.Minute)
	sema := make(chan struct{}, 10)
	for _, pod := range pods {
		if pod.Status.Phase != v1.PodRunning {
			continue
		}
		pod := pod
		errGroup.Go(func() error {
			ctx, span := trace.StartSpan(ctx, "getPodMetrics")
			defer span.End()
			logger := log.G(ctx).WithFields(log.Fields{
				"UID":       string(pod.UID),
				"Name":      pod.Name,
				"Namespace": pod.Namespace,
			})
			select {
			case <-ctx.Done():
				return ctx.Err()
			case sema <- struct{}{}:
			}
			defer func() {
				<-sema
			}()
			logger.Debug("Acquired semaphore")
			cgName := containerGroupName(pod.Namespace, pod.Name)
			systemStats, err := p.aciClient.GetContainerGroupMetrics(ctx, p.resourceGroup, cgName, aci.MetricsRequest{
				Dimension:    "containerName eq '*'",
				Start:        start,
				End:          end,
				Aggregations: []aci.AggregationType{aci.AggregationTypeAverage},
				Types:        []aci.MetricType{aci.MetricTypeCPUUsage, aci.MetricTypeMemoryUsage},
			})
			if err != nil {
				span.SetStatus(err)
				return errors.Wrapf(err, "error fetching cpu/mem stats for container group %s", cgName)
			}
			logger.Debug("Got system stats")
			netStats, err := p.aciClient.GetContainerGroupMetrics(ctx, p.resourceGroup, cgName, aci.MetricsRequest{
				Start:        start,
				End:          end,
				Aggregations: []aci.AggregationType{aci.AggregationTypeAverage},
				Types:        []aci.MetricType{aci.MetricTyperNetworkBytesRecievedPerSecond, aci.MetricTyperNetworkBytesTransmittedPerSecond},
			})
			if err != nil {
				span.SetStatus(err)
				return errors.Wrapf(err, "error fetching network stats for container group %s", cgName)
			}
			logger.Debug("Got network stats")
			chResult <- collectMetrics(pod, systemStats, netStats)
			return nil
		})
	}
	if err := errGroup.Wait(); err != nil {
		span.SetStatus(err)
		return nil, errors.Wrap(err, "error in request to fetch container group metrics")
	}
	close(chResult)
	log.G(ctx).Debugf("Collected status from azure for %d pods", len(pods))
	var s stats.Summary
	s.Node = stats.NodeStats{
		NodeName: p.nodeName,
	}
	s.Pods = make([]stats.PodStats, 0, len(chResult))
	for stat := range chResult {
		s.Pods = append(s.Pods, stat)
	}
	return &s, nil
}
GetStatsSummary returns the stats summary for pods running on ACI
package provider
import (
	"context"
	"strings"
	"time"
	"github.com/pkg/errors"
	"github.com/virtual-kubelet/azure-aci/client/aci"
	"github.com/virtual-kubelet/virtual-kubelet/log"
	"github.com/virtual-kubelet/virtual-kubelet/trace"
	"golang.org/x/sync/errgroup"
	v1 "k8s.io/api/core/v1"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	stats "github.com/virtual-kubelet/virtual-kubelet/node/api/statsv1alpha1"
)