[FEATURE] memory usage #108

Closed
opened 2024-09-16 15:28:20 +03:00 by vtolstov · 2 comments
Owner
ROUTINE ======================== go.unistack.org/micro-meter-prometheus/v3.(*prometheusMeter).Counter in go.unistack.org/micro-meter-prometheus/v3@v3.8.11/prometheus.go
  321.07MB   878.48MB (flat, cum)  2.54% of Total
         .          .    123:func (m *prometheusMeter) Counter(name string, labels ...string) meter.Counter {
         .   512.05kB    124:	m.Lock()
         .          .    125:	defer m.Unlock()
         .    41.50MB    126:	nm := m.buildName(name)
  320.57MB   770.13MB    127:	labels = m.buildLabels(append(m.opts.Labels, labels...)...) // TODO: Read prometheus.go:128
         .          .    128:	vcd, ok := m.counter.Load(nm)
         .       31MB    129:	h := newHash(labels)
         .          .    130:	if !ok {
         .          .    131:		cd := &counters{cs: &sync.Map{}}
         .          .    132:		c := &prometheusCounter{c: prometheus.NewGauge(prometheus.GaugeOpts{Name: nm}), labels: labels}
         .          .    133:		cd.cs.Store(h, c)
         .          .    134:		m.counter.Store(nm, cd)
         .          .    135:		return c
         .          .    136:	}
         .          .    137:	cd := vcd.(*counters)
         .          .    138:	vc, ok := cd.cs.Load(h)
         .          .    139:	if !ok {
  512.02kB   512.02kB    140:		c := &prometheusCounter{c: prometheus.NewGauge(prometheus.GaugeOpts{Name: nm}), labels: labels}
         .    34.85MB    141:		cd.cs.Store(h, c)
         .          .    142:		m.counter.Store(nm, cd)
         .          .    143:		return c
         .          .    144:	}
         .          .    145:	c := vc.(*prometheusCounter)
         .          .    146:	return c
ROUTINE ======================== go.unistack.org/micro-meter-prometheus/v3.(*prometheusMeter).Histogram in go.unistack.org/micro-meter-prometheus/v3@v3.8.11/prometheus.go
  219.55MB   537.58MB (flat, cum)  1.55% of Total
         .          .    201:func (m *prometheusMeter) Histogram(name string, labels ...string) meter.Histogram {
         .          .    202:	m.Lock()
         .          .    203:	defer m.Unlock()
         .    45.50MB    204:	nm := m.buildName(name)
  219.55MB   472.58MB    205:	labels = m.buildLabels(append(m.opts.Labels, labels...)...)
         .          .    206:	vcd, ok := m.histogram.Load(nm)
         .    19.50MB    207:	h := newHash(labels)
         .          .    208:	if !ok {
         .          .    209:		cd := &histograms{cs: &sync.Map{}}
         .          .    210:		c := &prometheusHistogram{c: prometheus.NewHistogram(prometheus.HistogramOpts{Name: nm}), labels: labels}
         .          .    211:		cd.cs.Store(h, c)
         .          .    212:		m.histogram.Store(nm, cd)
ROUTINE ======================== go.unistack.org/micro-meter-prometheus/v3.(*prometheusMeter).Summary in go.unistack.org/micro-meter-prometheus/v3@v3.8.11/prometheus.go
  211.05MB   506.58MB (flat, cum)  1.46% of Total
         .          .    227:func (m *prometheusMeter) Summary(name string, labels ...string) meter.Summary {
         .          .    228:	m.Lock()
         .          .    229:	defer m.Unlock()
         .    30.50MB    230:	nm := m.buildName(name)
  211.05MB   457.58MB    231:	labels = m.buildLabels(append(m.opts.Labels, labels...)...)
         .          .    232:	vcd, ok := m.summary.Load(nm)
         .    18.50MB    233:	h := newHash(labels)
         .          .    234:	if !ok {
         .          .    235:		cd := &summaries{cs: &sync.Map{}}
         .          .    236:		c := &prometheusSummary{c: prometheus.NewSummary(prometheus.SummaryOpts{Name: nm}), labels: labels}
         .          .    237:		cd.cs.Store(h, c)
         .          .    238:		m.summary.Store(nm, cd)
ROUTINE ======================== go.unistack.org/micro-meter-prometheus/v3.(*prometheusMeter).Write in go.unistack.org/micro-meter-prometheus/v3@v3.8.11/prometheus.go
         0   929.79MB (flat, cum)  2.69% of Total
         .          .    302:func (m *prometheusMeter) Write(w io.Writer, opts ...meter.Option) error {
         .          .    303:	options := m.opts
         .          .    304:	for _, o := range opts {
         .          .    305:		o(&options)
         .          .    306:	}
         .          .    307:
         .          .    308:	g, ok := m.set.(prometheus.Gatherer)
         .          .    309:	if !ok {
         .          .    310:		return fmt.Errorf("set type %T not prometheus.Gatherer", m.set)
         .          .    311:	}
         .          .    312:
         .    13.60MB    313:	mfs, err := g.Gather()
         .          .    314:	if err != nil {
         .          .    315:		return err
         .          .    316:	}
         .          .    317:
         .          .    318:	enc := expfmt.NewEncoder(w, expfmt.NewFormat(expfmt.TypeTextPlain))
         .          .    319:
         .   493.01MB    320:	m.counter.Range(func(k, v any) bool {
         .          .    321:		name := k.(string)
         .          .    322:		mf := &dto.MetricFamily{
         .          .    323:			Name: newString(name),
         .          .    324:			Type: dto.MetricType_GAUGE.Enum(),
         .          .    325:		}
         .          .    326:		v.(*counters).cs.Range(func(_, nv any) bool {
         .          .    327:			c := nv.(*prometheusCounter)
         .          .    328:			m := &dto.Metric{}
         .          .    329:			_ = c.c.Write(m)
         .          .    330:			fillMetric(m, c.labels)
         .          .    331:			mf.Metric = append(mf.Metric, m)
         .          .    332:			return true
         .          .    333:		})
         .          .    334:		mfs = append(mfs, mf)
         .          .    335:		return true
         .          .    336:	})
         .          .    337:
         .          .    338:	m.gauge.Range(func(k, v any) bool {
         .          .    339:		name := k.(string)
         .          .    340:		mf := &dto.MetricFamily{
         .          .    341:			Name: newString(name),
         .          .    342:			Type: dto.MetricType_GAUGE.Enum(),
         .          .    343:		}
         .          .    344:		v.(*gauges).cs.Range(func(_, nv any) bool {
         .          .    345:			c := nv.(*prometheusGauge)
         .          .    346:			m := &dto.Metric{}
         .          .    347:			_ = c.c.Write(m)
         .          .    348:			fillMetric(m, c.labels)
         .          .    349:			mf.Metric = append(mf.Metric, m)
         .          .    350:			return true
         .          .    351:		})
         .          .    352:		mfs = append(mfs, mf)
         .          .    353:		return true
         .          .    354:	})
         .          .    355:
         .          .    356:	m.floatCounter.Range(func(k, v any) bool {
         .          .    357:		name := k.(string)
         .          .    358:		mf := &dto.MetricFamily{
         .          .    359:			Name: newString(name),
         .          .    360:			Type: dto.MetricType_GAUGE.Enum(),
         .          .    361:		}
         .          .    362:		v.(*floatCounters).cs.Range(func(_, nv any) bool {
         .          .    363:			c := nv.(*prometheusFloatCounter)
         .          .    364:			m := &dto.Metric{}
         .          .    365:			_ = c.c.Write(m)
         .          .    366:			fillMetric(m, c.labels)
         .          .    367:			mf.Metric = append(mf.Metric, m)
         .          .    368:			return true
         .          .    369:		})
         .          .    370:		mfs = append(mfs, mf)
         .          .    371:		return true
         .          .    372:	})
         .          .    373:
         .     7.50MB    374:	m.histogram.Range(func(k, v any) bool {
         .          .    375:		name := k.(string)
         .          .    376:		mf := &dto.MetricFamily{
         .          .    377:			Name: newString(name),
         .          .    378:			Type: dto.MetricType_HISTOGRAM.Enum(),
         .          .    379:		}
         .          .    380:		v.(*histograms).cs.Range(func(_, nv any) bool {
         .          .    381:			c := nv.(*prometheusHistogram)
         .          .    382:			m := &dto.Metric{}
         .          .    383:			_ = c.c.Write(m)
         .          .    384:			fillMetric(m, c.labels)
         .          .    385:			mf.Metric = append(mf.Metric, m)
         .          .    386:			return true
         .          .    387:		})
         .          .    388:		mfs = append(mfs, mf)
         .          .    389:		return true
         .          .    390:	})
         .          .    391:
         .     1.50MB    392:	m.summary.Range(func(k, v any) bool {
         .          .    393:		name := k.(string)
         .          .    394:		mf := &dto.MetricFamily{
         .          .    395:			Name: newString(name),
         .          .    396:			Type: dto.MetricType_SUMMARY.Enum(),
         .          .    397:		}
         .          .    398:		v.(*summaries).cs.Range(func(_, nv any) bool {
         .          .    399:			c := nv.(*prometheusSummary)
         .          .    400:			m := &dto.Metric{}
         .          .    401:			_ = c.c.Write(m)
         .          .    402:			fillMetric(m, c.labels)
         .          .    403:			mf.Metric = append(mf.Metric, m)
         .          .    404:			return true
         .          .    405:		})
         .          .    406:		mfs = append(mfs, mf)
         .          .    407:		return true
         .          .    408:	})
         .          .    409:
         .          .    410:	for _, mf := range mfs {
         .   414.18MB    411:		_ = enc.Encode(mf)
         .          .    412:	}
         .          .    413:
         .          .    414:	if closer, ok := enc.(io.Closer); ok {
         .          .    415:		_ = closer.Close()
         .          .    416:	}
ROUTINE ======================== go.unistack.org/micro-meter-prometheus/v3.(*prometheusMeter).Write.func1 in go.unistack.org/micro-meter-prometheus/v3@v3.8.11/prometheus.go
    1.50MB   493.01MB (flat, cum)  1.42% of Total
         .          .    320:	m.counter.Range(func(k, v any) bool {
         .          .    321:		name := k.(string)
  512.05kB   512.05kB    322:		mf := &dto.MetricFamily{
         .          .    323:			Name: newString(name),
         .          .    324:			Type: dto.MetricType_GAUGE.Enum(),
         .          .    325:		}
         .   491.51MB    326:		v.(*counters).cs.Range(func(_, nv any) bool {
         .          .    327:			c := nv.(*prometheusCounter)
         .          .    328:			m := &dto.Metric{}
         .          .    329:			_ = c.c.Write(m)
         .          .    330:			fillMetric(m, c.labels)
         .          .    331:			mf.Metric = append(mf.Metric, m)
         .          .    332:			return true
         .          .    333:		})
       1MB        1MB    334:		mfs = append(mfs, mf)
         .          .    335:		return true
         .          .    336:	})
         .          .    337:
         .          .    338:	m.gauge.Range(func(k, v any) bool {
         .          .    339:		name := k.(string)
ROUTINE ======================== go.unistack.org/micro-meter-prometheus/v3.(*prometheusMeter).Write.func1.1 in go.unistack.org/micro-meter-prometheus/v3@v3.8.11/prometheus.go
   91.49MB   491.51MB (flat, cum)  1.42% of Total
         .          .    326:		v.(*counters).cs.Range(func(_, nv any) bool {
         .          .    327:			c := nv.(*prometheusCounter)
   73.51MB    73.51MB    328:			m := &dto.Metric{}
         .    35.50MB    329:			_ = c.c.Write(m)
         .   364.52MB    330:			fillMetric(m, c.labels)
   17.98MB    17.98MB    331:			mf.Metric = append(mf.Metric, m)
         .          .    332:			return true
         .          .    333:		})
         .          .    334:		mfs = append(mfs, mf)
         .          .    335:		return true
         .          .    336:	})
ROUTINE ======================== go.unistack.org/micro-meter-prometheus/v3.(*prometheusMeter).Write.func4 in go.unistack.org/micro-meter-prometheus/v3@v3.8.11/prometheus.go
         0     7.50MB (flat, cum) 0.022% of Total
         .          .    374:	m.histogram.Range(func(k, v any) bool {
         .          .    375:		name := k.(string)
         .          .    376:		mf := &dto.MetricFamily{
         .          .    377:			Name: newString(name),
         .          .    378:			Type: dto.MetricType_HISTOGRAM.Enum(),
         .          .    379:		}
         .     7.50MB    380:		v.(*histograms).cs.Range(func(_, nv any) bool {
         .          .    381:			c := nv.(*prometheusHistogram)
         .          .    382:			m := &dto.Metric{}
         .          .    383:			_ = c.c.Write(m)
         .          .    384:			fillMetric(m, c.labels)
         .          .    385:			mf.Metric = append(mf.Metric, m)
ROUTINE ======================== go.unistack.org/micro-meter-prometheus/v3.(*prometheusMeter).Write.func4.1 in go.unistack.org/micro-meter-prometheus/v3@v3.8.11/prometheus.go
  512.05kB     7.50MB (flat, cum) 0.022% of Total
         .          .    380:		v.(*histograms).cs.Range(func(_, nv any) bool {
         .          .    381:			c := nv.(*prometheusHistogram)
  512.05kB   512.05kB    382:			m := &dto.Metric{}
         .     6.50MB    383:			_ = c.c.Write(m)
         .   512.03kB    384:			fillMetric(m, c.labels)
         .          .    385:			mf.Metric = append(mf.Metric, m)
         .          .    386:			return true
         .          .    387:		})
         .          .    388:		mfs = append(mfs, mf)
         .          .    389:		return true
ROUTINE ======================== go.unistack.org/micro-meter-prometheus/v3.(*prometheusMeter).Write.func5 in go.unistack.org/micro-meter-prometheus/v3@v3.8.11/prometheus.go
         0     1.50MB (flat, cum) 0.0043% of Total
         .          .    392:	m.summary.Range(func(k, v any) bool {
         .          .    393:		name := k.(string)
         .          .    394:		mf := &dto.MetricFamily{
         .          .    395:			Name: newString(name),
         .          .    396:			Type: dto.MetricType_SUMMARY.Enum(),
         .          .    397:		}
         .     1.50MB    398:		v.(*summaries).cs.Range(func(_, nv any) bool {
         .          .    399:			c := nv.(*prometheusSummary)
         .          .    400:			m := &dto.Metric{}
         .          .    401:			_ = c.c.Write(m)
         .          .    402:			fillMetric(m, c.labels)
         .          .    403:			mf.Metric = append(mf.Metric, m)
ROUTINE ======================== go.unistack.org/micro-meter-prometheus/v3.(*prometheusMeter).Write.func5.1 in go.unistack.org/micro-meter-prometheus/v3@v3.8.11/prometheus.go
  512.05kB     1.50MB (flat, cum) 0.0043% of Total
         .          .    398:		v.(*summaries).cs.Range(func(_, nv any) bool {
         .          .    399:			c := nv.(*prometheusSummary)
  512.05kB   512.05kB    400:			m := &dto.Metric{}
         .   512.05kB    401:			_ = c.c.Write(m)
         .   512.03kB    402:			fillMetric(m, c.labels)
         .          .    403:			mf.Metric = append(mf.Metric, m)
         .          .    404:			return true
         .          .    405:		})
         .          .    406:		mfs = append(mfs, mf)
         .          .    407:		return true
ROUTINE ======================== go.unistack.org/micro-meter-prometheus/v3.(*prometheusMeter).buildLabels in go.unistack.org/micro-meter-prometheus/v3@v3.8.11/prometheus.go
  949.12MB   949.12MB (flat, cum)  2.74% of Total
         .          .    104:func (m *prometheusMeter) buildLabels(labels ...string) []string {
         .          .    105:	nl := len(labels)
         .          .    106:	if nl == 0 {
         .          .    107:		return nil
         .          .    108:	}
         .          .    109:
  620.12MB   620.12MB    110:	nlabels := make([]string, 0, nl)
         .          .    111:
         .          .    112:	for idx := 0; idx < nl; idx += 2 {
  329.01MB   329.01MB    113:		nlabels = append(nlabels, m.opts.LabelPrefix+labels[idx])
         .          .    114:		nlabels = append(nlabels, labels[idx+1])
         .          .    115:	}
         .          .    116:	return nlabels
         .          .    117:}
         .          .    118:
ROUTINE ======================== go.unistack.org/micro-meter-prometheus/v3.(*prometheusMeter).buildName in go.unistack.org/micro-meter-prometheus/v3@v3.8.11/prometheus.go
  117.50MB   117.50MB (flat, cum)  0.34% of Total
         .          .     97:func (m *prometheusMeter) buildName(name string) string {
         .          .     98:	if len(m.opts.MetricPrefix) > 0 {
  117.50MB   117.50MB     99:		name = m.opts.MetricPrefix + name
         .          .    100:	}
         .          .    101:	return name
         .          .    102:}
         .          .    103:
         .          .    104:func (m *prometheusMeter) buildLabels(labels ...string) []string {
ROUTINE ======================== go.unistack.org/micro-meter-prometheus/v3.fillMetric in go.unistack.org/micro-meter-prometheus/v3@v3.8.11/prometheus.go
  262.52MB   365.52MB (flat, cum)  1.06% of Total
         .          .    560:func fillMetric(m *dto.Metric, labels []string) *dto.Metric {
         .          .    561:	var ok bool
         .          .    562:	seen := make(map[string]bool, len(labels)/2)
   33.50MB    33.50MB    563:	m.Label = make([]*dto.LabelPair, 0, len(labels)/2)
         .          .    564:	for idx := 0; idx < len(labels); idx += 2 {
         .          .    565:		if _, ok = seen[labels[idx]]; ok {
         .          .    566:			continue
         .          .    567:		}
  229.01MB   229.01MB    568:		m.Label = append(m.Label, &dto.LabelPair{
         .       50MB    569:			Name:  newString(labels[idx]),
         .       53MB    570:			Value: newString(labels[idx+1]),
         .          .    571:		})
         .          .    572:		seen[labels[idx]] = true
         .          .    573:	}
         .          .    574:	return m
         .          .    575:}
ROUTINE ======================== go.unistack.org/micro-meter-prometheus/v3.newHash in go.unistack.org/micro-meter-prometheus/v3@v3.8.11/prometheus.go
         0       69MB (flat, cum)   0.2% of Total
         .          .    551:func newHash(labels []string) uint64 {
         .       69MB    552:	labels = meter.BuildLabels(labels...)
         .          .    553:	h := fnv.New64a()
         .          .    554:	for _, l := range labels {
         .          .    555:		h.Write([]byte(l))
         .          .    556:	}
         .          .    557:	return h.Sum64()
ROUTINE ======================== go.unistack.org/micro-meter-prometheus/v3.newString in go.unistack.org/micro-meter-prometheus/v3@v3.8.11/prometheus.go
     103MB      103MB (flat, cum)   0.3% of Total
         .          .     56:func newString(v string) *string {
     103MB      103MB     57:	nv := v
         .          .     58:	return &nv
         .          .     59:}
         .          .     60:
         .          .     61:func NewMeter(opts ...meter.Option) *prometheusMeter {
         .          .     62:	return &prometheusMeter{

``` ROUTINE ======================== go.unistack.org/micro-meter-prometheus/v3.(*prometheusMeter).Counter in go.unistack.org/micro-meter-prometheus/v3@v3.8.11/prometheus.go 321.07MB 878.48MB (flat, cum) 2.54% of Total . . 123:func (m *prometheusMeter) Counter(name string, labels ...string) meter.Counter { . 512.05kB 124: m.Lock() . . 125: defer m.Unlock() . 41.50MB 126: nm := m.buildName(name) 320.57MB 770.13MB 127: labels = m.buildLabels(append(m.opts.Labels, labels...)...) // TODO: Read prometheus.go:128 . . 128: vcd, ok := m.counter.Load(nm) . 31MB 129: h := newHash(labels) . . 130: if !ok { . . 131: cd := &counters{cs: &sync.Map{}} . . 132: c := &prometheusCounter{c: prometheus.NewGauge(prometheus.GaugeOpts{Name: nm}), labels: labels} . . 133: cd.cs.Store(h, c) . . 134: m.counter.Store(nm, cd) . . 135: return c . . 136: } . . 137: cd := vcd.(*counters) . . 138: vc, ok := cd.cs.Load(h) . . 139: if !ok { 512.02kB 512.02kB 140: c := &prometheusCounter{c: prometheus.NewGauge(prometheus.GaugeOpts{Name: nm}), labels: labels} . 34.85MB 141: cd.cs.Store(h, c) . . 142: m.counter.Store(nm, cd) . . 143: return c . . 144: } . . 145: c := vc.(*prometheusCounter) . . 146: return c ROUTINE ======================== go.unistack.org/micro-meter-prometheus/v3.(*prometheusMeter).Histogram in go.unistack.org/micro-meter-prometheus/v3@v3.8.11/prometheus.go 219.55MB 537.58MB (flat, cum) 1.55% of Total . . 201:func (m *prometheusMeter) Histogram(name string, labels ...string) meter.Histogram { . . 202: m.Lock() . . 203: defer m.Unlock() . 45.50MB 204: nm := m.buildName(name) 219.55MB 472.58MB 205: labels = m.buildLabels(append(m.opts.Labels, labels...)...) . . 206: vcd, ok := m.histogram.Load(nm) . 19.50MB 207: h := newHash(labels) . . 208: if !ok { . . 209: cd := &histograms{cs: &sync.Map{}} . . 210: c := &prometheusHistogram{c: prometheus.NewHistogram(prometheus.HistogramOpts{Name: nm}), labels: labels} . . 211: cd.cs.Store(h, c) . . 212: m.histogram.Store(nm, cd) ROUTINE ======================== go.unistack.org/micro-meter-prometheus/v3.(*prometheusMeter).Summary in go.unistack.org/micro-meter-prometheus/v3@v3.8.11/prometheus.go 211.05MB 506.58MB (flat, cum) 1.46% of Total . . 227:func (m *prometheusMeter) Summary(name string, labels ...string) meter.Summary { . . 228: m.Lock() . . 229: defer m.Unlock() . 30.50MB 230: nm := m.buildName(name) 211.05MB 457.58MB 231: labels = m.buildLabels(append(m.opts.Labels, labels...)...) . . 232: vcd, ok := m.summary.Load(nm) . 18.50MB 233: h := newHash(labels) . . 234: if !ok { . . 235: cd := &summaries{cs: &sync.Map{}} . . 236: c := &prometheusSummary{c: prometheus.NewSummary(prometheus.SummaryOpts{Name: nm}), labels: labels} . . 237: cd.cs.Store(h, c) . . 238: m.summary.Store(nm, cd) ROUTINE ======================== go.unistack.org/micro-meter-prometheus/v3.(*prometheusMeter).Write in go.unistack.org/micro-meter-prometheus/v3@v3.8.11/prometheus.go 0 929.79MB (flat, cum) 2.69% of Total . . 302:func (m *prometheusMeter) Write(w io.Writer, opts ...meter.Option) error { . . 303: options := m.opts . . 304: for _, o := range opts { . . 305: o(&options) . . 306: } . . 307: . . 308: g, ok := m.set.(prometheus.Gatherer) . . 309: if !ok { . . 310: return fmt.Errorf("set type %T not prometheus.Gatherer", m.set) . . 311: } . . 312: . 13.60MB 313: mfs, err := g.Gather() . . 314: if err != nil { . . 315: return err . . 316: } . . 317: . . 318: enc := expfmt.NewEncoder(w, expfmt.NewFormat(expfmt.TypeTextPlain)) . . 319: . 493.01MB 320: m.counter.Range(func(k, v any) bool { . . 321: name := k.(string) . . 322: mf := &dto.MetricFamily{ . . 323: Name: newString(name), . . 324: Type: dto.MetricType_GAUGE.Enum(), . . 325: } . . 326: v.(*counters).cs.Range(func(_, nv any) bool { . . 327: c := nv.(*prometheusCounter) . . 328: m := &dto.Metric{} . . 329: _ = c.c.Write(m) . . 330: fillMetric(m, c.labels) . . 331: mf.Metric = append(mf.Metric, m) . . 332: return true . . 333: }) . . 334: mfs = append(mfs, mf) . . 335: return true . . 336: }) . . 337: . . 338: m.gauge.Range(func(k, v any) bool { . . 339: name := k.(string) . . 340: mf := &dto.MetricFamily{ . . 341: Name: newString(name), . . 342: Type: dto.MetricType_GAUGE.Enum(), . . 343: } . . 344: v.(*gauges).cs.Range(func(_, nv any) bool { . . 345: c := nv.(*prometheusGauge) . . 346: m := &dto.Metric{} . . 347: _ = c.c.Write(m) . . 348: fillMetric(m, c.labels) . . 349: mf.Metric = append(mf.Metric, m) . . 350: return true . . 351: }) . . 352: mfs = append(mfs, mf) . . 353: return true . . 354: }) . . 355: . . 356: m.floatCounter.Range(func(k, v any) bool { . . 357: name := k.(string) . . 358: mf := &dto.MetricFamily{ . . 359: Name: newString(name), . . 360: Type: dto.MetricType_GAUGE.Enum(), . . 361: } . . 362: v.(*floatCounters).cs.Range(func(_, nv any) bool { . . 363: c := nv.(*prometheusFloatCounter) . . 364: m := &dto.Metric{} . . 365: _ = c.c.Write(m) . . 366: fillMetric(m, c.labels) . . 367: mf.Metric = append(mf.Metric, m) . . 368: return true . . 369: }) . . 370: mfs = append(mfs, mf) . . 371: return true . . 372: }) . . 373: . 7.50MB 374: m.histogram.Range(func(k, v any) bool { . . 375: name := k.(string) . . 376: mf := &dto.MetricFamily{ . . 377: Name: newString(name), . . 378: Type: dto.MetricType_HISTOGRAM.Enum(), . . 379: } . . 380: v.(*histograms).cs.Range(func(_, nv any) bool { . . 381: c := nv.(*prometheusHistogram) . . 382: m := &dto.Metric{} . . 383: _ = c.c.Write(m) . . 384: fillMetric(m, c.labels) . . 385: mf.Metric = append(mf.Metric, m) . . 386: return true . . 387: }) . . 388: mfs = append(mfs, mf) . . 389: return true . . 390: }) . . 391: . 1.50MB 392: m.summary.Range(func(k, v any) bool { . . 393: name := k.(string) . . 394: mf := &dto.MetricFamily{ . . 395: Name: newString(name), . . 396: Type: dto.MetricType_SUMMARY.Enum(), . . 397: } . . 398: v.(*summaries).cs.Range(func(_, nv any) bool { . . 399: c := nv.(*prometheusSummary) . . 400: m := &dto.Metric{} . . 401: _ = c.c.Write(m) . . 402: fillMetric(m, c.labels) . . 403: mf.Metric = append(mf.Metric, m) . . 404: return true . . 405: }) . . 406: mfs = append(mfs, mf) . . 407: return true . . 408: }) . . 409: . . 410: for _, mf := range mfs { . 414.18MB 411: _ = enc.Encode(mf) . . 412: } . . 413: . . 414: if closer, ok := enc.(io.Closer); ok { . . 415: _ = closer.Close() . . 416: } ROUTINE ======================== go.unistack.org/micro-meter-prometheus/v3.(*prometheusMeter).Write.func1 in go.unistack.org/micro-meter-prometheus/v3@v3.8.11/prometheus.go 1.50MB 493.01MB (flat, cum) 1.42% of Total . . 320: m.counter.Range(func(k, v any) bool { . . 321: name := k.(string) 512.05kB 512.05kB 322: mf := &dto.MetricFamily{ . . 323: Name: newString(name), . . 324: Type: dto.MetricType_GAUGE.Enum(), . . 325: } . 491.51MB 326: v.(*counters).cs.Range(func(_, nv any) bool { . . 327: c := nv.(*prometheusCounter) . . 328: m := &dto.Metric{} . . 329: _ = c.c.Write(m) . . 330: fillMetric(m, c.labels) . . 331: mf.Metric = append(mf.Metric, m) . . 332: return true . . 333: }) 1MB 1MB 334: mfs = append(mfs, mf) . . 335: return true . . 336: }) . . 337: . . 338: m.gauge.Range(func(k, v any) bool { . . 339: name := k.(string) ROUTINE ======================== go.unistack.org/micro-meter-prometheus/v3.(*prometheusMeter).Write.func1.1 in go.unistack.org/micro-meter-prometheus/v3@v3.8.11/prometheus.go 91.49MB 491.51MB (flat, cum) 1.42% of Total . . 326: v.(*counters).cs.Range(func(_, nv any) bool { . . 327: c := nv.(*prometheusCounter) 73.51MB 73.51MB 328: m := &dto.Metric{} . 35.50MB 329: _ = c.c.Write(m) . 364.52MB 330: fillMetric(m, c.labels) 17.98MB 17.98MB 331: mf.Metric = append(mf.Metric, m) . . 332: return true . . 333: }) . . 334: mfs = append(mfs, mf) . . 335: return true . . 336: }) ROUTINE ======================== go.unistack.org/micro-meter-prometheus/v3.(*prometheusMeter).Write.func4 in go.unistack.org/micro-meter-prometheus/v3@v3.8.11/prometheus.go 0 7.50MB (flat, cum) 0.022% of Total . . 374: m.histogram.Range(func(k, v any) bool { . . 375: name := k.(string) . . 376: mf := &dto.MetricFamily{ . . 377: Name: newString(name), . . 378: Type: dto.MetricType_HISTOGRAM.Enum(), . . 379: } . 7.50MB 380: v.(*histograms).cs.Range(func(_, nv any) bool { . . 381: c := nv.(*prometheusHistogram) . . 382: m := &dto.Metric{} . . 383: _ = c.c.Write(m) . . 384: fillMetric(m, c.labels) . . 385: mf.Metric = append(mf.Metric, m) ROUTINE ======================== go.unistack.org/micro-meter-prometheus/v3.(*prometheusMeter).Write.func4.1 in go.unistack.org/micro-meter-prometheus/v3@v3.8.11/prometheus.go 512.05kB 7.50MB (flat, cum) 0.022% of Total . . 380: v.(*histograms).cs.Range(func(_, nv any) bool { . . 381: c := nv.(*prometheusHistogram) 512.05kB 512.05kB 382: m := &dto.Metric{} . 6.50MB 383: _ = c.c.Write(m) . 512.03kB 384: fillMetric(m, c.labels) . . 385: mf.Metric = append(mf.Metric, m) . . 386: return true . . 387: }) . . 388: mfs = append(mfs, mf) . . 389: return true ROUTINE ======================== go.unistack.org/micro-meter-prometheus/v3.(*prometheusMeter).Write.func5 in go.unistack.org/micro-meter-prometheus/v3@v3.8.11/prometheus.go 0 1.50MB (flat, cum) 0.0043% of Total . . 392: m.summary.Range(func(k, v any) bool { . . 393: name := k.(string) . . 394: mf := &dto.MetricFamily{ . . 395: Name: newString(name), . . 396: Type: dto.MetricType_SUMMARY.Enum(), . . 397: } . 1.50MB 398: v.(*summaries).cs.Range(func(_, nv any) bool { . . 399: c := nv.(*prometheusSummary) . . 400: m := &dto.Metric{} . . 401: _ = c.c.Write(m) . . 402: fillMetric(m, c.labels) . . 403: mf.Metric = append(mf.Metric, m) ROUTINE ======================== go.unistack.org/micro-meter-prometheus/v3.(*prometheusMeter).Write.func5.1 in go.unistack.org/micro-meter-prometheus/v3@v3.8.11/prometheus.go 512.05kB 1.50MB (flat, cum) 0.0043% of Total . . 398: v.(*summaries).cs.Range(func(_, nv any) bool { . . 399: c := nv.(*prometheusSummary) 512.05kB 512.05kB 400: m := &dto.Metric{} . 512.05kB 401: _ = c.c.Write(m) . 512.03kB 402: fillMetric(m, c.labels) . . 403: mf.Metric = append(mf.Metric, m) . . 404: return true . . 405: }) . . 406: mfs = append(mfs, mf) . . 407: return true ROUTINE ======================== go.unistack.org/micro-meter-prometheus/v3.(*prometheusMeter).buildLabels in go.unistack.org/micro-meter-prometheus/v3@v3.8.11/prometheus.go 949.12MB 949.12MB (flat, cum) 2.74% of Total . . 104:func (m *prometheusMeter) buildLabels(labels ...string) []string { . . 105: nl := len(labels) . . 106: if nl == 0 { . . 107: return nil . . 108: } . . 109: 620.12MB 620.12MB 110: nlabels := make([]string, 0, nl) . . 111: . . 112: for idx := 0; idx < nl; idx += 2 { 329.01MB 329.01MB 113: nlabels = append(nlabels, m.opts.LabelPrefix+labels[idx]) . . 114: nlabels = append(nlabels, labels[idx+1]) . . 115: } . . 116: return nlabels . . 117:} . . 118: ROUTINE ======================== go.unistack.org/micro-meter-prometheus/v3.(*prometheusMeter).buildName in go.unistack.org/micro-meter-prometheus/v3@v3.8.11/prometheus.go 117.50MB 117.50MB (flat, cum) 0.34% of Total . . 97:func (m *prometheusMeter) buildName(name string) string { . . 98: if len(m.opts.MetricPrefix) > 0 { 117.50MB 117.50MB 99: name = m.opts.MetricPrefix + name . . 100: } . . 101: return name . . 102:} . . 103: . . 104:func (m *prometheusMeter) buildLabels(labels ...string) []string { ROUTINE ======================== go.unistack.org/micro-meter-prometheus/v3.fillMetric in go.unistack.org/micro-meter-prometheus/v3@v3.8.11/prometheus.go 262.52MB 365.52MB (flat, cum) 1.06% of Total . . 560:func fillMetric(m *dto.Metric, labels []string) *dto.Metric { . . 561: var ok bool . . 562: seen := make(map[string]bool, len(labels)/2) 33.50MB 33.50MB 563: m.Label = make([]*dto.LabelPair, 0, len(labels)/2) . . 564: for idx := 0; idx < len(labels); idx += 2 { . . 565: if _, ok = seen[labels[idx]]; ok { . . 566: continue . . 567: } 229.01MB 229.01MB 568: m.Label = append(m.Label, &dto.LabelPair{ . 50MB 569: Name: newString(labels[idx]), . 53MB 570: Value: newString(labels[idx+1]), . . 571: }) . . 572: seen[labels[idx]] = true . . 573: } . . 574: return m . . 575:} ROUTINE ======================== go.unistack.org/micro-meter-prometheus/v3.newHash in go.unistack.org/micro-meter-prometheus/v3@v3.8.11/prometheus.go 0 69MB (flat, cum) 0.2% of Total . . 551:func newHash(labels []string) uint64 { . 69MB 552: labels = meter.BuildLabels(labels...) . . 553: h := fnv.New64a() . . 554: for _, l := range labels { . . 555: h.Write([]byte(l)) . . 556: } . . 557: return h.Sum64() ROUTINE ======================== go.unistack.org/micro-meter-prometheus/v3.newString in go.unistack.org/micro-meter-prometheus/v3@v3.8.11/prometheus.go 103MB 103MB (flat, cum) 0.3% of Total . . 56:func newString(v string) *string { 103MB 103MB 57: nv := v . . 58: return &nv . . 59:} . . 60: . . 61:func NewMeter(opts ...meter.Option) *prometheusMeter { . . 62: return &prometheusMeter{ ```
Author
Owner
512.57GB 23.44% 56.43%   512.57GB 23.44%  go.unistack.org/micro-meter-prometheus/v3.fillMetric (inline)
181.54GB  8.30% 64.73%   760.44GB 34.78%  go.unistack.org/micro-meter-prometheus/v3.(*prometheusMeter).Write.func1.1
``` 512.57GB 23.44% 56.43% 512.57GB 23.44% go.unistack.org/micro-meter-prometheus/v3.fillMetric (inline) 181.54GB 8.30% 64.73% 760.44GB 34.78% go.unistack.org/micro-meter-prometheus/v3.(*prometheusMeter).Write.func1.1 ```
Author
Owner

fixed in v3.8.13

fixed in v3.8.13
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: unistack-org/micro-meter-prometheus#108
No description provided.