id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
128,100 | influxdata/telegraf | plugins/inputs/statsd/statsd.go | udpListen | func (s *Statsd) udpListen(conn *net.UDPConn) error {
if s.ReadBufferSize > 0 {
s.UDPlistener.SetReadBuffer(s.ReadBufferSize)
}
buf := make([]byte, UDP_MAX_PACKET_SIZE)
for {
select {
case <-s.done:
return nil
default:
n, _, err := conn.ReadFromUDP(buf)
if err != nil && !strings.Contains(err.Error... | go | func (s *Statsd) udpListen(conn *net.UDPConn) error {
if s.ReadBufferSize > 0 {
s.UDPlistener.SetReadBuffer(s.ReadBufferSize)
}
buf := make([]byte, UDP_MAX_PACKET_SIZE)
for {
select {
case <-s.done:
return nil
default:
n, _, err := conn.ReadFromUDP(buf)
if err != nil && !strings.Contains(err.Error... | [
"func",
"(",
"s",
"*",
"Statsd",
")",
"udpListen",
"(",
"conn",
"*",
"net",
".",
"UDPConn",
")",
"error",
"{",
"if",
"s",
".",
"ReadBufferSize",
">",
"0",
"{",
"s",
".",
"UDPlistener",
".",
"SetReadBuffer",
"(",
"s",
".",
"ReadBufferSize",
")",
"\n",... | // udpListen starts listening for udp packets on the configured port. | [
"udpListen",
"starts",
"listening",
"for",
"udp",
"packets",
"on",
"the",
"configured",
"port",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/statsd/statsd.go#L431-L461 |
128,101 | influxdata/telegraf | plugins/inputs/statsd/statsd.go | parser | func (s *Statsd) parser() error {
for {
select {
case <-s.done:
return nil
case buf := <-s.in:
lines := strings.Split(buf.String(), "\n")
s.bufPool.Put(buf)
for _, line := range lines {
line = strings.TrimSpace(line)
if line != "" {
s.parseStatsdLine(line)
}
}
}
}
} | go | func (s *Statsd) parser() error {
for {
select {
case <-s.done:
return nil
case buf := <-s.in:
lines := strings.Split(buf.String(), "\n")
s.bufPool.Put(buf)
for _, line := range lines {
line = strings.TrimSpace(line)
if line != "" {
s.parseStatsdLine(line)
}
}
}
}
} | [
"func",
"(",
"s",
"*",
"Statsd",
")",
"parser",
"(",
")",
"error",
"{",
"for",
"{",
"select",
"{",
"case",
"<-",
"s",
".",
"done",
":",
"return",
"nil",
"\n",
"case",
"buf",
":=",
"<-",
"s",
".",
"in",
":",
"lines",
":=",
"strings",
".",
"Split... | // parser monitors the s.in channel, if there is a packet ready, it parses the
// packet into statsd strings and then calls parseStatsdLine, which parses a
// single statsd metric into a struct. | [
"parser",
"monitors",
"the",
"s",
".",
"in",
"channel",
"if",
"there",
"is",
"a",
"packet",
"ready",
"it",
"parses",
"the",
"packet",
"into",
"statsd",
"strings",
"and",
"then",
"calls",
"parseStatsdLine",
"which",
"parses",
"a",
"single",
"statsd",
"metric"... | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/statsd/statsd.go#L466-L482 |
128,102 | influxdata/telegraf | plugins/inputs/statsd/statsd.go | parseKeyValue | func parseKeyValue(keyvalue string) (string, string) {
var key, val string
split := strings.Split(keyvalue, "=")
// Must be exactly 2 to get anything meaningful out of them
if len(split) == 2 {
key = split[0]
val = split[1]
} else if len(split) == 1 {
val = split[0]
}
return key, val
} | go | func parseKeyValue(keyvalue string) (string, string) {
var key, val string
split := strings.Split(keyvalue, "=")
// Must be exactly 2 to get anything meaningful out of them
if len(split) == 2 {
key = split[0]
val = split[1]
} else if len(split) == 1 {
val = split[0]
}
return key, val
} | [
"func",
"parseKeyValue",
"(",
"keyvalue",
"string",
")",
"(",
"string",
",",
"string",
")",
"{",
"var",
"key",
",",
"val",
"string",
"\n\n",
"split",
":=",
"strings",
".",
"Split",
"(",
"keyvalue",
",",
"\"",
"\"",
")",
"\n",
"// Must be exactly 2 to get a... | // Parse the key,value out of a string that looks like "key=value" | [
"Parse",
"the",
"key",
"value",
"out",
"of",
"a",
"string",
"that",
"looks",
"like",
"key",
"=",
"value"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/statsd/statsd.go#L693-L706 |
128,103 | influxdata/telegraf | plugins/outputs/cloudwatch/cloudwatch.go | PartitionDatums | func PartitionDatums(size int, datums []*cloudwatch.MetricDatum) [][]*cloudwatch.MetricDatum {
numberOfPartitions := len(datums) / size
if len(datums)%size != 0 {
numberOfPartitions += 1
}
partitions := make([][]*cloudwatch.MetricDatum, numberOfPartitions)
for i := 0; i < numberOfPartitions; i++ {
start := ... | go | func PartitionDatums(size int, datums []*cloudwatch.MetricDatum) [][]*cloudwatch.MetricDatum {
numberOfPartitions := len(datums) / size
if len(datums)%size != 0 {
numberOfPartitions += 1
}
partitions := make([][]*cloudwatch.MetricDatum, numberOfPartitions)
for i := 0; i < numberOfPartitions; i++ {
start := ... | [
"func",
"PartitionDatums",
"(",
"size",
"int",
",",
"datums",
"[",
"]",
"*",
"cloudwatch",
".",
"MetricDatum",
")",
"[",
"]",
"[",
"]",
"*",
"cloudwatch",
".",
"MetricDatum",
"{",
"numberOfPartitions",
":=",
"len",
"(",
"datums",
")",
"/",
"size",
"\n",
... | // Partition the MetricDatums into smaller slices of a max size so that are under the limit
// for the AWS API calls. | [
"Partition",
"the",
"MetricDatums",
"into",
"smaller",
"slices",
"of",
"a",
"max",
"size",
"so",
"that",
"are",
"under",
"the",
"limit",
"for",
"the",
"AWS",
"API",
"calls",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/outputs/cloudwatch/cloudwatch.go#L256-L276 |
128,104 | influxdata/telegraf | plugins/outputs/cloudwatch/cloudwatch.go | BuildMetricDatum | func BuildMetricDatum(buildStatistic bool, point telegraf.Metric) []*cloudwatch.MetricDatum {
fields := make(map[string]cloudwatchField)
tags := point.Tags()
for k, v := range point.Fields() {
val, ok := convert(v)
if !ok {
// Only fields with values that can be converted to float64 (and within CloudWatch ... | go | func BuildMetricDatum(buildStatistic bool, point telegraf.Metric) []*cloudwatch.MetricDatum {
fields := make(map[string]cloudwatchField)
tags := point.Tags()
for k, v := range point.Fields() {
val, ok := convert(v)
if !ok {
// Only fields with values that can be converted to float64 (and within CloudWatch ... | [
"func",
"BuildMetricDatum",
"(",
"buildStatistic",
"bool",
",",
"point",
"telegraf",
".",
"Metric",
")",
"[",
"]",
"*",
"cloudwatch",
".",
"MetricDatum",
"{",
"fields",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"cloudwatchField",
")",
"\n",
"tags",
":=... | // Make a MetricDatum from telegraf.Metric. It would check if all required fields of
// cloudwatch.StatisticSet are available. If so, it would build MetricDatum from statistic values.
// Otherwise, fields would still been built independently. | [
"Make",
"a",
"MetricDatum",
"from",
"telegraf",
".",
"Metric",
".",
"It",
"would",
"check",
"if",
"all",
"required",
"fields",
"of",
"cloudwatch",
".",
"StatisticSet",
"are",
"available",
".",
"If",
"so",
"it",
"would",
"build",
"MetricDatum",
"from",
"stati... | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/outputs/cloudwatch/cloudwatch.go#L281-L334 |
128,105 | influxdata/telegraf | plugins/outputs/cloudwatch/cloudwatch.go | BuildDimensions | func BuildDimensions(mTags map[string]string) []*cloudwatch.Dimension {
const MaxDimensions = 10
dimensions := make([]*cloudwatch.Dimension, 0, MaxDimensions)
// This is pretty ugly but we always want to include the "host" tag if it exists.
if host, ok := mTags["host"]; ok {
dimensions = append(dimensions, &clou... | go | func BuildDimensions(mTags map[string]string) []*cloudwatch.Dimension {
const MaxDimensions = 10
dimensions := make([]*cloudwatch.Dimension, 0, MaxDimensions)
// This is pretty ugly but we always want to include the "host" tag if it exists.
if host, ok := mTags["host"]; ok {
dimensions = append(dimensions, &clou... | [
"func",
"BuildDimensions",
"(",
"mTags",
"map",
"[",
"string",
"]",
"string",
")",
"[",
"]",
"*",
"cloudwatch",
".",
"Dimension",
"{",
"const",
"MaxDimensions",
"=",
"10",
"\n",
"dimensions",
":=",
"make",
"(",
"[",
"]",
"*",
"cloudwatch",
".",
"Dimensio... | // Make a list of Dimensions by using a Point's tags. CloudWatch supports up to
// 10 dimensions per metric so we only keep up to the first 10 alphabetically.
// This always includes the "host" tag if it exists. | [
"Make",
"a",
"list",
"of",
"Dimensions",
"by",
"using",
"a",
"Point",
"s",
"tags",
".",
"CloudWatch",
"supports",
"up",
"to",
"10",
"dimensions",
"per",
"metric",
"so",
"we",
"only",
"keep",
"up",
"to",
"the",
"first",
"10",
"alphabetically",
".",
"This"... | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/outputs/cloudwatch/cloudwatch.go#L339-L376 |
128,106 | influxdata/telegraf | plugins/inputs/amqp_consumer/amqp_consumer.go | Start | func (a *AMQPConsumer) Start(acc telegraf.Accumulator) error {
amqpConf, err := a.createConfig()
if err != nil {
return err
}
msgs, err := a.connect(amqpConf)
if err != nil {
return err
}
ctx, cancel := context.WithCancel(context.Background())
a.cancel = cancel
a.wg = &sync.WaitGroup{}
a.wg.Add(1)
go ... | go | func (a *AMQPConsumer) Start(acc telegraf.Accumulator) error {
amqpConf, err := a.createConfig()
if err != nil {
return err
}
msgs, err := a.connect(amqpConf)
if err != nil {
return err
}
ctx, cancel := context.WithCancel(context.Background())
a.cancel = cancel
a.wg = &sync.WaitGroup{}
a.wg.Add(1)
go ... | [
"func",
"(",
"a",
"*",
"AMQPConsumer",
")",
"Start",
"(",
"acc",
"telegraf",
".",
"Accumulator",
")",
"error",
"{",
"amqpConf",
",",
"err",
":=",
"a",
".",
"createConfig",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"... | // Start satisfies the telegraf.ServiceInput interface | [
"Start",
"satisfies",
"the",
"telegraf",
".",
"ServiceInput",
"interface"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/amqp_consumer/amqp_consumer.go#L198-L246 |
128,107 | influxdata/telegraf | plugins/inputs/amqp_consumer/amqp_consumer.go | process | func (a *AMQPConsumer) process(ctx context.Context, msgs <-chan amqp.Delivery, ac telegraf.Accumulator) {
a.deliveries = make(map[telegraf.TrackingID]amqp.Delivery)
acc := ac.WithTracking(a.MaxUndeliveredMessages)
sem := make(semaphore, a.MaxUndeliveredMessages)
for {
select {
case <-ctx.Done():
return
c... | go | func (a *AMQPConsumer) process(ctx context.Context, msgs <-chan amqp.Delivery, ac telegraf.Accumulator) {
a.deliveries = make(map[telegraf.TrackingID]amqp.Delivery)
acc := ac.WithTracking(a.MaxUndeliveredMessages)
sem := make(semaphore, a.MaxUndeliveredMessages)
for {
select {
case <-ctx.Done():
return
c... | [
"func",
"(",
"a",
"*",
"AMQPConsumer",
")",
"process",
"(",
"ctx",
"context",
".",
"Context",
",",
"msgs",
"<-",
"chan",
"amqp",
".",
"Delivery",
",",
"ac",
"telegraf",
".",
"Accumulator",
")",
"{",
"a",
".",
"deliveries",
"=",
"make",
"(",
"map",
"[... | // Read messages from queue and add them to the Accumulator | [
"Read",
"messages",
"from",
"queue",
"and",
"add",
"them",
"to",
"the",
"Accumulator"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/amqp_consumer/amqp_consumer.go#L393-L428 |
128,108 | influxdata/telegraf | internal/templating/node.go | insert | func (n *node) insert(filter string, template *Template) {
n.separator = template.separator
n.recursiveInsert(strings.Split(filter, n.separator), template)
} | go | func (n *node) insert(filter string, template *Template) {
n.separator = template.separator
n.recursiveInsert(strings.Split(filter, n.separator), template)
} | [
"func",
"(",
"n",
"*",
"node",
")",
"insert",
"(",
"filter",
"string",
",",
"template",
"*",
"Template",
")",
"{",
"n",
".",
"separator",
"=",
"template",
".",
"separator",
"\n",
"n",
".",
"recursiveInsert",
"(",
"strings",
".",
"Split",
"(",
"filter",... | // insert inserts the given string template into the tree. The filter string is separated
// on the template separator and each part is used as the path in the tree. | [
"insert",
"inserts",
"the",
"given",
"string",
"template",
"into",
"the",
"tree",
".",
"The",
"filter",
"string",
"is",
"separated",
"on",
"the",
"template",
"separator",
"and",
"each",
"part",
"is",
"used",
"as",
"the",
"path",
"in",
"the",
"tree",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/internal/templating/node.go#L19-L22 |
128,109 | influxdata/telegraf | internal/templating/node.go | recursiveInsert | func (n *node) recursiveInsert(values []string, template *Template) {
// Add the end, set the template
if len(values) == 0 {
n.template = template
return
}
// See if the the current element already exists in the tree. If so, insert the
// into that sub-tree
for _, v := range n.children {
if v.value == valu... | go | func (n *node) recursiveInsert(values []string, template *Template) {
// Add the end, set the template
if len(values) == 0 {
n.template = template
return
}
// See if the the current element already exists in the tree. If so, insert the
// into that sub-tree
for _, v := range n.children {
if v.value == valu... | [
"func",
"(",
"n",
"*",
"node",
")",
"recursiveInsert",
"(",
"values",
"[",
"]",
"string",
",",
"template",
"*",
"Template",
")",
"{",
"// Add the end, set the template",
"if",
"len",
"(",
"values",
")",
"==",
"0",
"{",
"n",
".",
"template",
"=",
"templat... | // recursiveInsert does the actual recursive insertion | [
"recursiveInsert",
"does",
"the",
"actual",
"recursive",
"insertion"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/internal/templating/node.go#L25-L48 |
128,110 | influxdata/telegraf | internal/templating/node.go | search | func (n *node) search(line string) *Template {
separator := n.separator
return n.recursiveSearch(strings.Split(line, separator))
} | go | func (n *node) search(line string) *Template {
separator := n.separator
return n.recursiveSearch(strings.Split(line, separator))
} | [
"func",
"(",
"n",
"*",
"node",
")",
"search",
"(",
"line",
"string",
")",
"*",
"Template",
"{",
"separator",
":=",
"n",
".",
"separator",
"\n",
"return",
"n",
".",
"recursiveSearch",
"(",
"strings",
".",
"Split",
"(",
"line",
",",
"separator",
")",
"... | // search searches for a template matching the input string | [
"search",
"searches",
"for",
"a",
"template",
"matching",
"the",
"input",
"string"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/internal/templating/node.go#L51-L54 |
128,111 | influxdata/telegraf | internal/templating/node.go | recursiveSearch | func (n *node) recursiveSearch(lineParts []string) *Template {
// Nothing to search
if len(lineParts) == 0 || len(n.children) == 0 {
return n.template
}
// If last element is a wildcard, don't include it in this search since it's sorted
// to the end but lexicographically it would not always be and sort.Search ... | go | func (n *node) recursiveSearch(lineParts []string) *Template {
// Nothing to search
if len(lineParts) == 0 || len(n.children) == 0 {
return n.template
}
// If last element is a wildcard, don't include it in this search since it's sorted
// to the end but lexicographically it would not always be and sort.Search ... | [
"func",
"(",
"n",
"*",
"node",
")",
"recursiveSearch",
"(",
"lineParts",
"[",
"]",
"string",
")",
"*",
"Template",
"{",
"// Nothing to search",
"if",
"len",
"(",
"lineParts",
")",
"==",
"0",
"||",
"len",
"(",
"n",
".",
"children",
")",
"==",
"0",
"{"... | // recursiveSearch performs the actual recursive search | [
"recursiveSearch",
"performs",
"the",
"actual",
"recursive",
"search"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/internal/templating/node.go#L57-L85 |
128,112 | influxdata/telegraf | plugins/serializers/influx/reader.go | NewReader | func NewReader(metrics []telegraf.Metric, serializer *Serializer) io.Reader {
return &reader{
metrics: metrics,
serializer: serializer,
offset: 0,
buf: bytes.NewBuffer(make([]byte, 0, serializer.maxLineBytes)),
}
} | go | func NewReader(metrics []telegraf.Metric, serializer *Serializer) io.Reader {
return &reader{
metrics: metrics,
serializer: serializer,
offset: 0,
buf: bytes.NewBuffer(make([]byte, 0, serializer.maxLineBytes)),
}
} | [
"func",
"NewReader",
"(",
"metrics",
"[",
"]",
"telegraf",
".",
"Metric",
",",
"serializer",
"*",
"Serializer",
")",
"io",
".",
"Reader",
"{",
"return",
"&",
"reader",
"{",
"metrics",
":",
"metrics",
",",
"serializer",
":",
"serializer",
",",
"offset",
"... | // NewReader creates a new reader over the given metrics. | [
"NewReader",
"creates",
"a",
"new",
"reader",
"over",
"the",
"given",
"metrics",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/serializers/influx/reader.go#L20-L27 |
128,113 | influxdata/telegraf | plugins/serializers/influx/reader.go | SetMetrics | func (r *reader) SetMetrics(metrics []telegraf.Metric) {
r.metrics = metrics
r.offset = 0
r.buf.Reset()
} | go | func (r *reader) SetMetrics(metrics []telegraf.Metric) {
r.metrics = metrics
r.offset = 0
r.buf.Reset()
} | [
"func",
"(",
"r",
"*",
"reader",
")",
"SetMetrics",
"(",
"metrics",
"[",
"]",
"telegraf",
".",
"Metric",
")",
"{",
"r",
".",
"metrics",
"=",
"metrics",
"\n",
"r",
".",
"offset",
"=",
"0",
"\n",
"r",
".",
"buf",
".",
"Reset",
"(",
")",
"\n",
"}"... | // SetMetrics changes the metrics to be read. | [
"SetMetrics",
"changes",
"the",
"metrics",
"to",
"be",
"read",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/serializers/influx/reader.go#L30-L34 |
128,114 | influxdata/telegraf | plugins/inputs/vsphere/throttled_exec.go | NewThrottledExecutor | func NewThrottledExecutor(limit int) *ThrottledExecutor {
if limit == 0 {
panic("Limit must be > 0")
}
return &ThrottledExecutor{limiter: make(chan struct{}, limit)}
} | go | func NewThrottledExecutor(limit int) *ThrottledExecutor {
if limit == 0 {
panic("Limit must be > 0")
}
return &ThrottledExecutor{limiter: make(chan struct{}, limit)}
} | [
"func",
"NewThrottledExecutor",
"(",
"limit",
"int",
")",
"*",
"ThrottledExecutor",
"{",
"if",
"limit",
"==",
"0",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"&",
"ThrottledExecutor",
"{",
"limiter",
":",
"make",
"(",
"chan",
"struct"... | // NewThrottledExecutor creates a new ThrottlesExecutor with a specified maximum
// number of concurrent jobs | [
"NewThrottledExecutor",
"creates",
"a",
"new",
"ThrottlesExecutor",
"with",
"a",
"specified",
"maximum",
"number",
"of",
"concurrent",
"jobs"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/vsphere/throttled_exec.go#L17-L22 |
128,115 | influxdata/telegraf | plugins/inputs/vsphere/throttled_exec.go | Run | func (t *ThrottledExecutor) Run(ctx context.Context, job func()) {
t.wg.Add(1)
go func() {
defer t.wg.Done()
select {
case t.limiter <- struct{}{}:
defer func() {
<-t.limiter
}()
job()
case <-ctx.Done():
return
}
}()
} | go | func (t *ThrottledExecutor) Run(ctx context.Context, job func()) {
t.wg.Add(1)
go func() {
defer t.wg.Done()
select {
case t.limiter <- struct{}{}:
defer func() {
<-t.limiter
}()
job()
case <-ctx.Done():
return
}
}()
} | [
"func",
"(",
"t",
"*",
"ThrottledExecutor",
")",
"Run",
"(",
"ctx",
"context",
".",
"Context",
",",
"job",
"func",
"(",
")",
")",
"{",
"t",
".",
"wg",
".",
"Add",
"(",
"1",
")",
"\n",
"go",
"func",
"(",
")",
"{",
"defer",
"t",
".",
"wg",
".",... | // Run schedules a job for execution as soon as possible while respecting the
// maximum concurrency limit. | [
"Run",
"schedules",
"a",
"job",
"for",
"execution",
"as",
"soon",
"as",
"possible",
"while",
"respecting",
"the",
"maximum",
"concurrency",
"limit",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/vsphere/throttled_exec.go#L26-L40 |
128,116 | influxdata/telegraf | logger/logger.go | newTelegrafWriter | func newTelegrafWriter(w io.Writer) io.Writer {
return &telegrafLog{
writer: wlog.NewWriter(w),
}
} | go | func newTelegrafWriter(w io.Writer) io.Writer {
return &telegrafLog{
writer: wlog.NewWriter(w),
}
} | [
"func",
"newTelegrafWriter",
"(",
"w",
"io",
".",
"Writer",
")",
"io",
".",
"Writer",
"{",
"return",
"&",
"telegrafLog",
"{",
"writer",
":",
"wlog",
".",
"NewWriter",
"(",
"w",
")",
",",
"}",
"\n",
"}"
] | // newTelegrafWriter returns a logging-wrapped writer. | [
"newTelegrafWriter",
"returns",
"a",
"logging",
"-",
"wrapped",
"writer",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/logger/logger.go#L16-L20 |
128,117 | influxdata/telegraf | logger/logger.go | SetupLogging | func SetupLogging(debug, quiet bool, logfile string) {
log.SetFlags(0)
if debug {
wlog.SetLevel(wlog.DEBUG)
}
if quiet {
wlog.SetLevel(wlog.ERROR)
}
var oFile *os.File
if logfile != "" {
var err error
if oFile, err = os.OpenFile(logfile, os.O_CREATE|os.O_APPEND|os.O_WRONLY, os.ModeAppend|0644); err != n... | go | func SetupLogging(debug, quiet bool, logfile string) {
log.SetFlags(0)
if debug {
wlog.SetLevel(wlog.DEBUG)
}
if quiet {
wlog.SetLevel(wlog.ERROR)
}
var oFile *os.File
if logfile != "" {
var err error
if oFile, err = os.OpenFile(logfile, os.O_CREATE|os.O_APPEND|os.O_WRONLY, os.ModeAppend|0644); err != n... | [
"func",
"SetupLogging",
"(",
"debug",
",",
"quiet",
"bool",
",",
"logfile",
"string",
")",
"{",
"log",
".",
"SetFlags",
"(",
"0",
")",
"\n",
"if",
"debug",
"{",
"wlog",
".",
"SetLevel",
"(",
"wlog",
".",
"DEBUG",
")",
"\n",
"}",
"\n",
"if",
"quiet"... | // SetupLogging configures the logging output.
// debug will set the log level to DEBUG
// quiet will set the log level to ERROR
// logfile will direct the logging output to a file. Empty string is
// interpreted as stderr. If there is an error opening the file the
// logger will fallback ... | [
"SetupLogging",
"configures",
"the",
"logging",
"output",
".",
"debug",
"will",
"set",
"the",
"log",
"level",
"to",
"DEBUG",
"quiet",
"will",
"set",
"the",
"log",
"level",
"to",
"ERROR",
"logfile",
"will",
"direct",
"the",
"logging",
"output",
"to",
"a",
"... | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/logger/logger.go#L42-L63 |
128,118 | influxdata/telegraf | metric/series_grouper.go | Add | func (g *SeriesGrouper) Add(
measurement string,
tags map[string]string,
tm time.Time,
field string,
fieldValue interface{},
) error {
var err error
id := groupID(measurement, tags, tm)
metric := g.metrics[id]
if metric == nil {
metric, err = New(measurement, tags, map[string]interface{}{field: fieldValue}, ... | go | func (g *SeriesGrouper) Add(
measurement string,
tags map[string]string,
tm time.Time,
field string,
fieldValue interface{},
) error {
var err error
id := groupID(measurement, tags, tm)
metric := g.metrics[id]
if metric == nil {
metric, err = New(measurement, tags, map[string]interface{}{field: fieldValue}, ... | [
"func",
"(",
"g",
"*",
"SeriesGrouper",
")",
"Add",
"(",
"measurement",
"string",
",",
"tags",
"map",
"[",
"string",
"]",
"string",
",",
"tm",
"time",
".",
"Time",
",",
"field",
"string",
",",
"fieldValue",
"interface",
"{",
"}",
",",
")",
"error",
"... | // Add adds a field key and value to the series. | [
"Add",
"adds",
"a",
"field",
"key",
"and",
"value",
"to",
"the",
"series",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/metric/series_grouper.go#L37-L58 |
128,119 | influxdata/telegraf | plugins/inputs/win_perf_counters/win_perf_counters.go | AddItem | func (m *Win_PerfCounters) AddItem(counterPath string, objectName string, instance string, counterName string, measurement string, includeTotal bool) error {
var err error
var counterHandle PDH_HCOUNTER
if !m.query.IsVistaOrNewer() {
counterHandle, err = m.query.AddCounterToQuery(counterPath)
if err != nil {
... | go | func (m *Win_PerfCounters) AddItem(counterPath string, objectName string, instance string, counterName string, measurement string, includeTotal bool) error {
var err error
var counterHandle PDH_HCOUNTER
if !m.query.IsVistaOrNewer() {
counterHandle, err = m.query.AddCounterToQuery(counterPath)
if err != nil {
... | [
"func",
"(",
"m",
"*",
"Win_PerfCounters",
")",
"AddItem",
"(",
"counterPath",
"string",
",",
"objectName",
"string",
",",
"instance",
"string",
",",
"counterName",
"string",
",",
"measurement",
"string",
",",
"includeTotal",
"bool",
")",
"error",
"{",
"var",
... | //objectName string, counter string, instance string, measurement string, include_total bool | [
"objectName",
"string",
"counter",
"string",
"instance",
"string",
"measurement",
"string",
"include_total",
"bool"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/win_perf_counters/win_perf_counters.go#L184-L242 |
128,120 | influxdata/telegraf | plugins/inputs/processes/processes.go | getEmptyFields | func getEmptyFields() map[string]interface{} {
fields := map[string]interface{}{
"blocked": int64(0),
"zombies": int64(0),
"stopped": int64(0),
"running": int64(0),
"sleeping": int64(0),
"total": int64(0),
"unknown": int64(0),
}
switch runtime.GOOS {
case "freebsd":
fields["idle"] = int64(0)... | go | func getEmptyFields() map[string]interface{} {
fields := map[string]interface{}{
"blocked": int64(0),
"zombies": int64(0),
"stopped": int64(0),
"running": int64(0),
"sleeping": int64(0),
"total": int64(0),
"unknown": int64(0),
}
switch runtime.GOOS {
case "freebsd":
fields["idle"] = int64(0)... | [
"func",
"getEmptyFields",
"(",
")",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"fields",
":=",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"\"",
"\"",
":",
"int64",
"(",
"0",
")",
",",
"\"",
"\"",
":",
"int64",
"(",
"0",
... | // Gets empty fields of metrics based on the OS | [
"Gets",
"empty",
"fields",
"of",
"metrics",
"based",
"on",
"the",
"OS"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/processes/processes.go#L67-L92 |
128,121 | influxdata/telegraf | plugins/inputs/processes/processes.go | gatherFromPS | func (p *Processes) gatherFromPS(fields map[string]interface{}) error {
out, err := p.execPS()
if err != nil {
return err
}
for i, status := range bytes.Fields(out) {
if i == 0 && string(status) == "STAT" {
// This is a header, skip it
continue
}
switch status[0] {
case 'W':
fields["wait"] = fie... | go | func (p *Processes) gatherFromPS(fields map[string]interface{}) error {
out, err := p.execPS()
if err != nil {
return err
}
for i, status := range bytes.Fields(out) {
if i == 0 && string(status) == "STAT" {
// This is a header, skip it
continue
}
switch status[0] {
case 'W':
fields["wait"] = fie... | [
"func",
"(",
"p",
"*",
"Processes",
")",
"gatherFromPS",
"(",
"fields",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"error",
"{",
"out",
",",
"err",
":=",
"p",
".",
"execPS",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"er... | // exec `ps` to get all process states | [
"exec",
"ps",
"to",
"get",
"all",
"process",
"states"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/processes/processes.go#L95-L133 |
128,122 | influxdata/telegraf | plugins/parsers/graphite/config.go | Validate | func (c *Config) Validate() error {
if err := c.validateTemplates(); err != nil {
return err
}
return nil
} | go | func (c *Config) Validate() error {
if err := c.validateTemplates(); err != nil {
return err
}
return nil
} | [
"func",
"(",
"c",
"*",
"Config",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"err",
":=",
"c",
".",
"validateTemplates",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // Validate validates the config's templates and tags. | [
"Validate",
"validates",
"the",
"config",
"s",
"templates",
"and",
"tags",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/parsers/graphite/config.go#L21-L27 |
128,123 | influxdata/telegraf | plugins/outputs/stackdriver/stackdriver.go | Connect | func (s *Stackdriver) Connect() error {
if s.Project == "" {
return fmt.Errorf("Project is a required field for stackdriver output")
}
if s.Namespace == "" {
return fmt.Errorf("Namespace is a required field for stackdriver output")
}
if s.ResourceType == "" {
s.ResourceType = "global"
}
if s.ResourceLab... | go | func (s *Stackdriver) Connect() error {
if s.Project == "" {
return fmt.Errorf("Project is a required field for stackdriver output")
}
if s.Namespace == "" {
return fmt.Errorf("Namespace is a required field for stackdriver output")
}
if s.ResourceType == "" {
s.ResourceType = "global"
}
if s.ResourceLab... | [
"func",
"(",
"s",
"*",
"Stackdriver",
")",
"Connect",
"(",
")",
"error",
"{",
"if",
"s",
".",
"Project",
"==",
"\"",
"\"",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"s",
".",
"Namespace",
"==",
"\"",
"\... | // Connect initiates the primary connection to the GCP project. | [
"Connect",
"initiates",
"the",
"primary",
"connection",
"to",
"the",
"GCP",
"project",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/outputs/stackdriver/stackdriver.go#L70-L99 |
128,124 | influxdata/telegraf | plugins/outputs/stackdriver/stackdriver.go | sorted | func sorted(metrics []telegraf.Metric) []telegraf.Metric {
batch := make([]telegraf.Metric, 0, len(metrics))
for i := len(metrics) - 1; i >= 0; i-- {
batch = append(batch, metrics[i])
}
sort.Slice(batch, func(i, j int) bool {
return batch[i].Time().Before(batch[j].Time())
})
return batch
} | go | func sorted(metrics []telegraf.Metric) []telegraf.Metric {
batch := make([]telegraf.Metric, 0, len(metrics))
for i := len(metrics) - 1; i >= 0; i-- {
batch = append(batch, metrics[i])
}
sort.Slice(batch, func(i, j int) bool {
return batch[i].Time().Before(batch[j].Time())
})
return batch
} | [
"func",
"sorted",
"(",
"metrics",
"[",
"]",
"telegraf",
".",
"Metric",
")",
"[",
"]",
"telegraf",
".",
"Metric",
"{",
"batch",
":=",
"make",
"(",
"[",
"]",
"telegraf",
".",
"Metric",
",",
"0",
",",
"len",
"(",
"metrics",
")",
")",
"\n",
"for",
"i... | // Sorted returns a copy of the metrics in time ascending order. A copy is
// made to avoid modifying the input metric slice since doing so is not
// allowed. | [
"Sorted",
"returns",
"a",
"copy",
"of",
"the",
"metrics",
"in",
"time",
"ascending",
"order",
".",
"A",
"copy",
"is",
"made",
"to",
"avoid",
"modifying",
"the",
"input",
"metric",
"slice",
"since",
"doing",
"so",
"is",
"not",
"allowed",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/outputs/stackdriver/stackdriver.go#L104-L113 |
128,125 | influxdata/telegraf | plugins/parsers/wavefront/scanner.go | Scan | func (s *PointScanner) Scan() (Token, string) {
// Read the next rune
ch := s.read()
if isWhitespace(ch) {
return WS, string(ch)
} else if isLetter(ch) {
return LETTER, string(ch)
} else if isNumber(ch) {
return NUMBER, string(ch)
} else if isDelta(ch) {
return DELTA, string(ch)
}
// Otherwise read th... | go | func (s *PointScanner) Scan() (Token, string) {
// Read the next rune
ch := s.read()
if isWhitespace(ch) {
return WS, string(ch)
} else if isLetter(ch) {
return LETTER, string(ch)
} else if isNumber(ch) {
return NUMBER, string(ch)
} else if isDelta(ch) {
return DELTA, string(ch)
}
// Otherwise read th... | [
"func",
"(",
"s",
"*",
"PointScanner",
")",
"Scan",
"(",
")",
"(",
"Token",
",",
"string",
")",
"{",
"// Read the next rune",
"ch",
":=",
"s",
".",
"read",
"(",
")",
"\n",
"if",
"isWhitespace",
"(",
"ch",
")",
"{",
"return",
"WS",
",",
"string",
"(... | // Scan returns the next token and literal value. | [
"Scan",
"returns",
"the",
"next",
"token",
"and",
"literal",
"value",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/parsers/wavefront/scanner.go#L33-L71 |
128,126 | influxdata/telegraf | plugins/inputs/vsphere/finder.go | FindAll | func (f *Finder) FindAll(ctx context.Context, resType string, paths []string, dst interface{}) error {
for _, p := range paths {
if err := f.Find(ctx, resType, p, dst); err != nil {
return err
}
}
return nil
} | go | func (f *Finder) FindAll(ctx context.Context, resType string, paths []string, dst interface{}) error {
for _, p := range paths {
if err := f.Find(ctx, resType, p, dst); err != nil {
return err
}
}
return nil
} | [
"func",
"(",
"f",
"*",
"Finder",
")",
"FindAll",
"(",
"ctx",
"context",
".",
"Context",
",",
"resType",
"string",
",",
"paths",
"[",
"]",
"string",
",",
"dst",
"interface",
"{",
"}",
")",
"error",
"{",
"for",
"_",
",",
"p",
":=",
"range",
"paths",
... | // FindAll returns the union of resources found given the supplied resource type and paths. | [
"FindAll",
"returns",
"the",
"union",
"of",
"resources",
"found",
"given",
"the",
"supplied",
"resource",
"type",
"and",
"paths",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/vsphere/finder.go#L38-L45 |
128,127 | influxdata/telegraf | plugins/inputs/vsphere/finder.go | Find | func (f *Finder) Find(ctx context.Context, resType, path string, dst interface{}) error {
p := strings.Split(path, "/")
flt := make([]property.Filter, len(p)-1)
for i := 1; i < len(p); i++ {
flt[i-1] = property.Filter{"name": p[i]}
}
objs := make(map[string]types.ObjectContent)
err := f.descend(ctx, f.client.Cl... | go | func (f *Finder) Find(ctx context.Context, resType, path string, dst interface{}) error {
p := strings.Split(path, "/")
flt := make([]property.Filter, len(p)-1)
for i := 1; i < len(p); i++ {
flt[i-1] = property.Filter{"name": p[i]}
}
objs := make(map[string]types.ObjectContent)
err := f.descend(ctx, f.client.Cl... | [
"func",
"(",
"f",
"*",
"Finder",
")",
"Find",
"(",
"ctx",
"context",
".",
"Context",
",",
"resType",
",",
"path",
"string",
",",
"dst",
"interface",
"{",
"}",
")",
"error",
"{",
"p",
":=",
"strings",
".",
"Split",
"(",
"path",
",",
"\"",
"\"",
")... | // Find returns the resources matching the specified path. | [
"Find",
"returns",
"the",
"resources",
"matching",
"the",
"specified",
"path",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/vsphere/finder.go#L48-L62 |
128,128 | influxdata/telegraf | plugins/inputs/vsphere/finder.go | FindAll | func (r *ResourceFilter) FindAll(ctx context.Context, dst interface{}) error {
return r.finder.FindAll(ctx, r.resType, r.paths, dst)
} | go | func (r *ResourceFilter) FindAll(ctx context.Context, dst interface{}) error {
return r.finder.FindAll(ctx, r.resType, r.paths, dst)
} | [
"func",
"(",
"r",
"*",
"ResourceFilter",
")",
"FindAll",
"(",
"ctx",
"context",
".",
"Context",
",",
"dst",
"interface",
"{",
"}",
")",
"error",
"{",
"return",
"r",
".",
"finder",
".",
"FindAll",
"(",
"ctx",
",",
"r",
".",
"resType",
",",
"r",
".",... | // FindAll finds all resources matching the paths that were specified upon creation of
// the ResourceFilter. | [
"FindAll",
"finds",
"all",
"resources",
"matching",
"the",
"paths",
"that",
"were",
"specified",
"upon",
"creation",
"of",
"the",
"ResourceFilter",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/vsphere/finder.go#L213-L215 |
128,129 | influxdata/telegraf | plugins/inputs/snmp/snmp.go | execCmd | func execCmd(arg0 string, args ...string) ([]byte, error) {
if wlog.LogLevel() == wlog.DEBUG {
quoted := make([]string, 0, len(args))
for _, arg := range args {
quoted = append(quoted, fmt.Sprintf("%q", arg))
}
log.Printf("D! [inputs.snmp] Executing %q %s", arg0, strings.Join(quoted, " "))
}
out, err := ... | go | func execCmd(arg0 string, args ...string) ([]byte, error) {
if wlog.LogLevel() == wlog.DEBUG {
quoted := make([]string, 0, len(args))
for _, arg := range args {
quoted = append(quoted, fmt.Sprintf("%q", arg))
}
log.Printf("D! [inputs.snmp] Executing %q %s", arg0, strings.Join(quoted, " "))
}
out, err := ... | [
"func",
"execCmd",
"(",
"arg0",
"string",
",",
"args",
"...",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"wlog",
".",
"LogLevel",
"(",
")",
"==",
"wlog",
".",
"DEBUG",
"{",
"quoted",
":=",
"make",
"(",
"[",
"]",
"string",... | // execCmd executes the specified command, returning the STDOUT content.
// If command exits with error status, the output is captured into the returned error. | [
"execCmd",
"executes",
"the",
"specified",
"command",
"returning",
"the",
"STDOUT",
"content",
".",
"If",
"command",
"exits",
"with",
"error",
"status",
"the",
"output",
"is",
"captured",
"into",
"the",
"returned",
"error",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/snmp/snmp.go#L87-L107 |
128,130 | influxdata/telegraf | plugins/inputs/snmp/snmp.go | initBuild | func (t *Table) initBuild() error {
if t.Oid == "" {
return nil
}
_, _, oidText, fields, err := snmpTable(t.Oid)
if err != nil {
return err
}
if t.Name == "" {
t.Name = oidText
}
knownOIDs := map[string]bool{}
for _, f := range t.Fields {
knownOIDs[f.Oid] = true
}
for _, f := range fields {
if !... | go | func (t *Table) initBuild() error {
if t.Oid == "" {
return nil
}
_, _, oidText, fields, err := snmpTable(t.Oid)
if err != nil {
return err
}
if t.Name == "" {
t.Name = oidText
}
knownOIDs := map[string]bool{}
for _, f := range t.Fields {
knownOIDs[f.Oid] = true
}
for _, f := range fields {
if !... | [
"func",
"(",
"t",
"*",
"Table",
")",
"initBuild",
"(",
")",
"error",
"{",
"if",
"t",
".",
"Oid",
"==",
"\"",
"\"",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"_",
",",
"_",
",",
"oidText",
",",
"fields",
",",
"err",
":=",
"snmpTable",
"(",
"t",
... | // initBuild initializes the table if it has an OID configured. If so, the
// net-snmp tools will be used to look up the OID and auto-populate the table's
// fields. | [
"initBuild",
"initializes",
"the",
"table",
"if",
"it",
"has",
"an",
"OID",
"configured",
".",
"If",
"so",
"the",
"net",
"-",
"snmp",
"tools",
"will",
"be",
"used",
"to",
"look",
"up",
"the",
"OID",
"and",
"auto",
"-",
"populate",
"the",
"table",
"s",
... | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/snmp/snmp.go#L221-L246 |
128,131 | influxdata/telegraf | plugins/inputs/snmp/snmp.go | Error | func (ne NestedError) Error() string {
return ne.Err.Error() + ": " + ne.NestedErr.Error()
} | go | func (ne NestedError) Error() string {
return ne.Err.Error() + ": " + ne.NestedErr.Error()
} | [
"func",
"(",
"ne",
"NestedError",
")",
"Error",
"(",
")",
"string",
"{",
"return",
"ne",
".",
"Err",
".",
"Error",
"(",
")",
"+",
"\"",
"\"",
"+",
"ne",
".",
"NestedErr",
".",
"Error",
"(",
")",
"\n",
"}"
] | // Error returns a concatenated string of all the nested errors. | [
"Error",
"returns",
"a",
"concatenated",
"string",
"of",
"all",
"the",
"nested",
"errors",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/snmp/snmp.go#L326-L328 |
128,132 | influxdata/telegraf | plugins/inputs/snmp/snmp.go | Errorf | func Errorf(err error, msg string, format ...interface{}) error {
return NestedError{
NestedErr: err,
Err: fmt.Errorf(msg, format...),
}
} | go | func Errorf(err error, msg string, format ...interface{}) error {
return NestedError{
NestedErr: err,
Err: fmt.Errorf(msg, format...),
}
} | [
"func",
"Errorf",
"(",
"err",
"error",
",",
"msg",
"string",
",",
"format",
"...",
"interface",
"{",
"}",
")",
"error",
"{",
"return",
"NestedError",
"{",
"NestedErr",
":",
"err",
",",
"Err",
":",
"fmt",
".",
"Errorf",
"(",
"msg",
",",
"format",
"...... | // Errorf is a convenience function for constructing a NestedError. | [
"Errorf",
"is",
"a",
"convenience",
"function",
"for",
"constructing",
"a",
"NestedError",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/snmp/snmp.go#L331-L336 |
128,133 | influxdata/telegraf | plugins/inputs/snmp/snmp.go | Gather | func (s *Snmp) Gather(acc telegraf.Accumulator) error {
if err := s.init(); err != nil {
return err
}
var wg sync.WaitGroup
for i, agent := range s.Agents {
wg.Add(1)
go func(i int, agent string) {
defer wg.Done()
gs, err := s.getConnection(i)
if err != nil {
acc.AddError(Errorf(err, "agent %s",... | go | func (s *Snmp) Gather(acc telegraf.Accumulator) error {
if err := s.init(); err != nil {
return err
}
var wg sync.WaitGroup
for i, agent := range s.Agents {
wg.Add(1)
go func(i int, agent string) {
defer wg.Done()
gs, err := s.getConnection(i)
if err != nil {
acc.AddError(Errorf(err, "agent %s",... | [
"func",
"(",
"s",
"*",
"Snmp",
")",
"Gather",
"(",
"acc",
"telegraf",
".",
"Accumulator",
")",
"error",
"{",
"if",
"err",
":=",
"s",
".",
"init",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"var",
"wg",
"sync",
"... | // Gather retrieves all the configured fields and tables.
// Any error encountered does not halt the process. The errors are accumulated
// and returned at the end. | [
"Gather",
"retrieves",
"all",
"the",
"configured",
"fields",
"and",
"tables",
".",
"Any",
"error",
"encountered",
"does",
"not",
"halt",
"the",
"process",
".",
"The",
"errors",
"are",
"accumulated",
"and",
"returned",
"at",
"the",
"end",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/snmp/snmp.go#L364-L401 |
128,134 | influxdata/telegraf | plugins/inputs/snmp/snmp.go | snmpTable | func snmpTable(oid string) (mibName string, oidNum string, oidText string, fields []Field, err error) {
snmpTableCachesLock.Lock()
if snmpTableCaches == nil {
snmpTableCaches = map[string]snmpTableCache{}
}
var stc snmpTableCache
var ok bool
if stc, ok = snmpTableCaches[oid]; !ok {
stc.mibName, stc.oidNum, s... | go | func snmpTable(oid string) (mibName string, oidNum string, oidText string, fields []Field, err error) {
snmpTableCachesLock.Lock()
if snmpTableCaches == nil {
snmpTableCaches = map[string]snmpTableCache{}
}
var stc snmpTableCache
var ok bool
if stc, ok = snmpTableCaches[oid]; !ok {
stc.mibName, stc.oidNum, s... | [
"func",
"snmpTable",
"(",
"oid",
"string",
")",
"(",
"mibName",
"string",
",",
"oidNum",
"string",
",",
"oidText",
"string",
",",
"fields",
"[",
"]",
"Field",
",",
"err",
"error",
")",
"{",
"snmpTableCachesLock",
".",
"Lock",
"(",
")",
"\n",
"if",
"snm... | // snmpTable resolves the given OID as a table, providing information about the
// table and fields within. | [
"snmpTable",
"resolves",
"the",
"given",
"OID",
"as",
"a",
"table",
"providing",
"information",
"about",
"the",
"table",
"and",
"fields",
"within",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/snmp/snmp.go#L863-L878 |
128,135 | influxdata/telegraf | plugins/inputs/snmp/snmp.go | snmpTranslate | func snmpTranslate(oid string) (mibName string, oidNum string, oidText string, conversion string, err error) {
snmpTranslateCachesLock.Lock()
if snmpTranslateCaches == nil {
snmpTranslateCaches = map[string]snmpTranslateCache{}
}
var stc snmpTranslateCache
var ok bool
if stc, ok = snmpTranslateCaches[oid]; !ok... | go | func snmpTranslate(oid string) (mibName string, oidNum string, oidText string, conversion string, err error) {
snmpTranslateCachesLock.Lock()
if snmpTranslateCaches == nil {
snmpTranslateCaches = map[string]snmpTranslateCache{}
}
var stc snmpTranslateCache
var ok bool
if stc, ok = snmpTranslateCaches[oid]; !ok... | [
"func",
"snmpTranslate",
"(",
"oid",
"string",
")",
"(",
"mibName",
"string",
",",
"oidNum",
"string",
",",
"oidText",
"string",
",",
"conversion",
"string",
",",
"err",
"error",
")",
"{",
"snmpTranslateCachesLock",
".",
"Lock",
"(",
")",
"\n",
"if",
"snmp... | // snmpTranslate resolves the given OID. | [
"snmpTranslate",
"resolves",
"the",
"given",
"OID",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/snmp/snmp.go#L951-L975 |
128,136 | influxdata/telegraf | plugins/inputs/sysstat/sysstat.go | withCLocale | func withCLocale(cmd *exec.Cmd) *exec.Cmd {
var env []string
if cmd.Env != nil {
env = cmd.Env
} else {
env = os.Environ()
}
env = filterEnviron(env, "LANG")
env = filterEnviron(env, "LC_")
env = append(env, "LANG=C")
cmd.Env = env
return cmd
} | go | func withCLocale(cmd *exec.Cmd) *exec.Cmd {
var env []string
if cmd.Env != nil {
env = cmd.Env
} else {
env = os.Environ()
}
env = filterEnviron(env, "LANG")
env = filterEnviron(env, "LC_")
env = append(env, "LANG=C")
cmd.Env = env
return cmd
} | [
"func",
"withCLocale",
"(",
"cmd",
"*",
"exec",
".",
"Cmd",
")",
"*",
"exec",
".",
"Cmd",
"{",
"var",
"env",
"[",
"]",
"string",
"\n",
"if",
"cmd",
".",
"Env",
"!=",
"nil",
"{",
"env",
"=",
"cmd",
".",
"Env",
"\n",
"}",
"else",
"{",
"env",
"=... | // Return the Cmd with its environment configured to use the C locale | [
"Return",
"the",
"Cmd",
"with",
"its",
"environment",
"configured",
"to",
"use",
"the",
"C",
"locale"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/sysstat/sysstat.go#L217-L229 |
128,137 | influxdata/telegraf | plugins/inputs/sysstat/sysstat.go | sadfOptions | func (s *Sysstat) sadfOptions(activityOption string) []string {
options := []string{
"-p",
"--",
"-p",
}
opts := strings.Split(activityOption, " ")
options = append(options, opts...)
options = append(options, s.tmpFile)
return options
} | go | func (s *Sysstat) sadfOptions(activityOption string) []string {
options := []string{
"-p",
"--",
"-p",
}
opts := strings.Split(activityOption, " ")
options = append(options, opts...)
options = append(options, s.tmpFile)
return options
} | [
"func",
"(",
"s",
"*",
"Sysstat",
")",
"sadfOptions",
"(",
"activityOption",
"string",
")",
"[",
"]",
"string",
"{",
"options",
":=",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"}",
"\n\n",
"opts",
":=",
"strings",
... | // sadfOptions creates the correct options for the sadf utility. | [
"sadfOptions",
"creates",
"the",
"correct",
"options",
"for",
"the",
"sadf",
"utility",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/sysstat/sysstat.go#L321-L333 |
128,138 | influxdata/telegraf | plugins/inputs/exec/exec.go | removeCarriageReturns | func removeCarriageReturns(b bytes.Buffer) bytes.Buffer {
if runtime.GOOS == "windows" {
var buf bytes.Buffer
for {
byt, er := b.ReadBytes(0x0D)
end := len(byt)
if nil == er {
end -= 1
}
if nil != byt {
buf.Write(byt[:end])
} else {
break
}
if nil != er {
break
}
}
b ... | go | func removeCarriageReturns(b bytes.Buffer) bytes.Buffer {
if runtime.GOOS == "windows" {
var buf bytes.Buffer
for {
byt, er := b.ReadBytes(0x0D)
end := len(byt)
if nil == er {
end -= 1
}
if nil != byt {
buf.Write(byt[:end])
} else {
break
}
if nil != er {
break
}
}
b ... | [
"func",
"removeCarriageReturns",
"(",
"b",
"bytes",
".",
"Buffer",
")",
"bytes",
".",
"Buffer",
"{",
"if",
"runtime",
".",
"GOOS",
"==",
"\"",
"\"",
"{",
"var",
"buf",
"bytes",
".",
"Buffer",
"\n",
"for",
"{",
"byt",
",",
"er",
":=",
"b",
".",
"Rea... | // removeCarriageReturns removes all carriage returns from the input if the
// OS is Windows. It does not return any errors. | [
"removeCarriageReturns",
"removes",
"all",
"carriage",
"returns",
"from",
"the",
"input",
"if",
"the",
"OS",
"is",
"Windows",
".",
"It",
"does",
"not",
"return",
"any",
"errors",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/exec/exec.go#L120-L142 |
128,139 | influxdata/telegraf | plugins/inputs/mesos/mesos.go | gatherMainMetrics | func (m *Mesos) gatherMainMetrics(u *url.URL, role Role, acc telegraf.Accumulator) error {
var jsonOut map[string]interface{}
tags := map[string]string{
"server": u.Hostname(),
"url": urlTag(u),
"role": string(role),
}
resp, err := m.client.Get(withPath(u, "/metrics/snapshot").String())
if err != nil... | go | func (m *Mesos) gatherMainMetrics(u *url.URL, role Role, acc telegraf.Accumulator) error {
var jsonOut map[string]interface{}
tags := map[string]string{
"server": u.Hostname(),
"url": urlTag(u),
"role": string(role),
}
resp, err := m.client.Get(withPath(u, "/metrics/snapshot").String())
if err != nil... | [
"func",
"(",
"m",
"*",
"Mesos",
")",
"gatherMainMetrics",
"(",
"u",
"*",
"url",
".",
"URL",
",",
"role",
"Role",
",",
"acc",
"telegraf",
".",
"Accumulator",
")",
"error",
"{",
"var",
"jsonOut",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"\n\n"... | // This should not belong to the object | [
"This",
"should",
"not",
"belong",
"to",
"the",
"object"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/mesos/mesos.go#L553-L599 |
128,140 | influxdata/telegraf | plugins/inputs/stackdriver/stackdriver.go | ListMetricDescriptors | func (c *stackdriverMetricClient) ListMetricDescriptors(
ctx context.Context,
req *monitoringpb.ListMetricDescriptorsRequest,
) (<-chan *metricpb.MetricDescriptor, error) {
mdChan := make(chan *metricpb.MetricDescriptor, 1000)
go func() {
log.Printf("D! [inputs.stackdriver] ListMetricDescriptors: %s", req.Filter... | go | func (c *stackdriverMetricClient) ListMetricDescriptors(
ctx context.Context,
req *monitoringpb.ListMetricDescriptorsRequest,
) (<-chan *metricpb.MetricDescriptor, error) {
mdChan := make(chan *metricpb.MetricDescriptor, 1000)
go func() {
log.Printf("D! [inputs.stackdriver] ListMetricDescriptors: %s", req.Filter... | [
"func",
"(",
"c",
"*",
"stackdriverMetricClient",
")",
"ListMetricDescriptors",
"(",
"ctx",
"context",
".",
"Context",
",",
"req",
"*",
"monitoringpb",
".",
"ListMetricDescriptorsRequest",
",",
")",
"(",
"<-",
"chan",
"*",
"metricpb",
".",
"MetricDescriptor",
",... | // ListMetricDescriptors implements metricClient interface | [
"ListMetricDescriptors",
"implements",
"metricClient",
"interface"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/stackdriver/stackdriver.go#L202-L228 |
128,141 | influxdata/telegraf | plugins/inputs/stackdriver/stackdriver.go | ListTimeSeries | func (c *stackdriverMetricClient) ListTimeSeries(
ctx context.Context,
req *monitoringpb.ListTimeSeriesRequest,
) (<-chan *monitoringpb.TimeSeries, error) {
tsChan := make(chan *monitoringpb.TimeSeries, 1000)
go func() {
log.Printf("D! [inputs.stackdriver] ListTimeSeries: %s", req.Filter)
defer close(tsChan)
... | go | func (c *stackdriverMetricClient) ListTimeSeries(
ctx context.Context,
req *monitoringpb.ListTimeSeriesRequest,
) (<-chan *monitoringpb.TimeSeries, error) {
tsChan := make(chan *monitoringpb.TimeSeries, 1000)
go func() {
log.Printf("D! [inputs.stackdriver] ListTimeSeries: %s", req.Filter)
defer close(tsChan)
... | [
"func",
"(",
"c",
"*",
"stackdriverMetricClient",
")",
"ListTimeSeries",
"(",
"ctx",
"context",
".",
"Context",
",",
"req",
"*",
"monitoringpb",
".",
"ListTimeSeriesRequest",
",",
")",
"(",
"<-",
"chan",
"*",
"monitoringpb",
".",
"TimeSeries",
",",
"error",
... | // ListTimeSeries implements metricClient interface | [
"ListTimeSeries",
"implements",
"metricClient",
"interface"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/stackdriver/stackdriver.go#L231-L257 |
128,142 | influxdata/telegraf | plugins/inputs/stackdriver/stackdriver.go | updateWindow | func (s *Stackdriver) updateWindow(prevEnd time.Time) (time.Time, time.Time) {
var start time.Time
if s.Window.Duration != 0 {
start = time.Now().Add(-s.Delay.Duration).Add(-s.Window.Duration)
} else if prevEnd.IsZero() {
start = time.Now().Add(-s.Delay.Duration).Add(-defaultWindow.Duration)
} else {
start = ... | go | func (s *Stackdriver) updateWindow(prevEnd time.Time) (time.Time, time.Time) {
var start time.Time
if s.Window.Duration != 0 {
start = time.Now().Add(-s.Delay.Duration).Add(-s.Window.Duration)
} else if prevEnd.IsZero() {
start = time.Now().Add(-s.Delay.Duration).Add(-defaultWindow.Duration)
} else {
start = ... | [
"func",
"(",
"s",
"*",
"Stackdriver",
")",
"updateWindow",
"(",
"prevEnd",
"time",
".",
"Time",
")",
"(",
"time",
".",
"Time",
",",
"time",
".",
"Time",
")",
"{",
"var",
"start",
"time",
".",
"Time",
"\n",
"if",
"s",
".",
"Window",
".",
"Duration",... | // Returns the start and end time for the next collection. | [
"Returns",
"the",
"start",
"and",
"end",
"time",
"for",
"the",
"next",
"collection",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/stackdriver/stackdriver.go#L321-L332 |
128,143 | influxdata/telegraf | plugins/inputs/stackdriver/stackdriver.go | newListTimeSeriesFilter | func (s *Stackdriver) newListTimeSeriesFilter(metricType string) string {
functions := []string{
"starts_with",
"ends_with",
"has_substring",
"one_of",
}
filterString := fmt.Sprintf(`metric.type = "%s"`, metricType)
if s.Filter == nil {
return filterString
}
var valueFmt string
if len(s.Filter.Resourc... | go | func (s *Stackdriver) newListTimeSeriesFilter(metricType string) string {
functions := []string{
"starts_with",
"ends_with",
"has_substring",
"one_of",
}
filterString := fmt.Sprintf(`metric.type = "%s"`, metricType)
if s.Filter == nil {
return filterString
}
var valueFmt string
if len(s.Filter.Resourc... | [
"func",
"(",
"s",
"*",
"Stackdriver",
")",
"newListTimeSeriesFilter",
"(",
"metricType",
"string",
")",
"string",
"{",
"functions",
":=",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"}",
"\n",
"filterS... | // Generate filter string for ListTimeSeriesRequest | [
"Generate",
"filter",
"string",
"for",
"ListTimeSeriesRequest"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/stackdriver/stackdriver.go#L335-L385 |
128,144 | influxdata/telegraf | plugins/inputs/stackdriver/stackdriver.go | newTimeSeriesConf | func (s *Stackdriver) newTimeSeriesConf(
metricType string, startTime, endTime time.Time,
) *timeSeriesConf {
filter := s.newListTimeSeriesFilter(metricType)
interval := &monitoringpb.TimeInterval{
EndTime: &googlepbts.Timestamp{Seconds: endTime.Unix()},
StartTime: &googlepbts.Timestamp{Seconds: startTime.Unix... | go | func (s *Stackdriver) newTimeSeriesConf(
metricType string, startTime, endTime time.Time,
) *timeSeriesConf {
filter := s.newListTimeSeriesFilter(metricType)
interval := &monitoringpb.TimeInterval{
EndTime: &googlepbts.Timestamp{Seconds: endTime.Unix()},
StartTime: &googlepbts.Timestamp{Seconds: startTime.Unix... | [
"func",
"(",
"s",
"*",
"Stackdriver",
")",
"newTimeSeriesConf",
"(",
"metricType",
"string",
",",
"startTime",
",",
"endTime",
"time",
".",
"Time",
",",
")",
"*",
"timeSeriesConf",
"{",
"filter",
":=",
"s",
".",
"newListTimeSeriesFilter",
"(",
"metricType",
... | // Create and initialize a timeSeriesConf for a given GCP metric type with
// defaults taken from the gcp_stackdriver plugin configuration. | [
"Create",
"and",
"initialize",
"a",
"timeSeriesConf",
"for",
"a",
"given",
"GCP",
"metric",
"type",
"with",
"defaults",
"taken",
"from",
"the",
"gcp_stackdriver",
"plugin",
"configuration",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/stackdriver/stackdriver.go#L389-L416 |
128,145 | influxdata/telegraf | plugins/inputs/stackdriver/stackdriver.go | IsValid | func (c *timeSeriesConfCache) IsValid() bool {
return c.TimeSeriesConfs != nil && time.Since(c.Generated) < c.TTL
} | go | func (c *timeSeriesConfCache) IsValid() bool {
return c.TimeSeriesConfs != nil && time.Since(c.Generated) < c.TTL
} | [
"func",
"(",
"c",
"*",
"timeSeriesConfCache",
")",
"IsValid",
"(",
")",
"bool",
"{",
"return",
"c",
".",
"TimeSeriesConfs",
"!=",
"nil",
"&&",
"time",
".",
"Since",
"(",
"c",
".",
"Generated",
")",
"<",
"c",
".",
"TTL",
"\n",
"}"
] | // IsValid checks timeseriesconf cache validity | [
"IsValid",
"checks",
"timeseriesconf",
"cache",
"validity"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/stackdriver/stackdriver.go#L441-L443 |
128,146 | influxdata/telegraf | plugins/inputs/stackdriver/stackdriver.go | includeMetricType | func (s *Stackdriver) includeMetricType(metricType string) bool {
k := metricType
inc := s.MetricTypePrefixInclude
exc := s.MetricTypePrefixExclude
return includeExcludeHelper(k, inc, exc)
} | go | func (s *Stackdriver) includeMetricType(metricType string) bool {
k := metricType
inc := s.MetricTypePrefixInclude
exc := s.MetricTypePrefixExclude
return includeExcludeHelper(k, inc, exc)
} | [
"func",
"(",
"s",
"*",
"Stackdriver",
")",
"includeMetricType",
"(",
"metricType",
"string",
")",
"bool",
"{",
"k",
":=",
"metricType",
"\n",
"inc",
":=",
"s",
".",
"MetricTypePrefixInclude",
"\n",
"exc",
":=",
"s",
".",
"MetricTypePrefixExclude",
"\n\n",
"r... | // Test whether a particular GCP metric type should be scraped by this plugin
// by checking the plugin name against the configuration's
// "includeMetricTypePrefixes" and "excludeMetricTypePrefixes" | [
"Test",
"whether",
"a",
"particular",
"GCP",
"metric",
"type",
"should",
"be",
"scraped",
"by",
"this",
"plugin",
"by",
"checking",
"the",
"plugin",
"name",
"against",
"the",
"configuration",
"s",
"includeMetricTypePrefixes",
"and",
"excludeMetricTypePrefixes"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/stackdriver/stackdriver.go#L493-L499 |
128,147 | influxdata/telegraf | plugins/inputs/stackdriver/stackdriver.go | newListMetricDescriptorsFilters | func (s *Stackdriver) newListMetricDescriptorsFilters() []string {
if len(s.MetricTypePrefixInclude) == 0 {
return nil
}
metricTypeFilters := make([]string, len(s.MetricTypePrefixInclude))
for i, metricTypePrefix := range s.MetricTypePrefixInclude {
metricTypeFilters[i] = fmt.Sprintf(`metric.type = starts_with... | go | func (s *Stackdriver) newListMetricDescriptorsFilters() []string {
if len(s.MetricTypePrefixInclude) == 0 {
return nil
}
metricTypeFilters := make([]string, len(s.MetricTypePrefixInclude))
for i, metricTypePrefix := range s.MetricTypePrefixInclude {
metricTypeFilters[i] = fmt.Sprintf(`metric.type = starts_with... | [
"func",
"(",
"s",
"*",
"Stackdriver",
")",
"newListMetricDescriptorsFilters",
"(",
")",
"[",
"]",
"string",
"{",
"if",
"len",
"(",
"s",
".",
"MetricTypePrefixInclude",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"metricTypeFilters",
":=",
"mak... | // Generates filter for list metric descriptors request | [
"Generates",
"filter",
"for",
"list",
"metric",
"descriptors",
"request"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/stackdriver/stackdriver.go#L502-L512 |
128,148 | influxdata/telegraf | plugins/inputs/stackdriver/stackdriver.go | generatetimeSeriesConfs | func (s *Stackdriver) generatetimeSeriesConfs(
ctx context.Context, startTime, endTime time.Time,
) ([]*timeSeriesConf, error) {
if s.timeSeriesConfCache != nil && s.timeSeriesConfCache.IsValid() {
// Update interval for timeseries requests in timeseries cache
interval := &monitoringpb.TimeInterval{
EndTime: ... | go | func (s *Stackdriver) generatetimeSeriesConfs(
ctx context.Context, startTime, endTime time.Time,
) ([]*timeSeriesConf, error) {
if s.timeSeriesConfCache != nil && s.timeSeriesConfCache.IsValid() {
// Update interval for timeseries requests in timeseries cache
interval := &monitoringpb.TimeInterval{
EndTime: ... | [
"func",
"(",
"s",
"*",
"Stackdriver",
")",
"generatetimeSeriesConfs",
"(",
"ctx",
"context",
".",
"Context",
",",
"startTime",
",",
"endTime",
"time",
".",
"Time",
",",
")",
"(",
"[",
"]",
"*",
"timeSeriesConf",
",",
"error",
")",
"{",
"if",
"s",
".",
... | // Generate a list of timeSeriesConfig structs by making a ListMetricDescriptors
// API request and filtering the result against our configuration. | [
"Generate",
"a",
"list",
"of",
"timeSeriesConfig",
"structs",
"by",
"making",
"a",
"ListMetricDescriptors",
"API",
"request",
"and",
"filtering",
"the",
"result",
"against",
"our",
"configuration",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/stackdriver/stackdriver.go#L516-L583 |
128,149 | influxdata/telegraf | plugins/inputs/stackdriver/stackdriver.go | gatherTimeSeries | func (s *Stackdriver) gatherTimeSeries(
ctx context.Context, grouper *lockedSeriesGrouper, tsConf *timeSeriesConf,
) error {
tsReq := tsConf.listTimeSeriesRequest
tsRespChan, err := s.client.ListTimeSeries(ctx, tsReq)
if err != nil {
return err
}
for tsDesc := range tsRespChan {
tags := map[string]string{
... | go | func (s *Stackdriver) gatherTimeSeries(
ctx context.Context, grouper *lockedSeriesGrouper, tsConf *timeSeriesConf,
) error {
tsReq := tsConf.listTimeSeriesRequest
tsRespChan, err := s.client.ListTimeSeries(ctx, tsReq)
if err != nil {
return err
}
for tsDesc := range tsRespChan {
tags := map[string]string{
... | [
"func",
"(",
"s",
"*",
"Stackdriver",
")",
"gatherTimeSeries",
"(",
"ctx",
"context",
".",
"Context",
",",
"grouper",
"*",
"lockedSeriesGrouper",
",",
"tsConf",
"*",
"timeSeriesConf",
",",
")",
"error",
"{",
"tsReq",
":=",
"tsConf",
".",
"listTimeSeriesRequest... | // Do the work to gather an individual time series. Runs inside a
// timeseries-specific goroutine. | [
"Do",
"the",
"work",
"to",
"gather",
"an",
"individual",
"time",
"series",
".",
"Runs",
"inside",
"a",
"timeseries",
"-",
"specific",
"goroutine",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/stackdriver/stackdriver.go#L587-L636 |
128,150 | influxdata/telegraf | plugins/inputs/stackdriver/stackdriver.go | addDistribution | func (s *Stackdriver) addDistribution(
metric *distributionpb.Distribution,
tags map[string]string, ts time.Time, grouper *lockedSeriesGrouper, tsConf *timeSeriesConf,
) {
field := tsConf.fieldKey
name := tsConf.measurement
grouper.Add(name, tags, ts, field+"_count", metric.Count)
grouper.Add(name, tags, ts, fie... | go | func (s *Stackdriver) addDistribution(
metric *distributionpb.Distribution,
tags map[string]string, ts time.Time, grouper *lockedSeriesGrouper, tsConf *timeSeriesConf,
) {
field := tsConf.fieldKey
name := tsConf.measurement
grouper.Add(name, tags, ts, field+"_count", metric.Count)
grouper.Add(name, tags, ts, fie... | [
"func",
"(",
"s",
"*",
"Stackdriver",
")",
"addDistribution",
"(",
"metric",
"*",
"distributionpb",
".",
"Distribution",
",",
"tags",
"map",
"[",
"string",
"]",
"string",
",",
"ts",
"time",
".",
"Time",
",",
"grouper",
"*",
"lockedSeriesGrouper",
",",
"tsC... | // AddDistribution adds metrics from a distribution value type. | [
"AddDistribution",
"adds",
"metrics",
"from",
"a",
"distribution",
"value",
"type",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/stackdriver/stackdriver.go#L639-L695 |
128,151 | influxdata/telegraf | plugins/inputs/jolokia2/gatherer.go | Gather | func (g *Gatherer) Gather(client *Client, acc telegraf.Accumulator) error {
var tags map[string]string
if client.config.ProxyConfig != nil {
tags = map[string]string{"jolokia_proxy_url": client.URL}
} else {
tags = map[string]string{"jolokia_agent_url": client.URL}
}
requests := makeReadRequests(g.metrics)
... | go | func (g *Gatherer) Gather(client *Client, acc telegraf.Accumulator) error {
var tags map[string]string
if client.config.ProxyConfig != nil {
tags = map[string]string{"jolokia_proxy_url": client.URL}
} else {
tags = map[string]string{"jolokia_agent_url": client.URL}
}
requests := makeReadRequests(g.metrics)
... | [
"func",
"(",
"g",
"*",
"Gatherer",
")",
"Gather",
"(",
"client",
"*",
"Client",
",",
"acc",
"telegraf",
".",
"Accumulator",
")",
"error",
"{",
"var",
"tags",
"map",
"[",
"string",
"]",
"string",
"\n\n",
"if",
"client",
".",
"config",
".",
"ProxyConfig"... | // Gather adds points to an accumulator from responses returned
// by a Jolokia agent. | [
"Gather",
"adds",
"points",
"to",
"an",
"accumulator",
"from",
"responses",
"returned",
"by",
"a",
"Jolokia",
"agent",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/jolokia2/gatherer.go#L27-L44 |
128,152 | influxdata/telegraf | plugins/inputs/jolokia2/gatherer.go | gatherResponses | func (g *Gatherer) gatherResponses(responses []ReadResponse, tags map[string]string, acc telegraf.Accumulator) {
series := make(map[string][]point, 0)
for _, metric := range g.metrics {
points, ok := series[metric.Name]
if !ok {
points = make([]point, 0)
}
responsePoints, responseErrors := g.generatePoin... | go | func (g *Gatherer) gatherResponses(responses []ReadResponse, tags map[string]string, acc telegraf.Accumulator) {
series := make(map[string][]point, 0)
for _, metric := range g.metrics {
points, ok := series[metric.Name]
if !ok {
points = make([]point, 0)
}
responsePoints, responseErrors := g.generatePoin... | [
"func",
"(",
"g",
"*",
"Gatherer",
")",
"gatherResponses",
"(",
"responses",
"[",
"]",
"ReadResponse",
",",
"tags",
"map",
"[",
"string",
"]",
"string",
",",
"acc",
"telegraf",
".",
"Accumulator",
")",
"{",
"series",
":=",
"make",
"(",
"map",
"[",
"str... | // gatherReponses adds points to an accumulator from the ReadResponse objects
// returned by a Jolokia agent. | [
"gatherReponses",
"adds",
"points",
"to",
"an",
"accumulator",
"from",
"the",
"ReadResponse",
"objects",
"returned",
"by",
"a",
"Jolokia",
"agent",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/jolokia2/gatherer.go#L48-L76 |
128,153 | influxdata/telegraf | plugins/inputs/jolokia2/gatherer.go | generatePoints | func (g *Gatherer) generatePoints(metric Metric, responses []ReadResponse) ([]point, []error) {
points := make([]point, 0)
errors := make([]error, 0)
for _, response := range responses {
switch response.Status {
case 200:
break
case 404:
continue
default:
errors = append(errors, fmt.Errorf("Unexpec... | go | func (g *Gatherer) generatePoints(metric Metric, responses []ReadResponse) ([]point, []error) {
points := make([]point, 0)
errors := make([]error, 0)
for _, response := range responses {
switch response.Status {
case 200:
break
case 404:
continue
default:
errors = append(errors, fmt.Errorf("Unexpec... | [
"func",
"(",
"g",
"*",
"Gatherer",
")",
"generatePoints",
"(",
"metric",
"Metric",
",",
"responses",
"[",
"]",
"ReadResponse",
")",
"(",
"[",
"]",
"point",
",",
"[",
"]",
"error",
")",
"{",
"points",
":=",
"make",
"(",
"[",
"]",
"point",
",",
"0",
... | // generatePoints creates points for the supplied metric from the ReadResponse
// objects returned by the Jolokia client. | [
"generatePoints",
"creates",
"points",
"for",
"the",
"supplied",
"metric",
"from",
"the",
"ReadResponse",
"objects",
"returned",
"by",
"the",
"Jolokia",
"client",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/jolokia2/gatherer.go#L80-L111 |
128,154 | influxdata/telegraf | plugins/inputs/jolokia2/gatherer.go | mergeTags | func mergeTags(metricTags, outerTags map[string]string) map[string]string {
tags := make(map[string]string)
for k, v := range outerTags {
tags[k] = v
}
for k, v := range metricTags {
tags[k] = v
}
return tags
} | go | func mergeTags(metricTags, outerTags map[string]string) map[string]string {
tags := make(map[string]string)
for k, v := range outerTags {
tags[k] = v
}
for k, v := range metricTags {
tags[k] = v
}
return tags
} | [
"func",
"mergeTags",
"(",
"metricTags",
",",
"outerTags",
"map",
"[",
"string",
"]",
"string",
")",
"map",
"[",
"string",
"]",
"string",
"{",
"tags",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
")",
"\n",
"for",
"k",
",",
"v",
":=",
"ra... | // mergeTags combines two tag sets into a single tag set. | [
"mergeTags",
"combines",
"two",
"tag",
"sets",
"into",
"a",
"single",
"tag",
"set",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/jolokia2/gatherer.go#L114-L124 |
128,155 | influxdata/telegraf | plugins/inputs/jolokia2/gatherer.go | metricMatchesResponse | func metricMatchesResponse(metric Metric, response ReadResponse) bool {
if !metric.MatchObjectName(response.RequestMbean) {
return false
}
if len(metric.Paths) == 0 {
return len(response.RequestAttributes) == 0
}
for _, attribute := range response.RequestAttributes {
if metric.MatchAttributeAndPath(attribu... | go | func metricMatchesResponse(metric Metric, response ReadResponse) bool {
if !metric.MatchObjectName(response.RequestMbean) {
return false
}
if len(metric.Paths) == 0 {
return len(response.RequestAttributes) == 0
}
for _, attribute := range response.RequestAttributes {
if metric.MatchAttributeAndPath(attribu... | [
"func",
"metricMatchesResponse",
"(",
"metric",
"Metric",
",",
"response",
"ReadResponse",
")",
"bool",
"{",
"if",
"!",
"metric",
".",
"MatchObjectName",
"(",
"response",
".",
"RequestMbean",
")",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
... | // metricMatchesResponse returns true when the name, attributes, and path
// of a Metric match the corresponding elements in a ReadResponse object
// returned by a Jolokia agent. | [
"metricMatchesResponse",
"returns",
"true",
"when",
"the",
"name",
"attributes",
"and",
"path",
"of",
"a",
"Metric",
"match",
"the",
"corresponding",
"elements",
"in",
"a",
"ReadResponse",
"object",
"returned",
"by",
"a",
"Jolokia",
"agent",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/jolokia2/gatherer.go#L129-L145 |
128,156 | influxdata/telegraf | plugins/inputs/jolokia2/gatherer.go | compactPoints | func compactPoints(points []point) []point {
compactedPoints := make([]point, 0)
for _, sourcePoint := range points {
keepPoint := true
for _, compactPoint := range compactedPoints {
if !tagSetsMatch(sourcePoint.Tags, compactPoint.Tags) {
continue
}
keepPoint = false
for key, val := range sourc... | go | func compactPoints(points []point) []point {
compactedPoints := make([]point, 0)
for _, sourcePoint := range points {
keepPoint := true
for _, compactPoint := range compactedPoints {
if !tagSetsMatch(sourcePoint.Tags, compactPoint.Tags) {
continue
}
keepPoint = false
for key, val := range sourc... | [
"func",
"compactPoints",
"(",
"points",
"[",
"]",
"point",
")",
"[",
"]",
"point",
"{",
"compactedPoints",
":=",
"make",
"(",
"[",
"]",
"point",
",",
"0",
")",
"\n\n",
"for",
"_",
",",
"sourcePoint",
":=",
"range",
"points",
"{",
"keepPoint",
":=",
"... | // compactPoints attepts to remove points by compacting points
// with matching tag sets. When a match is found, the fields from
// one point are moved to another, and the empty point is removed. | [
"compactPoints",
"attepts",
"to",
"remove",
"points",
"by",
"compacting",
"points",
"with",
"matching",
"tag",
"sets",
".",
"When",
"a",
"match",
"is",
"found",
"the",
"fields",
"from",
"one",
"point",
"are",
"moved",
"to",
"another",
"and",
"the",
"empty",
... | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/jolokia2/gatherer.go#L150-L173 |
128,157 | influxdata/telegraf | plugins/inputs/jolokia2/gatherer.go | tagSetsMatch | func tagSetsMatch(a, b map[string]string) bool {
if len(a) != len(b) {
return false
}
for ak, av := range a {
bv, ok := b[ak]
if !ok {
return false
}
if av != bv {
return false
}
}
return true
} | go | func tagSetsMatch(a, b map[string]string) bool {
if len(a) != len(b) {
return false
}
for ak, av := range a {
bv, ok := b[ak]
if !ok {
return false
}
if av != bv {
return false
}
}
return true
} | [
"func",
"tagSetsMatch",
"(",
"a",
",",
"b",
"map",
"[",
"string",
"]",
"string",
")",
"bool",
"{",
"if",
"len",
"(",
"a",
")",
"!=",
"len",
"(",
"b",
")",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"for",
"ak",
",",
"av",
":=",
"range",
"a",
... | // tagSetsMatch returns true if two maps are equivalent. | [
"tagSetsMatch",
"returns",
"true",
"if",
"two",
"maps",
"are",
"equivalent",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/jolokia2/gatherer.go#L176-L192 |
128,158 | influxdata/telegraf | plugins/inputs/jolokia2/gatherer.go | makeReadRequests | func makeReadRequests(metrics []Metric) []ReadRequest {
var requests []ReadRequest
for _, metric := range metrics {
if len(metric.Paths) == 0 {
requests = append(requests, ReadRequest{
Mbean: metric.Mbean,
Attributes: []string{},
})
} else {
attributes := make(map[string][]string)
for _... | go | func makeReadRequests(metrics []Metric) []ReadRequest {
var requests []ReadRequest
for _, metric := range metrics {
if len(metric.Paths) == 0 {
requests = append(requests, ReadRequest{
Mbean: metric.Mbean,
Attributes: []string{},
})
} else {
attributes := make(map[string][]string)
for _... | [
"func",
"makeReadRequests",
"(",
"metrics",
"[",
"]",
"Metric",
")",
"[",
"]",
"ReadRequest",
"{",
"var",
"requests",
"[",
"]",
"ReadRequest",
"\n",
"for",
"_",
",",
"metric",
":=",
"range",
"metrics",
"{",
"if",
"len",
"(",
"metric",
".",
"Paths",
")"... | // makeReadRequests creates ReadRequest objects from metrics definitions. | [
"makeReadRequests",
"creates",
"ReadRequest",
"objects",
"from",
"metrics",
"definitions",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/jolokia2/gatherer.go#L195-L242 |
128,159 | influxdata/telegraf | plugins/aggregators/histogram/histogram.go | NewHistogramAggregator | func NewHistogramAggregator() telegraf.Aggregator {
h := &HistogramAggregator{}
h.buckets = make(bucketsByMetrics)
h.resetCache()
return h
} | go | func NewHistogramAggregator() telegraf.Aggregator {
h := &HistogramAggregator{}
h.buckets = make(bucketsByMetrics)
h.resetCache()
return h
} | [
"func",
"NewHistogramAggregator",
"(",
")",
"telegraf",
".",
"Aggregator",
"{",
"h",
":=",
"&",
"HistogramAggregator",
"{",
"}",
"\n",
"h",
".",
"buckets",
"=",
"make",
"(",
"bucketsByMetrics",
")",
"\n",
"h",
".",
"resetCache",
"(",
")",
"\n\n",
"return",... | // NewHistogramAggregator creates new histogram aggregator | [
"NewHistogramAggregator",
"creates",
"new",
"histogram",
"aggregator"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/aggregators/histogram/histogram.go#L60-L66 |
128,160 | influxdata/telegraf | plugins/aggregators/histogram/histogram.go | Add | func (h *HistogramAggregator) Add(in telegraf.Metric) {
bucketsByField := make(map[string][]float64)
for field := range in.Fields() {
buckets := h.getBuckets(in.Name(), field)
if buckets != nil {
bucketsByField[field] = buckets
}
}
if len(bucketsByField) == 0 {
return
}
id := in.HashID()
agr, ok := ... | go | func (h *HistogramAggregator) Add(in telegraf.Metric) {
bucketsByField := make(map[string][]float64)
for field := range in.Fields() {
buckets := h.getBuckets(in.Name(), field)
if buckets != nil {
bucketsByField[field] = buckets
}
}
if len(bucketsByField) == 0 {
return
}
id := in.HashID()
agr, ok := ... | [
"func",
"(",
"h",
"*",
"HistogramAggregator",
")",
"Add",
"(",
"in",
"telegraf",
".",
"Metric",
")",
"{",
"bucketsByField",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"[",
"]",
"float64",
")",
"\n",
"for",
"field",
":=",
"range",
"in",
".",
"Field... | // Add adds new hit to the buckets | [
"Add",
"adds",
"new",
"hit",
"to",
"the",
"buckets"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/aggregators/histogram/histogram.go#L108-L145 |
128,161 | influxdata/telegraf | plugins/aggregators/histogram/histogram.go | Push | func (h *HistogramAggregator) Push(acc telegraf.Accumulator) {
metricsWithGroupedFields := []groupedByCountFields{}
for _, aggregate := range h.cache {
for field, counts := range aggregate.histogramCollection {
h.groupFieldsByBuckets(&metricsWithGroupedFields, aggregate.name, field, copyTags(aggregate.tags), co... | go | func (h *HistogramAggregator) Push(acc telegraf.Accumulator) {
metricsWithGroupedFields := []groupedByCountFields{}
for _, aggregate := range h.cache {
for field, counts := range aggregate.histogramCollection {
h.groupFieldsByBuckets(&metricsWithGroupedFields, aggregate.name, field, copyTags(aggregate.tags), co... | [
"func",
"(",
"h",
"*",
"HistogramAggregator",
")",
"Push",
"(",
"acc",
"telegraf",
".",
"Accumulator",
")",
"{",
"metricsWithGroupedFields",
":=",
"[",
"]",
"groupedByCountFields",
"{",
"}",
"\n\n",
"for",
"_",
",",
"aggregate",
":=",
"range",
"h",
".",
"c... | // Push returns histogram values for metrics | [
"Push",
"returns",
"histogram",
"values",
"for",
"metrics"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/aggregators/histogram/histogram.go#L148-L160 |
128,162 | influxdata/telegraf | plugins/aggregators/histogram/histogram.go | groupFieldsByBuckets | func (h *HistogramAggregator) groupFieldsByBuckets(
metricsWithGroupedFields *[]groupedByCountFields,
name string,
field string,
tags map[string]string,
counts []int64,
) {
count := int64(0)
for index, bucket := range h.getBuckets(name, field) {
count += counts[index]
tags[bucketTag] = strconv.FormatFloat(b... | go | func (h *HistogramAggregator) groupFieldsByBuckets(
metricsWithGroupedFields *[]groupedByCountFields,
name string,
field string,
tags map[string]string,
counts []int64,
) {
count := int64(0)
for index, bucket := range h.getBuckets(name, field) {
count += counts[index]
tags[bucketTag] = strconv.FormatFloat(b... | [
"func",
"(",
"h",
"*",
"HistogramAggregator",
")",
"groupFieldsByBuckets",
"(",
"metricsWithGroupedFields",
"*",
"[",
"]",
"groupedByCountFields",
",",
"name",
"string",
",",
"field",
"string",
",",
"tags",
"map",
"[",
"string",
"]",
"string",
",",
"counts",
"... | // groupFieldsByBuckets groups fields by metric buckets which are represented as tags | [
"groupFieldsByBuckets",
"groups",
"fields",
"by",
"metric",
"buckets",
"which",
"are",
"represented",
"as",
"tags"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/aggregators/histogram/histogram.go#L163-L182 |
128,163 | influxdata/telegraf | plugins/aggregators/histogram/histogram.go | groupField | func (h *HistogramAggregator) groupField(
metricsWithGroupedFields *[]groupedByCountFields,
name string,
field string,
count int64,
tags map[string]string,
) {
for key, metric := range *metricsWithGroupedFields {
if name == metric.name && isTagsIdentical(tags, metric.tags) {
(*metricsWithGroupedFields)[key].... | go | func (h *HistogramAggregator) groupField(
metricsWithGroupedFields *[]groupedByCountFields,
name string,
field string,
count int64,
tags map[string]string,
) {
for key, metric := range *metricsWithGroupedFields {
if name == metric.name && isTagsIdentical(tags, metric.tags) {
(*metricsWithGroupedFields)[key].... | [
"func",
"(",
"h",
"*",
"HistogramAggregator",
")",
"groupField",
"(",
"metricsWithGroupedFields",
"*",
"[",
"]",
"groupedByCountFields",
",",
"name",
"string",
",",
"field",
"string",
",",
"count",
"int64",
",",
"tags",
"map",
"[",
"string",
"]",
"string",
"... | // groupField groups field by count value | [
"groupField",
"groups",
"field",
"by",
"count",
"value"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/aggregators/histogram/histogram.go#L185-L207 |
128,164 | influxdata/telegraf | plugins/aggregators/histogram/histogram.go | Reset | func (h *HistogramAggregator) Reset() {
if h.ResetBuckets {
h.resetCache()
h.buckets = make(bucketsByMetrics)
}
} | go | func (h *HistogramAggregator) Reset() {
if h.ResetBuckets {
h.resetCache()
h.buckets = make(bucketsByMetrics)
}
} | [
"func",
"(",
"h",
"*",
"HistogramAggregator",
")",
"Reset",
"(",
")",
"{",
"if",
"h",
".",
"ResetBuckets",
"{",
"h",
".",
"resetCache",
"(",
")",
"\n",
"h",
".",
"buckets",
"=",
"make",
"(",
"bucketsByMetrics",
")",
"\n",
"}",
"\n",
"}"
] | // Reset does nothing by default, because we typically need to collect counts for a long time.
// Otherwise if config parameter 'reset' has 'true' value, we will get a histogram
// with a small amount of the distribution. However in some use cases a reset is useful. | [
"Reset",
"does",
"nothing",
"by",
"default",
"because",
"we",
"typically",
"need",
"to",
"collect",
"counts",
"for",
"a",
"long",
"time",
".",
"Otherwise",
"if",
"config",
"parameter",
"reset",
"has",
"true",
"value",
"we",
"will",
"get",
"a",
"histogram",
... | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/aggregators/histogram/histogram.go#L212-L217 |
128,165 | influxdata/telegraf | plugins/aggregators/histogram/histogram.go | getBuckets | func (h *HistogramAggregator) getBuckets(metric string, field string) []float64 {
if buckets, ok := h.buckets[metric][field]; ok {
return buckets
}
for _, config := range h.Configs {
if config.Metric == metric {
if !isBucketExists(field, config) {
continue
}
if _, ok := h.buckets[metric]; !ok {
... | go | func (h *HistogramAggregator) getBuckets(metric string, field string) []float64 {
if buckets, ok := h.buckets[metric][field]; ok {
return buckets
}
for _, config := range h.Configs {
if config.Metric == metric {
if !isBucketExists(field, config) {
continue
}
if _, ok := h.buckets[metric]; !ok {
... | [
"func",
"(",
"h",
"*",
"HistogramAggregator",
")",
"getBuckets",
"(",
"metric",
"string",
",",
"field",
"string",
")",
"[",
"]",
"float64",
"{",
"if",
"buckets",
",",
"ok",
":=",
"h",
".",
"buckets",
"[",
"metric",
"]",
"[",
"field",
"]",
";",
"ok",
... | // getBuckets finds buckets and returns them | [
"getBuckets",
"finds",
"buckets",
"and",
"returns",
"them"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/aggregators/histogram/histogram.go#L225-L245 |
128,166 | influxdata/telegraf | plugins/aggregators/histogram/histogram.go | isBucketExists | func isBucketExists(field string, cfg config) bool {
if len(cfg.Fields) == 0 {
return true
}
for _, fl := range cfg.Fields {
if fl == field {
return true
}
}
return false
} | go | func isBucketExists(field string, cfg config) bool {
if len(cfg.Fields) == 0 {
return true
}
for _, fl := range cfg.Fields {
if fl == field {
return true
}
}
return false
} | [
"func",
"isBucketExists",
"(",
"field",
"string",
",",
"cfg",
"config",
")",
"bool",
"{",
"if",
"len",
"(",
"cfg",
".",
"Fields",
")",
"==",
"0",
"{",
"return",
"true",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"fl",
":=",
"range",
"cfg",
".",
"Fields",
... | // isBucketExists checks if buckets exists for the passed field | [
"isBucketExists",
"checks",
"if",
"buckets",
"exists",
"for",
"the",
"passed",
"field"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/aggregators/histogram/histogram.go#L248-L260 |
128,167 | influxdata/telegraf | plugins/aggregators/histogram/histogram.go | sortBuckets | func sortBuckets(buckets []float64) []float64 {
for i, bucket := range buckets {
if i < len(buckets)-1 && bucket >= buckets[i+1] {
sort.Float64s(buckets)
break
}
}
return buckets
} | go | func sortBuckets(buckets []float64) []float64 {
for i, bucket := range buckets {
if i < len(buckets)-1 && bucket >= buckets[i+1] {
sort.Float64s(buckets)
break
}
}
return buckets
} | [
"func",
"sortBuckets",
"(",
"buckets",
"[",
"]",
"float64",
")",
"[",
"]",
"float64",
"{",
"for",
"i",
",",
"bucket",
":=",
"range",
"buckets",
"{",
"if",
"i",
"<",
"len",
"(",
"buckets",
")",
"-",
"1",
"&&",
"bucket",
">=",
"buckets",
"[",
"i",
... | // sortBuckets sorts the buckets if it is needed | [
"sortBuckets",
"sorts",
"the",
"buckets",
"if",
"it",
"is",
"needed"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/aggregators/histogram/histogram.go#L263-L272 |
128,168 | influxdata/telegraf | plugins/aggregators/histogram/histogram.go | copyTags | func copyTags(tags map[string]string) map[string]string {
copiedTags := map[string]string{}
for key, val := range tags {
copiedTags[key] = val
}
return copiedTags
} | go | func copyTags(tags map[string]string) map[string]string {
copiedTags := map[string]string{}
for key, val := range tags {
copiedTags[key] = val
}
return copiedTags
} | [
"func",
"copyTags",
"(",
"tags",
"map",
"[",
"string",
"]",
"string",
")",
"map",
"[",
"string",
"]",
"string",
"{",
"copiedTags",
":=",
"map",
"[",
"string",
"]",
"string",
"{",
"}",
"\n",
"for",
"key",
",",
"val",
":=",
"range",
"tags",
"{",
"cop... | // copyTags copies tags | [
"copyTags",
"copies",
"tags"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/aggregators/histogram/histogram.go#L287-L294 |
128,169 | influxdata/telegraf | plugins/aggregators/histogram/histogram.go | isTagsIdentical | func isTagsIdentical(originalTags, checkedTags map[string]string) bool {
if len(originalTags) != len(checkedTags) {
return false
}
for tagName, tagValue := range originalTags {
if tagValue != checkedTags[tagName] {
return false
}
}
return true
} | go | func isTagsIdentical(originalTags, checkedTags map[string]string) bool {
if len(originalTags) != len(checkedTags) {
return false
}
for tagName, tagValue := range originalTags {
if tagValue != checkedTags[tagName] {
return false
}
}
return true
} | [
"func",
"isTagsIdentical",
"(",
"originalTags",
",",
"checkedTags",
"map",
"[",
"string",
"]",
"string",
")",
"bool",
"{",
"if",
"len",
"(",
"originalTags",
")",
"!=",
"len",
"(",
"checkedTags",
")",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"for",
"tag... | // isTagsIdentical checks the identity of two list of tags | [
"isTagsIdentical",
"checks",
"the",
"identity",
"of",
"two",
"list",
"of",
"tags"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/aggregators/histogram/histogram.go#L297-L309 |
128,170 | influxdata/telegraf | plugins/aggregators/histogram/histogram.go | makeFieldsWithCount | func makeFieldsWithCount(fieldsWithCountIn map[string]int64) map[string]interface{} {
fieldsWithCountOut := map[string]interface{}{}
for field, count := range fieldsWithCountIn {
fieldsWithCountOut[field+"_bucket"] = count
}
return fieldsWithCountOut
} | go | func makeFieldsWithCount(fieldsWithCountIn map[string]int64) map[string]interface{} {
fieldsWithCountOut := map[string]interface{}{}
for field, count := range fieldsWithCountIn {
fieldsWithCountOut[field+"_bucket"] = count
}
return fieldsWithCountOut
} | [
"func",
"makeFieldsWithCount",
"(",
"fieldsWithCountIn",
"map",
"[",
"string",
"]",
"int64",
")",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"fieldsWithCountOut",
":=",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"}",
"\n",
"for",
... | // makeFieldsWithCount assigns count value to all metric fields | [
"makeFieldsWithCount",
"assigns",
"count",
"value",
"to",
"all",
"metric",
"fields"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/aggregators/histogram/histogram.go#L312-L319 |
128,171 | influxdata/telegraf | internal/config/config.go | InputNames | func (c *Config) InputNames() []string {
var name []string
for _, input := range c.Inputs {
name = append(name, input.Config.Name)
}
return name
} | go | func (c *Config) InputNames() []string {
var name []string
for _, input := range c.Inputs {
name = append(name, input.Config.Name)
}
return name
} | [
"func",
"(",
"c",
"*",
"Config",
")",
"InputNames",
"(",
")",
"[",
"]",
"string",
"{",
"var",
"name",
"[",
"]",
"string",
"\n",
"for",
"_",
",",
"input",
":=",
"range",
"c",
".",
"Inputs",
"{",
"name",
"=",
"append",
"(",
"name",
",",
"input",
... | // Inputs returns a list of strings of the configured inputs. | [
"Inputs",
"returns",
"a",
"list",
"of",
"strings",
"of",
"the",
"configured",
"inputs",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/internal/config/config.go#L155-L161 |
128,172 | influxdata/telegraf | internal/config/config.go | AggregatorNames | func (c *Config) AggregatorNames() []string {
var name []string
for _, aggregator := range c.Aggregators {
name = append(name, aggregator.Config.Name)
}
return name
} | go | func (c *Config) AggregatorNames() []string {
var name []string
for _, aggregator := range c.Aggregators {
name = append(name, aggregator.Config.Name)
}
return name
} | [
"func",
"(",
"c",
"*",
"Config",
")",
"AggregatorNames",
"(",
")",
"[",
"]",
"string",
"{",
"var",
"name",
"[",
"]",
"string",
"\n",
"for",
"_",
",",
"aggregator",
":=",
"range",
"c",
".",
"Aggregators",
"{",
"name",
"=",
"append",
"(",
"name",
","... | // Outputs returns a list of strings of the configured aggregators. | [
"Outputs",
"returns",
"a",
"list",
"of",
"strings",
"of",
"the",
"configured",
"aggregators",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/internal/config/config.go#L164-L170 |
128,173 | influxdata/telegraf | internal/config/config.go | ProcessorNames | func (c *Config) ProcessorNames() []string {
var name []string
for _, processor := range c.Processors {
name = append(name, processor.Name)
}
return name
} | go | func (c *Config) ProcessorNames() []string {
var name []string
for _, processor := range c.Processors {
name = append(name, processor.Name)
}
return name
} | [
"func",
"(",
"c",
"*",
"Config",
")",
"ProcessorNames",
"(",
")",
"[",
"]",
"string",
"{",
"var",
"name",
"[",
"]",
"string",
"\n",
"for",
"_",
",",
"processor",
":=",
"range",
"c",
".",
"Processors",
"{",
"name",
"=",
"append",
"(",
"name",
",",
... | // Outputs returns a list of strings of the configured processors. | [
"Outputs",
"returns",
"a",
"list",
"of",
"strings",
"of",
"the",
"configured",
"processors",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/internal/config/config.go#L173-L179 |
128,174 | influxdata/telegraf | internal/config/config.go | OutputNames | func (c *Config) OutputNames() []string {
var name []string
for _, output := range c.Outputs {
name = append(name, output.Name)
}
return name
} | go | func (c *Config) OutputNames() []string {
var name []string
for _, output := range c.Outputs {
name = append(name, output.Name)
}
return name
} | [
"func",
"(",
"c",
"*",
"Config",
")",
"OutputNames",
"(",
")",
"[",
"]",
"string",
"{",
"var",
"name",
"[",
"]",
"string",
"\n",
"for",
"_",
",",
"output",
":=",
"range",
"c",
".",
"Outputs",
"{",
"name",
"=",
"append",
"(",
"name",
",",
"output"... | // Outputs returns a list of strings of the configured outputs. | [
"Outputs",
"returns",
"a",
"list",
"of",
"strings",
"of",
"the",
"configured",
"outputs",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/internal/config/config.go#L182-L188 |
128,175 | influxdata/telegraf | internal/config/config.go | ListTags | func (c *Config) ListTags() string {
var tags []string
for k, v := range c.Tags {
tags = append(tags, fmt.Sprintf("%s=%s", k, v))
}
sort.Strings(tags)
return strings.Join(tags, " ")
} | go | func (c *Config) ListTags() string {
var tags []string
for k, v := range c.Tags {
tags = append(tags, fmt.Sprintf("%s=%s", k, v))
}
sort.Strings(tags)
return strings.Join(tags, " ")
} | [
"func",
"(",
"c",
"*",
"Config",
")",
"ListTags",
"(",
")",
"string",
"{",
"var",
"tags",
"[",
"]",
"string",
"\n\n",
"for",
"k",
",",
"v",
":=",
"range",
"c",
".",
"Tags",
"{",
"tags",
"=",
"append",
"(",
"tags",
",",
"fmt",
".",
"Sprintf",
"(... | // ListTags returns a string of tags specified in the config,
// line-protocol style | [
"ListTags",
"returns",
"a",
"string",
"of",
"tags",
"specified",
"in",
"the",
"config",
"line",
"-",
"protocol",
"style"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/internal/config/config.go#L192-L202 |
128,176 | influxdata/telegraf | internal/config/config.go | PrintSampleConfig | func PrintSampleConfig(
sectionFilters []string,
inputFilters []string,
outputFilters []string,
aggregatorFilters []string,
processorFilters []string,
) {
// print headers
fmt.Printf(header)
if len(sectionFilters) == 0 {
sectionFilters = sectionDefaults
}
printFilteredGlobalSections(sectionFilters)
// pr... | go | func PrintSampleConfig(
sectionFilters []string,
inputFilters []string,
outputFilters []string,
aggregatorFilters []string,
processorFilters []string,
) {
// print headers
fmt.Printf(header)
if len(sectionFilters) == 0 {
sectionFilters = sectionDefaults
}
printFilteredGlobalSections(sectionFilters)
// pr... | [
"func",
"PrintSampleConfig",
"(",
"sectionFilters",
"[",
"]",
"string",
",",
"inputFilters",
"[",
"]",
"string",
",",
"outputFilters",
"[",
"]",
"string",
",",
"aggregatorFilters",
"[",
"]",
"string",
",",
"processorFilters",
"[",
"]",
"string",
",",
")",
"{... | // PrintSampleConfig prints the sample config | [
"PrintSampleConfig",
"prints",
"the",
"sample",
"config"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/internal/config/config.go#L320-L414 |
128,177 | influxdata/telegraf | internal/config/config.go | PrintInputConfig | func PrintInputConfig(name string) error {
if creator, ok := inputs.Inputs[name]; ok {
printConfig(name, creator(), "inputs", false)
} else {
return errors.New(fmt.Sprintf("Input %s not found", name))
}
return nil
} | go | func PrintInputConfig(name string) error {
if creator, ok := inputs.Inputs[name]; ok {
printConfig(name, creator(), "inputs", false)
} else {
return errors.New(fmt.Sprintf("Input %s not found", name))
}
return nil
} | [
"func",
"PrintInputConfig",
"(",
"name",
"string",
")",
"error",
"{",
"if",
"creator",
",",
"ok",
":=",
"inputs",
".",
"Inputs",
"[",
"name",
"]",
";",
"ok",
"{",
"printConfig",
"(",
"name",
",",
"creator",
"(",
")",
",",
"\"",
"\"",
",",
"false",
... | // PrintInputConfig prints the config usage of a single input. | [
"PrintInputConfig",
"prints",
"the",
"config",
"usage",
"of",
"a",
"single",
"input",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/internal/config/config.go#L560-L567 |
128,178 | influxdata/telegraf | internal/config/config.go | PrintOutputConfig | func PrintOutputConfig(name string) error {
if creator, ok := outputs.Outputs[name]; ok {
printConfig(name, creator(), "outputs", false)
} else {
return errors.New(fmt.Sprintf("Output %s not found", name))
}
return nil
} | go | func PrintOutputConfig(name string) error {
if creator, ok := outputs.Outputs[name]; ok {
printConfig(name, creator(), "outputs", false)
} else {
return errors.New(fmt.Sprintf("Output %s not found", name))
}
return nil
} | [
"func",
"PrintOutputConfig",
"(",
"name",
"string",
")",
"error",
"{",
"if",
"creator",
",",
"ok",
":=",
"outputs",
".",
"Outputs",
"[",
"name",
"]",
";",
"ok",
"{",
"printConfig",
"(",
"name",
",",
"creator",
"(",
")",
",",
"\"",
"\"",
",",
"false",... | // PrintOutputConfig prints the config usage of a single output. | [
"PrintOutputConfig",
"prints",
"the",
"config",
"usage",
"of",
"a",
"single",
"output",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/internal/config/config.go#L570-L577 |
128,179 | influxdata/telegraf | internal/config/config.go | parseConfig | func parseConfig(contents []byte) (*ast.Table, error) {
contents = trimBOM(contents)
parameters := envVarRe.FindAllSubmatch(contents, -1)
for _, parameter := range parameters {
if len(parameter) != 3 {
continue
}
var env_var []byte
if parameter[1] != nil {
env_var = parameter[1]
} else if parameter... | go | func parseConfig(contents []byte) (*ast.Table, error) {
contents = trimBOM(contents)
parameters := envVarRe.FindAllSubmatch(contents, -1)
for _, parameter := range parameters {
if len(parameter) != 3 {
continue
}
var env_var []byte
if parameter[1] != nil {
env_var = parameter[1]
} else if parameter... | [
"func",
"parseConfig",
"(",
"contents",
"[",
"]",
"byte",
")",
"(",
"*",
"ast",
".",
"Table",
",",
"error",
")",
"{",
"contents",
"=",
"trimBOM",
"(",
"contents",
")",
"\n\n",
"parameters",
":=",
"envVarRe",
".",
"FindAllSubmatch",
"(",
"contents",
",",
... | // parseConfig loads a TOML configuration from a provided path and
// returns the AST produced from the TOML parser. When loading the file, it
// will find environment variables and replace them. | [
"parseConfig",
"loads",
"a",
"TOML",
"configuration",
"from",
"a",
"provided",
"path",
"and",
"returns",
"the",
"AST",
"produced",
"from",
"the",
"TOML",
"parser",
".",
"When",
"loading",
"the",
"file",
"it",
"will",
"find",
"environment",
"variables",
"and",
... | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/internal/config/config.go#L832-L858 |
128,180 | influxdata/telegraf | internal/config/config.go | buildProcessor | func buildProcessor(name string, tbl *ast.Table) (*models.ProcessorConfig, error) {
conf := &models.ProcessorConfig{Name: name}
if node, ok := tbl.Fields["order"]; ok {
if kv, ok := node.(*ast.KeyValue); ok {
if b, ok := kv.Value.(*ast.Integer); ok {
var err error
conf.Order, err = strconv.ParseInt(b.Va... | go | func buildProcessor(name string, tbl *ast.Table) (*models.ProcessorConfig, error) {
conf := &models.ProcessorConfig{Name: name}
if node, ok := tbl.Fields["order"]; ok {
if kv, ok := node.(*ast.KeyValue); ok {
if b, ok := kv.Value.(*ast.Integer); ok {
var err error
conf.Order, err = strconv.ParseInt(b.Va... | [
"func",
"buildProcessor",
"(",
"name",
"string",
",",
"tbl",
"*",
"ast",
".",
"Table",
")",
"(",
"*",
"models",
".",
"ProcessorConfig",
",",
"error",
")",
"{",
"conf",
":=",
"&",
"models",
".",
"ProcessorConfig",
"{",
"Name",
":",
"name",
"}",
"\n\n",
... | // buildProcessor parses Processor specific items from the ast.Table,
// builds the filter and returns a
// models.ProcessorConfig to be inserted into models.RunningProcessor | [
"buildProcessor",
"parses",
"Processor",
"specific",
"items",
"from",
"the",
"ast",
".",
"Table",
"builds",
"the",
"filter",
"and",
"returns",
"a",
"models",
".",
"ProcessorConfig",
"to",
"be",
"inserted",
"into",
"models",
".",
"RunningProcessor"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/internal/config/config.go#L1093-L1115 |
128,181 | influxdata/telegraf | internal/config/config.go | buildInput | func buildInput(name string, tbl *ast.Table) (*models.InputConfig, error) {
cp := &models.InputConfig{Name: name}
if node, ok := tbl.Fields["interval"]; ok {
if kv, ok := node.(*ast.KeyValue); ok {
if str, ok := kv.Value.(*ast.String); ok {
dur, err := time.ParseDuration(str.Value)
if err != nil {
r... | go | func buildInput(name string, tbl *ast.Table) (*models.InputConfig, error) {
cp := &models.InputConfig{Name: name}
if node, ok := tbl.Fields["interval"]; ok {
if kv, ok := node.(*ast.KeyValue); ok {
if str, ok := kv.Value.(*ast.String); ok {
dur, err := time.ParseDuration(str.Value)
if err != nil {
r... | [
"func",
"buildInput",
"(",
"name",
"string",
",",
"tbl",
"*",
"ast",
".",
"Table",
")",
"(",
"*",
"models",
".",
"InputConfig",
",",
"error",
")",
"{",
"cp",
":=",
"&",
"models",
".",
"InputConfig",
"{",
"Name",
":",
"name",
"}",
"\n",
"if",
"node"... | // buildInput parses input specific items from the ast.Table,
// builds the filter and returns a
// models.InputConfig to be inserted into models.RunningInput | [
"buildInput",
"parses",
"input",
"specific",
"items",
"from",
"the",
"ast",
".",
"Table",
"builds",
"the",
"filter",
"and",
"returns",
"a",
"models",
".",
"InputConfig",
"to",
"be",
"inserted",
"into",
"models",
".",
"RunningInput"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/internal/config/config.go#L1257-L1316 |
128,182 | influxdata/telegraf | internal/config/config.go | buildParser | func buildParser(name string, tbl *ast.Table) (parsers.Parser, error) {
config, err := getParserConfig(name, tbl)
if err != nil {
return nil, err
}
return parsers.NewParser(config)
} | go | func buildParser(name string, tbl *ast.Table) (parsers.Parser, error) {
config, err := getParserConfig(name, tbl)
if err != nil {
return nil, err
}
return parsers.NewParser(config)
} | [
"func",
"buildParser",
"(",
"name",
"string",
",",
"tbl",
"*",
"ast",
".",
"Table",
")",
"(",
"parsers",
".",
"Parser",
",",
"error",
")",
"{",
"config",
",",
"err",
":=",
"getParserConfig",
"(",
"name",
",",
"tbl",
")",
"\n",
"if",
"err",
"!=",
"n... | // buildParser grabs the necessary entries from the ast.Table for creating
// a parsers.Parser object, and creates it, which can then be added onto
// an Input object. | [
"buildParser",
"grabs",
"the",
"necessary",
"entries",
"from",
"the",
"ast",
".",
"Table",
"for",
"creating",
"a",
"parsers",
".",
"Parser",
"object",
"and",
"creates",
"it",
"which",
"can",
"then",
"be",
"added",
"onto",
"an",
"Input",
"object",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/internal/config/config.go#L1321-L1327 |
128,183 | influxdata/telegraf | plugins/inputs/http_response/http_response.go | getProxyFunc | func getProxyFunc(http_proxy string) func(*http.Request) (*url.URL, error) {
if http_proxy == "" {
return http.ProxyFromEnvironment
}
proxyURL, err := url.Parse(http_proxy)
if err != nil {
return func(_ *http.Request) (*url.URL, error) {
return nil, errors.New("bad proxy: " + err.Error())
}
}
return func... | go | func getProxyFunc(http_proxy string) func(*http.Request) (*url.URL, error) {
if http_proxy == "" {
return http.ProxyFromEnvironment
}
proxyURL, err := url.Parse(http_proxy)
if err != nil {
return func(_ *http.Request) (*url.URL, error) {
return nil, errors.New("bad proxy: " + err.Error())
}
}
return func... | [
"func",
"getProxyFunc",
"(",
"http_proxy",
"string",
")",
"func",
"(",
"*",
"http",
".",
"Request",
")",
"(",
"*",
"url",
".",
"URL",
",",
"error",
")",
"{",
"if",
"http_proxy",
"==",
"\"",
"\"",
"{",
"return",
"http",
".",
"ProxyFromEnvironment",
"\n"... | // Set the proxy. A configured proxy overwrites the system wide proxy. | [
"Set",
"the",
"proxy",
".",
"A",
"configured",
"proxy",
"overwrites",
"the",
"system",
"wide",
"proxy",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/http_response/http_response.go#L91-L104 |
128,184 | influxdata/telegraf | plugins/inputs/http_response/http_response.go | createHttpClient | func (h *HTTPResponse) createHttpClient() (*http.Client, error) {
tlsCfg, err := h.ClientConfig.TLSConfig()
if err != nil {
return nil, err
}
client := &http.Client{
Transport: &http.Transport{
Proxy: getProxyFunc(h.HTTPProxy),
DisableKeepAlives: true,
TLSClientConfig: tlsCfg,
},
Time... | go | func (h *HTTPResponse) createHttpClient() (*http.Client, error) {
tlsCfg, err := h.ClientConfig.TLSConfig()
if err != nil {
return nil, err
}
client := &http.Client{
Transport: &http.Transport{
Proxy: getProxyFunc(h.HTTPProxy),
DisableKeepAlives: true,
TLSClientConfig: tlsCfg,
},
Time... | [
"func",
"(",
"h",
"*",
"HTTPResponse",
")",
"createHttpClient",
"(",
")",
"(",
"*",
"http",
".",
"Client",
",",
"error",
")",
"{",
"tlsCfg",
",",
"err",
":=",
"h",
".",
"ClientConfig",
".",
"TLSConfig",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{"... | // CreateHttpClient creates an http client which will timeout at the specified
// timeout period and can follow redirects if specified | [
"CreateHttpClient",
"creates",
"an",
"http",
"client",
"which",
"will",
"timeout",
"at",
"the",
"specified",
"timeout",
"period",
"and",
"can",
"follow",
"redirects",
"if",
"specified"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/http_response/http_response.go#L108-L128 |
128,185 | influxdata/telegraf | plugins/inputs/http_response/http_response.go | httpGather | func (h *HTTPResponse) httpGather() (map[string]interface{}, map[string]string, error) {
// Prepare fields and tags
fields := make(map[string]interface{})
tags := map[string]string{"server": h.Address, "method": h.Method}
var body io.Reader
if h.Body != "" {
body = strings.NewReader(h.Body)
}
request, err := ... | go | func (h *HTTPResponse) httpGather() (map[string]interface{}, map[string]string, error) {
// Prepare fields and tags
fields := make(map[string]interface{})
tags := map[string]string{"server": h.Address, "method": h.Method}
var body io.Reader
if h.Body != "" {
body = strings.NewReader(h.Body)
}
request, err := ... | [
"func",
"(",
"h",
"*",
"HTTPResponse",
")",
"httpGather",
"(",
")",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"map",
"[",
"string",
"]",
"string",
",",
"error",
")",
"{",
"// Prepare fields and tags",
"fields",
":=",
"make",
"(",
"map... | // HTTPGather gathers all fields and returns any errors it encounters | [
"HTTPGather",
"gathers",
"all",
"fields",
"and",
"returns",
"any",
"errors",
"it",
"encounters"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/http_response/http_response.go#L174-L266 |
128,186 | influxdata/telegraf | plugins/inputs/http_response/http_response.go | Gather | func (h *HTTPResponse) Gather(acc telegraf.Accumulator) error {
// Compile the body regex if it exist
if h.compiledStringMatch == nil {
var err error
h.compiledStringMatch, err = regexp.Compile(h.ResponseStringMatch)
if err != nil {
return fmt.Errorf("Failed to compile regular expression %s : %s", h.Response... | go | func (h *HTTPResponse) Gather(acc telegraf.Accumulator) error {
// Compile the body regex if it exist
if h.compiledStringMatch == nil {
var err error
h.compiledStringMatch, err = regexp.Compile(h.ResponseStringMatch)
if err != nil {
return fmt.Errorf("Failed to compile regular expression %s : %s", h.Response... | [
"func",
"(",
"h",
"*",
"HTTPResponse",
")",
"Gather",
"(",
"acc",
"telegraf",
".",
"Accumulator",
")",
"error",
"{",
"// Compile the body regex if it exist",
"if",
"h",
".",
"compiledStringMatch",
"==",
"nil",
"{",
"var",
"err",
"error",
"\n",
"h",
".",
"com... | // Gather gets all metric fields and tags and returns any errors it encounters | [
"Gather",
"gets",
"all",
"metric",
"fields",
"and",
"tags",
"and",
"returns",
"any",
"errors",
"it",
"encounters"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/http_response/http_response.go#L269-L319 |
128,187 | influxdata/telegraf | internal/globpath/globpath.go | Match | func (g *GlobPath) Match() []string {
if !g.hasMeta {
return []string{g.path}
}
if !g.HasSuperMeta {
files, _ := filepath.Glob(g.path)
return files
}
roots, err := filepath.Glob(g.rootGlob)
if err != nil {
return []string{}
}
out := []string{}
walkfn := func(path string, _ *godirwalk.Dirent) error {
... | go | func (g *GlobPath) Match() []string {
if !g.hasMeta {
return []string{g.path}
}
if !g.HasSuperMeta {
files, _ := filepath.Glob(g.path)
return files
}
roots, err := filepath.Glob(g.rootGlob)
if err != nil {
return []string{}
}
out := []string{}
walkfn := func(path string, _ *godirwalk.Dirent) error {
... | [
"func",
"(",
"g",
"*",
"GlobPath",
")",
"Match",
"(",
")",
"[",
"]",
"string",
"{",
"if",
"!",
"g",
".",
"hasMeta",
"{",
"return",
"[",
"]",
"string",
"{",
"g",
".",
"path",
"}",
"\n",
"}",
"\n",
"if",
"!",
"g",
".",
"HasSuperMeta",
"{",
"fil... | // Match returns all files matching the expression
// If it's a static path, returns path | [
"Match",
"returns",
"all",
"files",
"matching",
"the",
"expression",
"If",
"it",
"s",
"a",
"static",
"path",
"returns",
"path"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/internal/globpath/globpath.go#L46-L83 |
128,188 | influxdata/telegraf | internal/globpath/globpath.go | MatchString | func (g *GlobPath) MatchString(path string) bool {
if !g.HasSuperMeta {
res, _ := filepath.Match(g.path, path)
return res
}
return g.g.Match(path)
} | go | func (g *GlobPath) MatchString(path string) bool {
if !g.HasSuperMeta {
res, _ := filepath.Match(g.path, path)
return res
}
return g.g.Match(path)
} | [
"func",
"(",
"g",
"*",
"GlobPath",
")",
"MatchString",
"(",
"path",
"string",
")",
"bool",
"{",
"if",
"!",
"g",
".",
"HasSuperMeta",
"{",
"res",
",",
"_",
":=",
"filepath",
".",
"Match",
"(",
"g",
".",
"path",
",",
"path",
")",
"\n",
"return",
"r... | // MatchString test a string against the glob | [
"MatchString",
"test",
"a",
"string",
"against",
"the",
"glob"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/internal/globpath/globpath.go#L86-L92 |
128,189 | influxdata/telegraf | plugins/parsers/influx/machine.go | Column | func (m *machine) Column() int {
lineOffset := m.p - m.sol
return lineOffset + 1
} | go | func (m *machine) Column() int {
lineOffset := m.p - m.sol
return lineOffset + 1
} | [
"func",
"(",
"m",
"*",
"machine",
")",
"Column",
"(",
")",
"int",
"{",
"lineOffset",
":=",
"m",
".",
"p",
"-",
"m",
".",
"sol",
"\n",
"return",
"lineOffset",
"+",
"1",
"\n",
"}"
] | // Column returns the current column. | [
"Column",
"returns",
"the",
"current",
"column",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/parsers/influx/machine.go#L30790-L30793 |
128,190 | influxdata/telegraf | plugins/inputs/prometheus/prometheus.go | Start | func (p *Prometheus) Start(a telegraf.Accumulator) error {
if p.MonitorPods {
var ctx context.Context
ctx, p.cancel = context.WithCancel(context.Background())
return p.start(ctx)
}
return nil
} | go | func (p *Prometheus) Start(a telegraf.Accumulator) error {
if p.MonitorPods {
var ctx context.Context
ctx, p.cancel = context.WithCancel(context.Background())
return p.start(ctx)
}
return nil
} | [
"func",
"(",
"p",
"*",
"Prometheus",
")",
"Start",
"(",
"a",
"telegraf",
".",
"Accumulator",
")",
"error",
"{",
"if",
"p",
".",
"MonitorPods",
"{",
"var",
"ctx",
"context",
".",
"Context",
"\n",
"ctx",
",",
"p",
".",
"cancel",
"=",
"context",
".",
... | // Start will start the Kubernetes scraping if enabled in the configuration | [
"Start",
"will",
"start",
"the",
"Kubernetes",
"scraping",
"if",
"enabled",
"in",
"the",
"configuration"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/prometheus/prometheus.go#L312-L319 |
128,191 | influxdata/telegraf | agent/accumulator.go | AddError | func (ac *accumulator) AddError(err error) {
if err == nil {
return
}
NErrors.Incr(1)
log.Printf("E! [%s]: Error in plugin: %v", ac.maker.Name(), err)
} | go | func (ac *accumulator) AddError(err error) {
if err == nil {
return
}
NErrors.Incr(1)
log.Printf("E! [%s]: Error in plugin: %v", ac.maker.Name(), err)
} | [
"func",
"(",
"ac",
"*",
"accumulator",
")",
"AddError",
"(",
"err",
"error",
")",
"{",
"if",
"err",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"NErrors",
".",
"Incr",
"(",
"1",
")",
"\n",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"ac",
".",... | // AddError passes a runtime error to the accumulator.
// The error will be tagged with the plugin name and written to the log. | [
"AddError",
"passes",
"a",
"runtime",
"error",
"to",
"the",
"accumulator",
".",
"The",
"error",
"will",
"be",
"tagged",
"with",
"the",
"plugin",
"name",
"and",
"written",
"to",
"the",
"log",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/agent/accumulator.go#L109-L115 |
128,192 | influxdata/telegraf | plugins/inputs/cloud_pubsub/pubsub.go | Start | func (ps *PubSub) Start(ac telegraf.Accumulator) error {
if ps.Subscription == "" {
return fmt.Errorf(`"subscription" is required`)
}
if ps.Project == "" {
return fmt.Errorf(`"project" is required`)
}
ps.sem = make(semaphore, ps.MaxUndeliveredMessages)
ps.acc = ac.WithTracking(ps.MaxUndeliveredMessages)
/... | go | func (ps *PubSub) Start(ac telegraf.Accumulator) error {
if ps.Subscription == "" {
return fmt.Errorf(`"subscription" is required`)
}
if ps.Project == "" {
return fmt.Errorf(`"project" is required`)
}
ps.sem = make(semaphore, ps.MaxUndeliveredMessages)
ps.acc = ac.WithTracking(ps.MaxUndeliveredMessages)
/... | [
"func",
"(",
"ps",
"*",
"PubSub",
")",
"Start",
"(",
"ac",
"telegraf",
".",
"Accumulator",
")",
"error",
"{",
"if",
"ps",
".",
"Subscription",
"==",
"\"",
"\"",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"`\"subscription\" is required`",
")",
"\n",
"}",
... | // Start initializes the plugin and processing messages from Google PubSub.
// Two goroutines are started - one pulling for the subscription, one
// receiving delivery notifications from the accumulator. | [
"Start",
"initializes",
"the",
"plugin",
"and",
"processing",
"messages",
"from",
"Google",
"PubSub",
".",
"Two",
"goroutines",
"are",
"started",
"-",
"one",
"pulling",
"for",
"the",
"subscription",
"one",
"receiving",
"delivery",
"notifications",
"from",
"the",
... | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/cloud_pubsub/pubsub.go#L80-L122 |
128,193 | influxdata/telegraf | plugins/inputs/cloud_pubsub/pubsub.go | onMessage | func (ps *PubSub) onMessage(ctx context.Context, msg message) error {
if ps.MaxMessageLen > 0 && len(msg.Data()) > ps.MaxMessageLen {
msg.Ack()
return fmt.Errorf("message longer than max_message_len (%d > %d)", len(msg.Data()), ps.MaxMessageLen)
}
var data []byte
if ps.Base64Data {
strData, err := base64.Std... | go | func (ps *PubSub) onMessage(ctx context.Context, msg message) error {
if ps.MaxMessageLen > 0 && len(msg.Data()) > ps.MaxMessageLen {
msg.Ack()
return fmt.Errorf("message longer than max_message_len (%d > %d)", len(msg.Data()), ps.MaxMessageLen)
}
var data []byte
if ps.Base64Data {
strData, err := base64.Std... | [
"func",
"(",
"ps",
"*",
"PubSub",
")",
"onMessage",
"(",
"ctx",
"context",
".",
"Context",
",",
"msg",
"message",
")",
"error",
"{",
"if",
"ps",
".",
"MaxMessageLen",
">",
"0",
"&&",
"len",
"(",
"msg",
".",
"Data",
"(",
")",
")",
">",
"ps",
".",
... | // onMessage handles parsing and adding a received message to the accumulator. | [
"onMessage",
"handles",
"parsing",
"and",
"adding",
"a",
"received",
"message",
"to",
"the",
"accumulator",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/cloud_pubsub/pubsub.go#L169-L214 |
128,194 | influxdata/telegraf | plugins/inputs/opensmtpd/opensmtpd.go | Gather | func (s *Opensmtpd) Gather(acc telegraf.Accumulator) error {
// Always exclude uptime.human statistics
stat_excluded := []string{"uptime.human"}
filter_excluded, err := filter.Compile(stat_excluded)
if err != nil {
return err
}
out, err := s.run(s.Binary, s.Timeout, s.UseSudo)
if err != nil {
return fmt.Err... | go | func (s *Opensmtpd) Gather(acc telegraf.Accumulator) error {
// Always exclude uptime.human statistics
stat_excluded := []string{"uptime.human"}
filter_excluded, err := filter.Compile(stat_excluded)
if err != nil {
return err
}
out, err := s.run(s.Binary, s.Timeout, s.UseSudo)
if err != nil {
return fmt.Err... | [
"func",
"(",
"s",
"*",
"Opensmtpd",
")",
"Gather",
"(",
"acc",
"telegraf",
".",
"Accumulator",
")",
"error",
"{",
"// Always exclude uptime.human statistics",
"stat_excluded",
":=",
"[",
"]",
"string",
"{",
"\"",
"\"",
"}",
"\n",
"filter_excluded",
",",
"err",... | // Gather collects the configured stats from smtpctl and adds them to the
// Accumulator
//
// All the dots in stat name will replaced by underscores. Histogram statistics will not be collected. | [
"Gather",
"collects",
"the",
"configured",
"stats",
"from",
"smtpctl",
"and",
"adds",
"them",
"to",
"the",
"Accumulator",
"All",
"the",
"dots",
"in",
"stat",
"name",
"will",
"replaced",
"by",
"underscores",
".",
"Histogram",
"statistics",
"will",
"not",
"be",
... | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/opensmtpd/opensmtpd.go#L78-L123 |
128,195 | influxdata/telegraf | plugins/inputs/logparser/logparser.go | Gather | func (l *LogParserPlugin) Gather(acc telegraf.Accumulator) error {
l.Lock()
defer l.Unlock()
// always start from the beginning of files that appear while we're running
return l.tailNewfiles(true)
} | go | func (l *LogParserPlugin) Gather(acc telegraf.Accumulator) error {
l.Lock()
defer l.Unlock()
// always start from the beginning of files that appear while we're running
return l.tailNewfiles(true)
} | [
"func",
"(",
"l",
"*",
"LogParserPlugin",
")",
"Gather",
"(",
"acc",
"telegraf",
".",
"Accumulator",
")",
"error",
"{",
"l",
".",
"Lock",
"(",
")",
"\n",
"defer",
"l",
".",
"Unlock",
"(",
")",
"\n\n",
"// always start from the beginning of files that appear wh... | // Gather is the primary function to collect the metrics for the plugin | [
"Gather",
"is",
"the",
"primary",
"function",
"to",
"collect",
"the",
"metrics",
"for",
"the",
"plugin"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/logparser/logparser.go#L120-L126 |
128,196 | influxdata/telegraf | plugins/inputs/logparser/logparser.go | Start | func (l *LogParserPlugin) Start(acc telegraf.Accumulator) error {
l.Lock()
defer l.Unlock()
l.acc = acc
l.lines = make(chan logEntry, 1000)
l.done = make(chan struct{})
l.tailers = make(map[string]*tail.Tail)
mName := "logparser"
if l.GrokConfig.MeasurementName != "" {
mName = l.GrokConfig.MeasurementName
... | go | func (l *LogParserPlugin) Start(acc telegraf.Accumulator) error {
l.Lock()
defer l.Unlock()
l.acc = acc
l.lines = make(chan logEntry, 1000)
l.done = make(chan struct{})
l.tailers = make(map[string]*tail.Tail)
mName := "logparser"
if l.GrokConfig.MeasurementName != "" {
mName = l.GrokConfig.MeasurementName
... | [
"func",
"(",
"l",
"*",
"LogParserPlugin",
")",
"Start",
"(",
"acc",
"telegraf",
".",
"Accumulator",
")",
"error",
"{",
"l",
".",
"Lock",
"(",
")",
"\n",
"defer",
"l",
".",
"Unlock",
"(",
")",
"\n\n",
"l",
".",
"acc",
"=",
"acc",
"\n",
"l",
".",
... | // Start kicks off collection of stats for the plugin | [
"Start",
"kicks",
"off",
"collection",
"of",
"stats",
"for",
"the",
"plugin"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/logparser/logparser.go#L129-L165 |
128,197 | influxdata/telegraf | plugins/inputs/logparser/logparser.go | tailNewfiles | func (l *LogParserPlugin) tailNewfiles(fromBeginning bool) error {
var seek tail.SeekInfo
if !fromBeginning {
seek.Whence = 2
seek.Offset = 0
}
var poll bool
if l.WatchMethod == "poll" {
poll = true
}
// Create a "tailer" for each file
for _, filepath := range l.Files {
g, err := globpath.Compile(file... | go | func (l *LogParserPlugin) tailNewfiles(fromBeginning bool) error {
var seek tail.SeekInfo
if !fromBeginning {
seek.Whence = 2
seek.Offset = 0
}
var poll bool
if l.WatchMethod == "poll" {
poll = true
}
// Create a "tailer" for each file
for _, filepath := range l.Files {
g, err := globpath.Compile(file... | [
"func",
"(",
"l",
"*",
"LogParserPlugin",
")",
"tailNewfiles",
"(",
"fromBeginning",
"bool",
")",
"error",
"{",
"var",
"seek",
"tail",
".",
"SeekInfo",
"\n",
"if",
"!",
"fromBeginning",
"{",
"seek",
".",
"Whence",
"=",
"2",
"\n",
"seek",
".",
"Offset",
... | // check the globs against files on disk, and start tailing any new files.
// Assumes l's lock is held! | [
"check",
"the",
"globs",
"against",
"files",
"on",
"disk",
"and",
"start",
"tailing",
"any",
"new",
"files",
".",
"Assumes",
"l",
"s",
"lock",
"is",
"held!"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/logparser/logparser.go#L169-L220 |
128,198 | influxdata/telegraf | plugins/inputs/logparser/logparser.go | receiver | func (l *LogParserPlugin) receiver(tailer *tail.Tail) {
defer l.wg.Done()
var line *tail.Line
for line = range tailer.Lines {
if line.Err != nil {
log.Printf("E! Error tailing file %s, Error: %s\n",
tailer.Filename, line.Err)
continue
}
// Fix up files with Windows line endings.
text := strings.... | go | func (l *LogParserPlugin) receiver(tailer *tail.Tail) {
defer l.wg.Done()
var line *tail.Line
for line = range tailer.Lines {
if line.Err != nil {
log.Printf("E! Error tailing file %s, Error: %s\n",
tailer.Filename, line.Err)
continue
}
// Fix up files with Windows line endings.
text := strings.... | [
"func",
"(",
"l",
"*",
"LogParserPlugin",
")",
"receiver",
"(",
"tailer",
"*",
"tail",
".",
"Tail",
")",
"{",
"defer",
"l",
".",
"wg",
".",
"Done",
"(",
")",
"\n\n",
"var",
"line",
"*",
"tail",
".",
"Line",
"\n",
"for",
"line",
"=",
"range",
"tai... | // receiver is launched as a goroutine to continuously watch a tailed logfile
// for changes and send any log lines down the l.lines channel. | [
"receiver",
"is",
"launched",
"as",
"a",
"goroutine",
"to",
"continuously",
"watch",
"a",
"tailed",
"logfile",
"for",
"changes",
"and",
"send",
"any",
"log",
"lines",
"down",
"the",
"l",
".",
"lines",
"channel",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/logparser/logparser.go#L224-L249 |
128,199 | influxdata/telegraf | plugins/inputs/logparser/logparser.go | Stop | func (l *LogParserPlugin) Stop() {
l.Lock()
defer l.Unlock()
for _, t := range l.tailers {
err := t.Stop()
//message for a stopped tailer
log.Printf("D! tail dropped for file: %v", t.Filename)
if err != nil {
log.Printf("E! Error stopping tail on file %s\n", t.Filename)
}
t.Cleanup()
}
close(l.do... | go | func (l *LogParserPlugin) Stop() {
l.Lock()
defer l.Unlock()
for _, t := range l.tailers {
err := t.Stop()
//message for a stopped tailer
log.Printf("D! tail dropped for file: %v", t.Filename)
if err != nil {
log.Printf("E! Error stopping tail on file %s\n", t.Filename)
}
t.Cleanup()
}
close(l.do... | [
"func",
"(",
"l",
"*",
"LogParserPlugin",
")",
"Stop",
"(",
")",
"{",
"l",
".",
"Lock",
"(",
")",
"\n",
"defer",
"l",
".",
"Unlock",
"(",
")",
"\n\n",
"for",
"_",
",",
"t",
":=",
"range",
"l",
".",
"tailers",
"{",
"err",
":=",
"t",
".",
"Stop... | // Stop will end the metrics collection process on file tailers | [
"Stop",
"will",
"end",
"the",
"metrics",
"collection",
"process",
"on",
"file",
"tailers"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/logparser/logparser.go#L284-L301 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.