MCPcopy
hub / github.com/netdata/netdata / createChart

Method createChart

src/go/plugin/framework/jobruntime/job_v1.go:594–666  ·  view source on GitHub ↗
(chart *collectorapi.Chart)

Source from the content-addressed store, hash-verified

592}
593
594func (j *Job) createChart(chart *collectorapi.Chart) {
595 defer func() { chart.SetCreated(true) }()
596 if chart.IsIgnored() {
597 return
598 }
599
600 if chart.Priority == 0 {
601 chart.Priority = j.priority
602 j.priority++
603 }
604 updateEvery := j.updateEvery
605 if chart.UpdateEvery > 0 {
606 updateEvery = chart.UpdateEvery
607 }
608
609 j.api.CHART(netdataapi.ChartOpts{
610 TypeID: getChartType(chart, j),
611 ID: getChartID(chart),
612 Name: chart.OverID,
613 Title: chart.Title,
614 Units: chart.Units,
615 Family: chart.Fam,
616 Context: chart.Ctx,
617 ChartType: chart.Type.String(),
618 Priority: chart.Priority,
619 UpdateEvery: updateEvery,
620 Options: chart.Opts.String(),
621 Plugin: j.pluginName,
622 Module: j.moduleName,
623 })
624
625 if chart.Obsolete {
626 _ = j.api.EMPTYLINE()
627 return
628 }
629
630 seen := make(map[string]bool)
631 for _, l := range chart.Labels {
632 if l.Key != "" {
633 seen[l.Key] = true
634 ls := l.Source
635 // the default should be auto
636 // https://github.com/netdata/netdata/blob/cc2586de697702f86a3c34e60e23652dd4ddcb42/database/rrd.h#L205
637 if ls == 0 {
638 ls = collectorapi.LabelSourceAuto
639 }
640 j.api.CLABEL(l.Key, lblValueReplacer.Replace(l.Value), ls)
641 }
642 }
643 for k, v := range j.labels {
644 if !seen[k] {
645 j.api.CLABEL(k, lblValueReplacer.Replace(v), collectorapi.LabelSourceConf)
646 }
647 }
648 j.api.CLABEL("_collect_job", lblValueReplacer.Replace(j.Name()), collectorapi.LabelSourceAuto)
649 j.api.CLABELCOMMIT()
650
651 for _, dim := range chart.Dims {

Callers 2

CleanupMethod · 0.95
processMetricsMethod · 0.95

Calls 14

NameMethod · 0.95
getChartTypeFunction · 0.85
getChartIDFunction · 0.85
SetCreatedMethod · 0.80
IsIgnoredMethod · 0.80
CHARTMethod · 0.80
EMPTYLINEMethod · 0.80
CLABELMethod · 0.80
CLABELCOMMITMethod · 0.80
DIMENSIONMethod · 0.80
VARIABLEMethod · 0.80
firstNotEmptyFunction · 0.70

Tested by

no test coverage detected