MCPcopy
hub / github.com/prometheus/prometheus / sampleCount

Function sampleCount

storage/remote/write_otlp_handler_test.go:676–707  ·  view source on GitHub ↗
(md pmetric.Metrics)

Source from the content-addressed store, hash-verified

674}
675
676func sampleCount(md pmetric.Metrics) int {
677 var total int
678 rms := md.ResourceMetrics()
679 for i := range rms.Len() {
680 sms := rms.At(i).ScopeMetrics()
681 for i := range sms.Len() {
682 ms := sms.At(i).Metrics()
683 for i := range ms.Len() {
684 m := ms.At(i)
685 switch m.Type() {
686 case pmetric.MetricTypeSum:
687 total += m.Sum().DataPoints().Len()
688 case pmetric.MetricTypeGauge:
689 total += m.Gauge().DataPoints().Len()
690 case pmetric.MetricTypeHistogram:
691 dps := m.Histogram().DataPoints()
692 for i := range dps.Len() {
693 total += dps.At(i).BucketCounts().Len()
694 total++ // le=+Inf series
695 total++ // _sum series
696 total++ // _count series
697 }
698 case pmetric.MetricTypeExponentialHistogram:
699 total += m.ExponentialHistogram().DataPoints().Len()
700 case pmetric.MetricTypeSummary:
701 total += m.Summary().DataPoints().Len()
702 }
703 }
704 }
705 }
706 return total
707}
708
709func TestOTLPInstrumentedAppendable(t *testing.T) {
710 t.Run("no problems", func(t *testing.T) {

Callers 1

BenchmarkOTLPFunction · 0.85

Calls 4

LenMethod · 0.65
AtMethod · 0.65
TypeMethod · 0.65
HistogramMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…