MCPcopy
hub / github.com/netdata/netdata / processMetrics

Method processMetrics

src/go/plugin/framework/jobruntime/job_v1.go:489–576  ·  view source on GitHub ↗
(mx collectedMetrics, startTime time.Time, sinceLastRun int)

Source from the content-addressed store, hash-verified

487}
488
489func (j *Job) processMetrics(mx collectedMetrics, startTime time.Time, sinceLastRun int) bool {
490 var createChart bool
491 if j.module.VirtualNode() == nil {
492 select {
493 case vnode := <-j.updVnode:
494 j.vnodeCreated = false
495 createChart = j.vnode.GUID != vnode.GUID
496 j.vnode = *vnode.Copy()
497 default:
498 }
499 }
500
501 if !j.vnodeCreated {
502 if j.vnode.GUID == "" {
503 if v := j.module.VirtualNode(); v != nil && v.GUID != "" && v.Hostname != "" {
504 j.vnode = *v
505 }
506 }
507 if j.vnode.GUID != "" {
508 j.sendVnodeHostInfo()
509 j.vnodeCreated = true
510 }
511 }
512
513 bufLenBeforeHost := j.buf.Len()
514 j.api.HOST(j.vnode.GUID)
515
516 elapsed := int64(durationTo(time.Since(startTime), time.Millisecond))
517
518 var i, updated, created int
519 for _, chart := range *j.charts {
520 if !chart.IsCreated() || createChart {
521 typeID := fmt.Sprintf("%s.%s", getChartType(chart, j), getChartID(chart))
522 if len(typeID) >= NetdataChartIDMaxLength {
523 j.Warningf("chart 'type.id' length (%d) >= max allowed (%d), the chart is ignored (%s)",
524 len(typeID), NetdataChartIDMaxLength, typeID)
525 chart.SetIgnored(true)
526 }
527 j.createChart(chart)
528 created++
529 }
530 if chart.IsRemoved() {
531 continue
532 }
533 (*j.charts)[i] = chart
534 i++
535 if len(mx.intMetrics)+len(mx.floatMetrics) == 0 || chart.Obsolete {
536 continue
537 }
538 if j.updateChart(chart, mx, sinceLastRun) {
539 updated++
540 }
541 }
542 *j.charts = (*j.charts)[:i]
543
544 if updated == 0 && created == 0 && j.vnode.GUID != "" {
545 j.buf.Truncate(bufLenBeforeHost)
546 }

Callers 2

runOnceMethod · 0.95

Calls 15

sendVnodeHostInfoMethod · 0.95
createChartMethod · 0.95
updateChartMethod · 0.95
FullNameMethod · 0.95
durationToFunction · 0.85
getChartTypeFunction · 0.85
getChartIDFunction · 0.85
cleanPluginNameFunction · 0.85
HOSTMethod · 0.80
IsCreatedMethod · 0.80
SetIgnoredMethod · 0.80
BoolMethod · 0.80

Tested by 1