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,200 | influxdata/telegraf | plugins/inputs/vsphere/endpoint.go | Collect | func (e *Endpoint) Collect(ctx context.Context, acc telegraf.Accumulator) error {
// If we never managed to do a discovery, collection will be a no-op. Therefore,
// we need to check that a connection is available, or the collection will
// silently fail.
if _, err := e.clientFactory.GetClient(ctx); err != nil {
... | go | func (e *Endpoint) Collect(ctx context.Context, acc telegraf.Accumulator) error {
// If we never managed to do a discovery, collection will be a no-op. Therefore,
// we need to check that a connection is available, or the collection will
// silently fail.
if _, err := e.clientFactory.GetClient(ctx); err != nil {
... | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"Collect",
"(",
"ctx",
"context",
".",
"Context",
",",
"acc",
"telegraf",
".",
"Accumulator",
")",
"error",
"{",
"// If we never managed to do a discovery, collection will be a no-op. Therefore,",
"// we need to check that a connectio... | // Collect runs a round of data collections as specified in the configuration. | [
"Collect",
"runs",
"a",
"round",
"of",
"data",
"collections",
"as",
"specified",
"in",
"the",
"configuration",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/vsphere/endpoint.go#L654-L695 |
128,201 | influxdata/telegraf | plugins/inputs/vsphere/endpoint.go | submitChunkJob | func submitChunkJob(ctx context.Context, te *ThrottledExecutor, job func([]types.PerfQuerySpec), pqs []types.PerfQuerySpec) {
te.Run(ctx, func() {
job(pqs)
})
} | go | func submitChunkJob(ctx context.Context, te *ThrottledExecutor, job func([]types.PerfQuerySpec), pqs []types.PerfQuerySpec) {
te.Run(ctx, func() {
job(pqs)
})
} | [
"func",
"submitChunkJob",
"(",
"ctx",
"context",
".",
"Context",
",",
"te",
"*",
"ThrottledExecutor",
",",
"job",
"func",
"(",
"[",
"]",
"types",
".",
"PerfQuerySpec",
")",
",",
"pqs",
"[",
"]",
"types",
".",
"PerfQuerySpec",
")",
"{",
"te",
".",
"Run"... | // Workaround to make sure pqs is a copy of the loop variable and won't change. | [
"Workaround",
"to",
"make",
"sure",
"pqs",
"is",
"a",
"copy",
"of",
"the",
"loop",
"variable",
"and",
"won",
"t",
"change",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/vsphere/endpoint.go#L698-L702 |
128,202 | influxdata/telegraf | plugins/inputs/phpfpm/child.go | Serve | func Serve(l net.Listener, handler http.Handler) error {
if l == nil {
var err error
l, err = net.FileListener(os.Stdin)
if err != nil {
return err
}
defer l.Close()
}
if handler == nil {
handler = http.DefaultServeMux
}
for {
rw, err := l.Accept()
if err != nil {
return err
}
c := newChi... | go | func Serve(l net.Listener, handler http.Handler) error {
if l == nil {
var err error
l, err = net.FileListener(os.Stdin)
if err != nil {
return err
}
defer l.Close()
}
if handler == nil {
handler = http.DefaultServeMux
}
for {
rw, err := l.Accept()
if err != nil {
return err
}
c := newChi... | [
"func",
"Serve",
"(",
"l",
"net",
".",
"Listener",
",",
"handler",
"http",
".",
"Handler",
")",
"error",
"{",
"if",
"l",
"==",
"nil",
"{",
"var",
"err",
"error",
"\n",
"l",
",",
"err",
"=",
"net",
".",
"FileListener",
"(",
"os",
".",
"Stdin",
")"... | // Serve accepts incoming FastCGI connections on the listener l, creating a new
// goroutine for each. The goroutine reads requests and then calls handler
// to reply to them.
// If l is nil, Serve accepts connections from os.Stdin.
// If handler is nil, http.DefaultServeMux is used. | [
"Serve",
"accepts",
"incoming",
"FastCGI",
"connections",
"on",
"the",
"listener",
"l",
"creating",
"a",
"new",
"goroutine",
"for",
"each",
".",
"The",
"goroutine",
"reads",
"requests",
"and",
"then",
"calls",
"handler",
"to",
"reply",
"to",
"them",
".",
"If... | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/phpfpm/child.go#L311-L331 |
128,203 | influxdata/telegraf | plugins/inputs/vsphere/client.go | NewClientFactory | func NewClientFactory(ctx context.Context, url *url.URL, parent *VSphere) *ClientFactory {
return &ClientFactory{
client: nil,
parent: parent,
url: url,
}
} | go | func NewClientFactory(ctx context.Context, url *url.URL, parent *VSphere) *ClientFactory {
return &ClientFactory{
client: nil,
parent: parent,
url: url,
}
} | [
"func",
"NewClientFactory",
"(",
"ctx",
"context",
".",
"Context",
",",
"url",
"*",
"url",
".",
"URL",
",",
"parent",
"*",
"VSphere",
")",
"*",
"ClientFactory",
"{",
"return",
"&",
"ClientFactory",
"{",
"client",
":",
"nil",
",",
"parent",
":",
"parent",... | // NewClientFactory creates a new ClientFactory and prepares it for use. | [
"NewClientFactory",
"creates",
"a",
"new",
"ClientFactory",
"and",
"prepares",
"it",
"for",
"use",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/vsphere/client.go#L51-L57 |
128,204 | influxdata/telegraf | plugins/inputs/vsphere/client.go | Close | func (cf *ClientFactory) Close() {
cf.mux.Lock()
defer cf.mux.Unlock()
if cf.client != nil {
cf.client.close()
}
} | go | func (cf *ClientFactory) Close() {
cf.mux.Lock()
defer cf.mux.Unlock()
if cf.client != nil {
cf.client.close()
}
} | [
"func",
"(",
"cf",
"*",
"ClientFactory",
")",
"Close",
"(",
")",
"{",
"cf",
".",
"mux",
".",
"Lock",
"(",
")",
"\n",
"defer",
"cf",
".",
"mux",
".",
"Unlock",
"(",
")",
"\n",
"if",
"cf",
".",
"client",
"!=",
"nil",
"{",
"cf",
".",
"client",
"... | // Close shuts down a ClientFactory and releases any resources associated with it. | [
"Close",
"shuts",
"down",
"a",
"ClientFactory",
"and",
"releases",
"any",
"resources",
"associated",
"with",
"it",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/vsphere/client.go#L185-L191 |
128,205 | influxdata/telegraf | plugins/inputs/vsphere/client.go | GetServerTime | func (c *Client) GetServerTime(ctx context.Context) (time.Time, error) {
ctx, cancel := context.WithTimeout(ctx, c.Timeout)
defer cancel()
t, err := methods.GetCurrentTime(ctx, c.Client)
if err != nil {
return time.Time{}, err
}
return *t, nil
} | go | func (c *Client) GetServerTime(ctx context.Context) (time.Time, error) {
ctx, cancel := context.WithTimeout(ctx, c.Timeout)
defer cancel()
t, err := methods.GetCurrentTime(ctx, c.Client)
if err != nil {
return time.Time{}, err
}
return *t, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetServerTime",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"time",
".",
"Time",
",",
"error",
")",
"{",
"ctx",
",",
"cancel",
":=",
"context",
".",
"WithTimeout",
"(",
"ctx",
",",
"c",
".",
"Timeout",
")... | // GetServerTime returns the time at the vCenter server | [
"GetServerTime",
"returns",
"the",
"time",
"at",
"the",
"vCenter",
"server"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/vsphere/client.go#L209-L217 |
128,206 | influxdata/telegraf | plugins/inputs/vsphere/client.go | GetMaxQueryMetrics | func (c *Client) GetMaxQueryMetrics(ctx context.Context) (int, error) {
ctx, cancel := context.WithTimeout(ctx, c.Timeout)
defer cancel()
om := object.NewOptionManager(c.Client.Client, *c.Client.Client.ServiceContent.Setting)
res, err := om.Query(ctx, "config.vpxd.stats.maxQueryMetrics")
if err == nil {
if len(... | go | func (c *Client) GetMaxQueryMetrics(ctx context.Context) (int, error) {
ctx, cancel := context.WithTimeout(ctx, c.Timeout)
defer cancel()
om := object.NewOptionManager(c.Client.Client, *c.Client.Client.ServiceContent.Setting)
res, err := om.Query(ctx, "config.vpxd.stats.maxQueryMetrics")
if err == nil {
if len(... | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetMaxQueryMetrics",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"int",
",",
"error",
")",
"{",
"ctx",
",",
"cancel",
":=",
"context",
".",
"WithTimeout",
"(",
"ctx",
",",
"c",
".",
"Timeout",
")",
"\n",
... | // GetMaxQueryMetrics returns the max_query_metrics setting as configured in vCenter | [
"GetMaxQueryMetrics",
"returns",
"the",
"max_query_metrics",
"setting",
"as",
"configured",
"in",
"vCenter"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/vsphere/client.go#L220-L261 |
128,207 | influxdata/telegraf | plugins/inputs/vsphere/client.go | QueryMetrics | func (c *Client) QueryMetrics(ctx context.Context, pqs []types.PerfQuerySpec) ([]performance.EntityMetric, error) {
ctx1, cancel1 := context.WithTimeout(ctx, c.Timeout)
defer cancel1()
metrics, err := c.Perf.Query(ctx1, pqs)
if err != nil {
return nil, err
}
ctx2, cancel2 := context.WithTimeout(ctx, c.Timeout)... | go | func (c *Client) QueryMetrics(ctx context.Context, pqs []types.PerfQuerySpec) ([]performance.EntityMetric, error) {
ctx1, cancel1 := context.WithTimeout(ctx, c.Timeout)
defer cancel1()
metrics, err := c.Perf.Query(ctx1, pqs)
if err != nil {
return nil, err
}
ctx2, cancel2 := context.WithTimeout(ctx, c.Timeout)... | [
"func",
"(",
"c",
"*",
"Client",
")",
"QueryMetrics",
"(",
"ctx",
"context",
".",
"Context",
",",
"pqs",
"[",
"]",
"types",
".",
"PerfQuerySpec",
")",
"(",
"[",
"]",
"performance",
".",
"EntityMetric",
",",
"error",
")",
"{",
"ctx1",
",",
"cancel1",
... | // QueryMetrics wraps performance.Query to give it proper timeouts | [
"QueryMetrics",
"wraps",
"performance",
".",
"Query",
"to",
"give",
"it",
"proper",
"timeouts"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/vsphere/client.go#L264-L275 |
128,208 | influxdata/telegraf | plugins/inputs/vsphere/client.go | CounterInfoByName | func (c *Client) CounterInfoByName(ctx context.Context) (map[string]*types.PerfCounterInfo, error) {
ctx1, cancel1 := context.WithTimeout(ctx, c.Timeout)
defer cancel1()
return c.Perf.CounterInfoByName(ctx1)
} | go | func (c *Client) CounterInfoByName(ctx context.Context) (map[string]*types.PerfCounterInfo, error) {
ctx1, cancel1 := context.WithTimeout(ctx, c.Timeout)
defer cancel1()
return c.Perf.CounterInfoByName(ctx1)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"CounterInfoByName",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"map",
"[",
"string",
"]",
"*",
"types",
".",
"PerfCounterInfo",
",",
"error",
")",
"{",
"ctx1",
",",
"cancel1",
":=",
"context",
".",
"WithTime... | // CounterInfoByName wraps performance.CounterInfoByName to give it proper timeouts | [
"CounterInfoByName",
"wraps",
"performance",
".",
"CounterInfoByName",
"to",
"give",
"it",
"proper",
"timeouts"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/vsphere/client.go#L278-L282 |
128,209 | influxdata/telegraf | plugins/inputs/vsphere/client.go | CounterInfoByKey | func (c *Client) CounterInfoByKey(ctx context.Context) (map[int32]*types.PerfCounterInfo, error) {
ctx1, cancel1 := context.WithTimeout(ctx, c.Timeout)
defer cancel1()
return c.Perf.CounterInfoByKey(ctx1)
} | go | func (c *Client) CounterInfoByKey(ctx context.Context) (map[int32]*types.PerfCounterInfo, error) {
ctx1, cancel1 := context.WithTimeout(ctx, c.Timeout)
defer cancel1()
return c.Perf.CounterInfoByKey(ctx1)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"CounterInfoByKey",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"map",
"[",
"int32",
"]",
"*",
"types",
".",
"PerfCounterInfo",
",",
"error",
")",
"{",
"ctx1",
",",
"cancel1",
":=",
"context",
".",
"WithTimeou... | // CounterInfoByKey wraps performance.CounterInfoByKey to give it proper timeouts | [
"CounterInfoByKey",
"wraps",
"performance",
".",
"CounterInfoByKey",
"to",
"give",
"it",
"proper",
"timeouts"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/vsphere/client.go#L285-L289 |
128,210 | influxdata/telegraf | plugins/inputs/vsphere/client.go | ListResources | func (c *Client) ListResources(ctx context.Context, root *view.ContainerView, kind []string, ps []string, dst interface{}) error {
ctx1, cancel1 := context.WithTimeout(ctx, c.Timeout)
defer cancel1()
return root.Retrieve(ctx1, kind, ps, dst)
} | go | func (c *Client) ListResources(ctx context.Context, root *view.ContainerView, kind []string, ps []string, dst interface{}) error {
ctx1, cancel1 := context.WithTimeout(ctx, c.Timeout)
defer cancel1()
return root.Retrieve(ctx1, kind, ps, dst)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"ListResources",
"(",
"ctx",
"context",
".",
"Context",
",",
"root",
"*",
"view",
".",
"ContainerView",
",",
"kind",
"[",
"]",
"string",
",",
"ps",
"[",
"]",
"string",
",",
"dst",
"interface",
"{",
"}",
")",
"e... | // ListResources wraps property.Collector.Retrieve to give it proper timeouts | [
"ListResources",
"wraps",
"property",
".",
"Collector",
".",
"Retrieve",
"to",
"give",
"it",
"proper",
"timeouts"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/vsphere/client.go#L292-L296 |
128,211 | influxdata/telegraf | plugins/inputs/minecraft/internal/rcon/rcon.go | Compile | func (p Packet) Compile() (payload []byte, err error) {
var size int32 = p.Header.Size
var buffer bytes.Buffer
var padding [PacketPaddingSize]byte
if err = binary.Write(&buffer, binary.LittleEndian, &size); nil != err {
return
} else if err = binary.Write(&buffer, binary.LittleEndian, &p.Header.Challenge); nil ... | go | func (p Packet) Compile() (payload []byte, err error) {
var size int32 = p.Header.Size
var buffer bytes.Buffer
var padding [PacketPaddingSize]byte
if err = binary.Write(&buffer, binary.LittleEndian, &size); nil != err {
return
} else if err = binary.Write(&buffer, binary.LittleEndian, &p.Header.Challenge); nil ... | [
"func",
"(",
"p",
"Packet",
")",
"Compile",
"(",
")",
"(",
"payload",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"var",
"size",
"int32",
"=",
"p",
".",
"Header",
".",
"Size",
"\n",
"var",
"buffer",
"bytes",
".",
"Buffer",
"\n",
"var",
"padd... | // Compile converts a packets header and body into its approriate
// byte array payload, returning an error if the binary packages
// Write method fails to write the header bytes in their little
// endian byte order. | [
"Compile",
"converts",
"a",
"packets",
"header",
"and",
"body",
"into",
"its",
"approriate",
"byte",
"array",
"payload",
"returning",
"an",
"error",
"if",
"the",
"binary",
"packages",
"Write",
"method",
"fails",
"to",
"write",
"the",
"header",
"bytes",
"in",
... | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/minecraft/internal/rcon/rcon.go#L64-L81 |
128,212 | influxdata/telegraf | plugins/inputs/minecraft/internal/rcon/rcon.go | NewPacket | func NewPacket(challenge, typ int32, body string) (packet *Packet) {
size := int32(len([]byte(body)) + int(PacketHeaderSize+PacketPaddingSize))
return &Packet{Header{size, challenge, typ}, body}
} | go | func NewPacket(challenge, typ int32, body string) (packet *Packet) {
size := int32(len([]byte(body)) + int(PacketHeaderSize+PacketPaddingSize))
return &Packet{Header{size, challenge, typ}, body}
} | [
"func",
"NewPacket",
"(",
"challenge",
",",
"typ",
"int32",
",",
"body",
"string",
")",
"(",
"packet",
"*",
"Packet",
")",
"{",
"size",
":=",
"int32",
"(",
"len",
"(",
"[",
"]",
"byte",
"(",
"body",
")",
")",
"+",
"int",
"(",
"PacketHeaderSize",
"+... | // NewPacket returns a pointer to a new Packet type. | [
"NewPacket",
"returns",
"a",
"pointer",
"to",
"a",
"new",
"Packet",
"type",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/minecraft/internal/rcon/rcon.go#L84-L87 |
128,213 | influxdata/telegraf | plugins/inputs/minecraft/internal/rcon/rcon.go | Authorize | func (c *Client) Authorize(password string) (response *Packet, err error) {
if response, err = c.Send(Auth, password); nil == err {
if response.Header.Type == AuthResponse {
c.Authorized = true
} else {
err = ErrFailedAuthorization
response = nil
return
}
}
return
} | go | func (c *Client) Authorize(password string) (response *Packet, err error) {
if response, err = c.Send(Auth, password); nil == err {
if response.Header.Type == AuthResponse {
c.Authorized = true
} else {
err = ErrFailedAuthorization
response = nil
return
}
}
return
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Authorize",
"(",
"password",
"string",
")",
"(",
"response",
"*",
"Packet",
",",
"err",
"error",
")",
"{",
"if",
"response",
",",
"err",
"=",
"c",
".",
"Send",
"(",
"Auth",
",",
"password",
")",
";",
"nil",
... | // Authorize calls Send with the appropriate command type and the provided
// password. The response packet is returned if authorization is successful
// or a potential error. | [
"Authorize",
"calls",
"Send",
"with",
"the",
"appropriate",
"command",
"type",
"and",
"the",
"provided",
"password",
".",
"The",
"response",
"packet",
"is",
"returned",
"if",
"authorization",
"is",
"successful",
"or",
"a",
"potential",
"error",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/minecraft/internal/rcon/rcon.go#L92-L104 |
128,214 | influxdata/telegraf | plugins/inputs/minecraft/internal/rcon/rcon.go | Execute | func (c *Client) Execute(command string) (response *Packet, err error) {
return c.Send(Exec, command)
} | go | func (c *Client) Execute(command string) (response *Packet, err error) {
return c.Send(Exec, command)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Execute",
"(",
"command",
"string",
")",
"(",
"response",
"*",
"Packet",
",",
"err",
"error",
")",
"{",
"return",
"c",
".",
"Send",
"(",
"Exec",
",",
"command",
")",
"\n",
"}"
] | // Execute calls Send with the appropriate command type and the provided
// command. The response packet is returned if the command executed successfully
// or a potential error. | [
"Execute",
"calls",
"Send",
"with",
"the",
"appropriate",
"command",
"type",
"and",
"the",
"provided",
"command",
".",
"The",
"response",
"packet",
"is",
"returned",
"if",
"the",
"command",
"executed",
"successfully",
"or",
"a",
"potential",
"error",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/minecraft/internal/rcon/rcon.go#L109-L111 |
128,215 | influxdata/telegraf | plugins/inputs/minecraft/internal/rcon/rcon.go | Send | func (c *Client) Send(typ int32, command string) (response *Packet, err error) {
if typ != Auth && !c.Authorized {
err = ErrUnauthorizedRequest
return
}
// Create a random challenge for the server to mirror in its response.
var challenge int32
binary.Read(rand.Reader, binary.LittleEndian, &challenge)
// Cre... | go | func (c *Client) Send(typ int32, command string) (response *Packet, err error) {
if typ != Auth && !c.Authorized {
err = ErrUnauthorizedRequest
return
}
// Create a random challenge for the server to mirror in its response.
var challenge int32
binary.Read(rand.Reader, binary.LittleEndian, &challenge)
// Cre... | [
"func",
"(",
"c",
"*",
"Client",
")",
"Send",
"(",
"typ",
"int32",
",",
"command",
"string",
")",
"(",
"response",
"*",
"Packet",
",",
"err",
"error",
")",
"{",
"if",
"typ",
"!=",
"Auth",
"&&",
"!",
"c",
".",
"Authorized",
"{",
"err",
"=",
"ErrUn... | // Sends accepts the commands type and its string to execute to the clients server,
// creating a packet with a random challenge id for the server to mirror,
// and compiling its payload bytes in the appropriate order. The resonse is
// decompiled from its bytes into a Packet type for return. An error is returned
// if... | [
"Sends",
"accepts",
"the",
"commands",
"type",
"and",
"its",
"string",
"to",
"execute",
"to",
"the",
"clients",
"server",
"creating",
"a",
"packet",
"with",
"a",
"random",
"challenge",
"id",
"for",
"the",
"server",
"to",
"mirror",
"and",
"compiling",
"its",
... | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/minecraft/internal/rcon/rcon.go#L118-L197 |
128,216 | influxdata/telegraf | plugins/inputs/minecraft/internal/rcon/rcon.go | NewClient | func NewClient(host string, port int) (client *Client, err error) {
client = new(Client)
client.Host = host
client.Port = port
client.Connection, err = net.Dial("tcp", fmt.Sprintf("%v:%v", client.Host, client.Port))
return
} | go | func NewClient(host string, port int) (client *Client, err error) {
client = new(Client)
client.Host = host
client.Port = port
client.Connection, err = net.Dial("tcp", fmt.Sprintf("%v:%v", client.Host, client.Port))
return
} | [
"func",
"NewClient",
"(",
"host",
"string",
",",
"port",
"int",
")",
"(",
"client",
"*",
"Client",
",",
"err",
"error",
")",
"{",
"client",
"=",
"new",
"(",
"Client",
")",
"\n",
"client",
".",
"Host",
"=",
"host",
"\n",
"client",
".",
"Port",
"=",
... | // NewClient creates a new Client type, creating the connection
// to the server specified by the host and port arguments. If
// the connection fails, an error is returned. | [
"NewClient",
"creates",
"a",
"new",
"Client",
"type",
"creating",
"the",
"connection",
"to",
"the",
"server",
"specified",
"by",
"the",
"host",
"and",
"port",
"arguments",
".",
"If",
"the",
"connection",
"fails",
"an",
"error",
"is",
"returned",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/minecraft/internal/rcon/rcon.go#L202-L208 |
128,217 | influxdata/telegraf | plugins/inputs/bind/json_stats.go | addJSONCounter | func addJSONCounter(acc telegraf.Accumulator, commonTags map[string]string, stats map[string]int) {
grouper := metric.NewSeriesGrouper()
ts := time.Now()
for name, value := range stats {
if commonTags["type"] == "opcode" && strings.HasPrefix(name, "RESERVED") {
continue
}
tags := make(map[string]string)
... | go | func addJSONCounter(acc telegraf.Accumulator, commonTags map[string]string, stats map[string]int) {
grouper := metric.NewSeriesGrouper()
ts := time.Now()
for name, value := range stats {
if commonTags["type"] == "opcode" && strings.HasPrefix(name, "RESERVED") {
continue
}
tags := make(map[string]string)
... | [
"func",
"addJSONCounter",
"(",
"acc",
"telegraf",
".",
"Accumulator",
",",
"commonTags",
"map",
"[",
"string",
"]",
"string",
",",
"stats",
"map",
"[",
"string",
"]",
"int",
")",
"{",
"grouper",
":=",
"metric",
".",
"NewSeriesGrouper",
"(",
")",
"\n",
"t... | // addJSONCounter adds a counter array to a Telegraf Accumulator, with the specified tags. | [
"addJSONCounter",
"adds",
"a",
"counter",
"array",
"to",
"a",
"Telegraf",
"Accumulator",
"with",
"the",
"specified",
"tags",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/bind/json_stats.go#L44-L66 |
128,218 | influxdata/telegraf | plugins/inputs/bind/json_stats.go | addStatsJSON | func (b *Bind) addStatsJSON(stats jsonStats, acc telegraf.Accumulator, urlTag string) {
grouper := metric.NewSeriesGrouper()
ts := time.Now()
tags := map[string]string{"url": urlTag}
host, port, _ := net.SplitHostPort(urlTag)
tags["source"] = host
tags["port"] = port
// Opcodes
tags["type"] = "opcode"
addJSON... | go | func (b *Bind) addStatsJSON(stats jsonStats, acc telegraf.Accumulator, urlTag string) {
grouper := metric.NewSeriesGrouper()
ts := time.Now()
tags := map[string]string{"url": urlTag}
host, port, _ := net.SplitHostPort(urlTag)
tags["source"] = host
tags["port"] = port
// Opcodes
tags["type"] = "opcode"
addJSON... | [
"func",
"(",
"b",
"*",
"Bind",
")",
"addStatsJSON",
"(",
"stats",
"jsonStats",
",",
"acc",
"telegraf",
".",
"Accumulator",
",",
"urlTag",
"string",
")",
"{",
"grouper",
":=",
"metric",
".",
"NewSeriesGrouper",
"(",
")",
"\n",
"ts",
":=",
"time",
".",
"... | // addStatsJson walks a jsonStats struct and adds the values to the telegraf.Accumulator. | [
"addStatsJson",
"walks",
"a",
"jsonStats",
"struct",
"and",
"adds",
"the",
"values",
"to",
"the",
"telegraf",
".",
"Accumulator",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/bind/json_stats.go#L69-L136 |
128,219 | influxdata/telegraf | plugins/parsers/nagios/parser.go | getExitCode | func getExitCode(err error) (int, error) {
if err == nil {
return 0, nil
}
ee, ok := err.(*exec.ExitError)
if !ok {
// If it is not an *exec.ExitError, then it must be
// an io error, but docs do not say anything about the
// exit code in this case.
return 0, errors.New("expected *exec.ExitError")
}
w... | go | func getExitCode(err error) (int, error) {
if err == nil {
return 0, nil
}
ee, ok := err.(*exec.ExitError)
if !ok {
// If it is not an *exec.ExitError, then it must be
// an io error, but docs do not say anything about the
// exit code in this case.
return 0, errors.New("expected *exec.ExitError")
}
w... | [
"func",
"getExitCode",
"(",
"err",
"error",
")",
"(",
"int",
",",
"error",
")",
"{",
"if",
"err",
"==",
"nil",
"{",
"return",
"0",
",",
"nil",
"\n",
"}",
"\n\n",
"ee",
",",
"ok",
":=",
"err",
".",
"(",
"*",
"exec",
".",
"ExitError",
")",
"\n",
... | // getExitCode get the exit code from an error value which is the result
// of running a command through exec package api. | [
"getExitCode",
"get",
"the",
"exit",
"code",
"from",
"an",
"error",
"value",
"which",
"is",
"the",
"result",
"of",
"running",
"a",
"command",
"through",
"exec",
"package",
"api",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/parsers/nagios/parser.go#L22-L41 |
128,220 | influxdata/telegraf | plugins/parsers/nagios/parser.go | TryAddState | func TryAddState(runErr error, metrics []telegraf.Metric) ([]telegraf.Metric, error) {
state, err := getExitCode(runErr)
if err != nil {
return metrics, fmt.Errorf("exec: get exit code: %s", err)
}
for _, m := range metrics {
if m.Name() == "nagios_state" {
m.AddField("state", state)
return metrics, nil
... | go | func TryAddState(runErr error, metrics []telegraf.Metric) ([]telegraf.Metric, error) {
state, err := getExitCode(runErr)
if err != nil {
return metrics, fmt.Errorf("exec: get exit code: %s", err)
}
for _, m := range metrics {
if m.Name() == "nagios_state" {
m.AddField("state", state)
return metrics, nil
... | [
"func",
"TryAddState",
"(",
"runErr",
"error",
",",
"metrics",
"[",
"]",
"telegraf",
".",
"Metric",
")",
"(",
"[",
"]",
"telegraf",
".",
"Metric",
",",
"error",
")",
"{",
"state",
",",
"err",
":=",
"getExitCode",
"(",
"runErr",
")",
"\n",
"if",
"err"... | // TryAddState attempts to add a state derived from the runErr.
// If any error occurs, it is guaranteed to be returned along with
// the initial metric slice. | [
"TryAddState",
"attempts",
"to",
"add",
"a",
"state",
"derived",
"from",
"the",
"runErr",
".",
"If",
"any",
"error",
"occurs",
"it",
"is",
"guaranteed",
"to",
"be",
"returned",
"along",
"with",
"the",
"initial",
"metric",
"slice",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/parsers/nagios/parser.go#L46-L74 |
128,221 | influxdata/telegraf | plugins/inputs/filestat/filestat.go | getMd5 | func getMd5(file string) (string, error) {
of, err := os.Open(file)
if err != nil {
return "", err
}
defer of.Close()
hash := md5.New()
_, err = io.Copy(hash, of)
if err != nil {
// fatal error
return "", err
}
return fmt.Sprintf("%x", hash.Sum(nil)), nil
} | go | func getMd5(file string) (string, error) {
of, err := os.Open(file)
if err != nil {
return "", err
}
defer of.Close()
hash := md5.New()
_, err = io.Copy(hash, of)
if err != nil {
// fatal error
return "", err
}
return fmt.Sprintf("%x", hash.Sum(nil)), nil
} | [
"func",
"getMd5",
"(",
"file",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"of",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"file",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"defer",
... | // Read given file and calculate an md5 hash. | [
"Read",
"given",
"file",
"and",
"calculate",
"an",
"md5",
"hash",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/filestat/filestat.go#L113-L127 |
128,222 | influxdata/telegraf | plugins/inputs/wireless/wireless_linux.go | Gather | func (w *Wireless) Gather(acc telegraf.Accumulator) error {
// load proc path, get default value if config value and env variable are empty
w.loadPath()
wirelessPath := path.Join(w.HostProc, "net", "wireless")
table, err := ioutil.ReadFile(wirelessPath)
if err != nil {
return err
}
interfaces, err := loadWir... | go | func (w *Wireless) Gather(acc telegraf.Accumulator) error {
// load proc path, get default value if config value and env variable are empty
w.loadPath()
wirelessPath := path.Join(w.HostProc, "net", "wireless")
table, err := ioutil.ReadFile(wirelessPath)
if err != nil {
return err
}
interfaces, err := loadWir... | [
"func",
"(",
"w",
"*",
"Wireless",
")",
"Gather",
"(",
"acc",
"telegraf",
".",
"Accumulator",
")",
"error",
"{",
"// load proc path, get default value if config value and env variable are empty",
"w",
".",
"loadPath",
"(",
")",
"\n\n",
"wirelessPath",
":=",
"path",
... | // Gather collects the wireless information. | [
"Gather",
"collects",
"the",
"wireless",
"information",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/wireless/wireless_linux.go#L44-L81 |
128,223 | influxdata/telegraf | plugins/inputs/github/github.go | createGitHubClient | func (g *GitHub) createGitHubClient(ctx context.Context) (*github.Client, error) {
httpClient := &http.Client{
Transport: &http.Transport{
Proxy: http.ProxyFromEnvironment,
},
Timeout: g.HTTPTimeout.Duration,
}
g.obfusticatedToken = "Unauthenticated"
if g.AccessToken != "" {
tokenSource := oauth2.Stati... | go | func (g *GitHub) createGitHubClient(ctx context.Context) (*github.Client, error) {
httpClient := &http.Client{
Transport: &http.Transport{
Proxy: http.ProxyFromEnvironment,
},
Timeout: g.HTTPTimeout.Duration,
}
g.obfusticatedToken = "Unauthenticated"
if g.AccessToken != "" {
tokenSource := oauth2.Stati... | [
"func",
"(",
"g",
"*",
"GitHub",
")",
"createGitHubClient",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"*",
"github",
".",
"Client",
",",
"error",
")",
"{",
"httpClient",
":=",
"&",
"http",
".",
"Client",
"{",
"Transport",
":",
"&",
"http",
"."... | // Create GitHub Client | [
"Create",
"GitHub",
"Client"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/github/github.go#L55-L78 |
128,224 | influxdata/telegraf | plugins/inputs/github/github.go | Gather | func (g *GitHub) Gather(acc telegraf.Accumulator) error {
ctx := context.Background()
if g.githubClient == nil {
githubClient, err := g.createGitHubClient(ctx)
if err != nil {
return err
}
g.githubClient = githubClient
tokenTags := map[string]string{
"access_token": g.obfusticatedToken,
}
g.R... | go | func (g *GitHub) Gather(acc telegraf.Accumulator) error {
ctx := context.Background()
if g.githubClient == nil {
githubClient, err := g.createGitHubClient(ctx)
if err != nil {
return err
}
g.githubClient = githubClient
tokenTags := map[string]string{
"access_token": g.obfusticatedToken,
}
g.R... | [
"func",
"(",
"g",
"*",
"GitHub",
")",
"Gather",
"(",
"acc",
"telegraf",
".",
"Accumulator",
")",
"error",
"{",
"ctx",
":=",
"context",
".",
"Background",
"(",
")",
"\n\n",
"if",
"g",
".",
"githubClient",
"==",
"nil",
"{",
"githubClient",
",",
"err",
... | // Gather GitHub Metrics | [
"Gather",
"GitHub",
"Metrics"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/github/github.go#L81-L139 |
128,225 | influxdata/telegraf | plugins/inputs/x509_cert/x509_cert.go | Gather | func (c *X509Cert) Gather(acc telegraf.Accumulator) error {
now := time.Now()
for _, location := range c.Sources {
certs, err := c.getCert(location, c.Timeout.Duration*time.Second)
if err != nil {
acc.AddError(fmt.Errorf("cannot get SSL cert '%s': %s", location, err.Error()))
}
for _, cert := range certs... | go | func (c *X509Cert) Gather(acc telegraf.Accumulator) error {
now := time.Now()
for _, location := range c.Sources {
certs, err := c.getCert(location, c.Timeout.Duration*time.Second)
if err != nil {
acc.AddError(fmt.Errorf("cannot get SSL cert '%s': %s", location, err.Error()))
}
for _, cert := range certs... | [
"func",
"(",
"c",
"*",
"X509Cert",
")",
"Gather",
"(",
"acc",
"telegraf",
".",
"Accumulator",
")",
"error",
"{",
"now",
":=",
"time",
".",
"Now",
"(",
")",
"\n\n",
"for",
"_",
",",
"location",
":=",
"range",
"c",
".",
"Sources",
"{",
"certs",
",",
... | // Gather adds metrics into the accumulator. | [
"Gather",
"adds",
"metrics",
"into",
"the",
"accumulator",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/x509_cert/x509_cert.go#L163-L181 |
128,226 | influxdata/telegraf | plugins/parsers/registry.go | NewParser | func NewParser(config *Config) (Parser, error) {
var err error
var parser Parser
switch config.DataFormat {
case "json":
parser = newJSONParser(config.MetricName,
config.TagKeys,
config.JSONNameKey,
config.JSONStringFields,
config.JSONQuery,
config.JSONTimeKey,
config.JSONTimeFormat,
config.J... | go | func NewParser(config *Config) (Parser, error) {
var err error
var parser Parser
switch config.DataFormat {
case "json":
parser = newJSONParser(config.MetricName,
config.TagKeys,
config.JSONNameKey,
config.JSONStringFields,
config.JSONQuery,
config.JSONTimeKey,
config.JSONTimeFormat,
config.J... | [
"func",
"NewParser",
"(",
"config",
"*",
"Config",
")",
"(",
"Parser",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n",
"var",
"parser",
"Parser",
"\n",
"switch",
"config",
".",
"DataFormat",
"{",
"case",
"\"",
"\"",
":",
"parser",
"=",
"newJSONPar... | // NewParser returns a Parser interface based on the given config. | [
"NewParser",
"returns",
"a",
"Parser",
"interface",
"based",
"on",
"the",
"given",
"config",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/parsers/registry.go#L147-L216 |
128,227 | influxdata/telegraf | plugins/parsers/registry.go | NewLogFmtParser | func NewLogFmtParser(metricName string, defaultTags map[string]string) (Parser, error) {
return logfmt.NewParser(metricName, defaultTags), nil
} | go | func NewLogFmtParser(metricName string, defaultTags map[string]string) (Parser, error) {
return logfmt.NewParser(metricName, defaultTags), nil
} | [
"func",
"NewLogFmtParser",
"(",
"metricName",
"string",
",",
"defaultTags",
"map",
"[",
"string",
"]",
"string",
")",
"(",
"Parser",
",",
"error",
")",
"{",
"return",
"logfmt",
".",
"NewParser",
"(",
"metricName",
",",
"defaultTags",
")",
",",
"nil",
"\n",... | // NewLogFmtParser returns a logfmt parser with the default options. | [
"NewLogFmtParser",
"returns",
"a",
"logfmt",
"parser",
"with",
"the",
"default",
"options",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/parsers/registry.go#L396-L398 |
128,228 | influxdata/telegraf | selfstat/stat.go | Tags | func (s *stat) Tags() map[string]string {
m := make(map[string]string, len(s.tags))
for k, v := range s.tags {
m[k] = v
}
return m
} | go | func (s *stat) Tags() map[string]string {
m := make(map[string]string, len(s.tags))
for k, v := range s.tags {
m[k] = v
}
return m
} | [
"func",
"(",
"s",
"*",
"stat",
")",
"Tags",
"(",
")",
"map",
"[",
"string",
"]",
"string",
"{",
"m",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"len",
"(",
"s",
".",
"tags",
")",
")",
"\n",
"for",
"k",
",",
"v",
":=",
"ran... | // Tags returns a copy of the stat's tags.
// NOTE this allocates a new map every time it is called. | [
"Tags",
"returns",
"a",
"copy",
"of",
"the",
"stat",
"s",
"tags",
".",
"NOTE",
"this",
"allocates",
"a",
"new",
"map",
"every",
"time",
"it",
"is",
"called",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/selfstat/stat.go#L37-L43 |
128,229 | influxdata/telegraf | plugins/inputs/twemproxy/twemproxy.go | Gather | func (t *Twemproxy) Gather(acc telegraf.Accumulator) error {
conn, err := net.DialTimeout("tcp", t.Addr, 1*time.Second)
if err != nil {
return err
}
body, err := ioutil.ReadAll(conn)
if err != nil {
return err
}
var stats map[string]interface{}
if err = json.Unmarshal(body, &stats); err != nil {
return e... | go | func (t *Twemproxy) Gather(acc telegraf.Accumulator) error {
conn, err := net.DialTimeout("tcp", t.Addr, 1*time.Second)
if err != nil {
return err
}
body, err := ioutil.ReadAll(conn)
if err != nil {
return err
}
var stats map[string]interface{}
if err = json.Unmarshal(body, &stats); err != nil {
return e... | [
"func",
"(",
"t",
"*",
"Twemproxy",
")",
"Gather",
"(",
"acc",
"telegraf",
".",
"Accumulator",
")",
"error",
"{",
"conn",
",",
"err",
":=",
"net",
".",
"DialTimeout",
"(",
"\"",
"\"",
",",
"t",
".",
"Addr",
",",
"1",
"*",
"time",
".",
"Second",
"... | // Gather data from all Twemproxy instances | [
"Gather",
"data",
"from",
"all",
"Twemproxy",
"instances"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/twemproxy/twemproxy.go#L35-L55 |
128,230 | influxdata/telegraf | plugins/inputs/twemproxy/twemproxy.go | processStat | func (t *Twemproxy) processStat(
acc telegraf.Accumulator,
tags map[string]string,
data map[string]interface{},
) {
if source, ok := data["source"]; ok {
if val, ok := source.(string); ok {
tags["source"] = val
}
}
fields := make(map[string]interface{})
metrics := []string{"total_connections", "curr_conn... | go | func (t *Twemproxy) processStat(
acc telegraf.Accumulator,
tags map[string]string,
data map[string]interface{},
) {
if source, ok := data["source"]; ok {
if val, ok := source.(string); ok {
tags["source"] = val
}
}
fields := make(map[string]interface{})
metrics := []string{"total_connections", "curr_conn... | [
"func",
"(",
"t",
"*",
"Twemproxy",
")",
"processStat",
"(",
"acc",
"telegraf",
".",
"Accumulator",
",",
"tags",
"map",
"[",
"string",
"]",
"string",
",",
"data",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
")",
"{",
"if",
"source",
",",
... | // Process Twemproxy server stats | [
"Process",
"Twemproxy",
"server",
"stats"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/twemproxy/twemproxy.go#L58-L89 |
128,231 | influxdata/telegraf | plugins/inputs/twemproxy/twemproxy.go | processPool | func (t *Twemproxy) processPool(
acc telegraf.Accumulator,
tags map[string]string,
data map[string]interface{},
) {
serverTags := make(map[string]map[string]string)
fields := make(map[string]interface{})
for key, value := range data {
switch key {
case "client_connections", "forward_error", "client_err", "se... | go | func (t *Twemproxy) processPool(
acc telegraf.Accumulator,
tags map[string]string,
data map[string]interface{},
) {
serverTags := make(map[string]map[string]string)
fields := make(map[string]interface{})
for key, value := range data {
switch key {
case "client_connections", "forward_error", "client_err", "se... | [
"func",
"(",
"t",
"*",
"Twemproxy",
")",
"processPool",
"(",
"acc",
"telegraf",
".",
"Accumulator",
",",
"tags",
"map",
"[",
"string",
"]",
"string",
",",
"data",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
")",
"{",
"serverTags",
":=",
"m... | // Process pool data in Twemproxy stats | [
"Process",
"pool",
"data",
"in",
"Twemproxy",
"stats"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/twemproxy/twemproxy.go#L92-L117 |
128,232 | influxdata/telegraf | plugins/inputs/twemproxy/twemproxy.go | copyTags | func copyTags(tags map[string]string) map[string]string {
newTags := make(map[string]string)
for k, v := range tags {
newTags[k] = v
}
return newTags
} | go | func copyTags(tags map[string]string) map[string]string {
newTags := make(map[string]string)
for k, v := range tags {
newTags[k] = v
}
return newTags
} | [
"func",
"copyTags",
"(",
"tags",
"map",
"[",
"string",
"]",
"string",
")",
"map",
"[",
"string",
"]",
"string",
"{",
"newTags",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
")",
"\n",
"for",
"k",
",",
"v",
":=",
"range",
"tags",
"{",
"... | // Tags is not expected to be mutated after passing to Add. | [
"Tags",
"is",
"not",
"expected",
"to",
"be",
"mutated",
"after",
"passing",
"to",
"Add",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/twemproxy/twemproxy.go#L138-L144 |
128,233 | influxdata/telegraf | plugins/inputs/procstat/native_finder.go | Uid | func (pg *NativeFinder) Uid(user string) ([]PID, error) {
var dst []PID
procs, err := process.Processes()
if err != nil {
return dst, err
}
for _, p := range procs {
username, err := p.Username()
if err != nil {
//skip, this can happen if we don't have permissions or
//the pid no longer exists
conti... | go | func (pg *NativeFinder) Uid(user string) ([]PID, error) {
var dst []PID
procs, err := process.Processes()
if err != nil {
return dst, err
}
for _, p := range procs {
username, err := p.Username()
if err != nil {
//skip, this can happen if we don't have permissions or
//the pid no longer exists
conti... | [
"func",
"(",
"pg",
"*",
"NativeFinder",
")",
"Uid",
"(",
"user",
"string",
")",
"(",
"[",
"]",
"PID",
",",
"error",
")",
"{",
"var",
"dst",
"[",
"]",
"PID",
"\n",
"procs",
",",
"err",
":=",
"process",
".",
"Processes",
"(",
")",
"\n",
"if",
"er... | //Uid will return all pids for the given user | [
"Uid",
"will",
"return",
"all",
"pids",
"for",
"the",
"given",
"user"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/procstat/native_finder.go#L22-L40 |
128,234 | influxdata/telegraf | plugins/inputs/procstat/native_finder.go | PidFile | func (pg *NativeFinder) PidFile(path string) ([]PID, error) {
var pids []PID
pidString, err := ioutil.ReadFile(path)
if err != nil {
return pids, fmt.Errorf("Failed to read pidfile '%s'. Error: '%s'",
path, err)
}
pid, err := strconv.Atoi(strings.TrimSpace(string(pidString)))
if err != nil {
return pids, e... | go | func (pg *NativeFinder) PidFile(path string) ([]PID, error) {
var pids []PID
pidString, err := ioutil.ReadFile(path)
if err != nil {
return pids, fmt.Errorf("Failed to read pidfile '%s'. Error: '%s'",
path, err)
}
pid, err := strconv.Atoi(strings.TrimSpace(string(pidString)))
if err != nil {
return pids, e... | [
"func",
"(",
"pg",
"*",
"NativeFinder",
")",
"PidFile",
"(",
"path",
"string",
")",
"(",
"[",
"]",
"PID",
",",
"error",
")",
"{",
"var",
"pids",
"[",
"]",
"PID",
"\n",
"pidString",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"path",
")",
"\... | //PidFile returns the pid from the pid file given. | [
"PidFile",
"returns",
"the",
"pid",
"from",
"the",
"pid",
"file",
"given",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/procstat/native_finder.go#L43-L57 |
128,235 | influxdata/telegraf | plugins/parsers/wavefront/parser.go | NewWavefrontElements | func NewWavefrontElements() []ElementParser {
var elements []ElementParser
wsParser := WhiteSpaceParser{}
wsParserNextOpt := WhiteSpaceParser{nextOptional: true}
repeatParser := LoopedParser{wrappedParser: &TagParser{}, wsPaser: &wsParser}
elements = append(elements, &NameParser{}, &wsParser, &ValueParser{}, &wsPa... | go | func NewWavefrontElements() []ElementParser {
var elements []ElementParser
wsParser := WhiteSpaceParser{}
wsParserNextOpt := WhiteSpaceParser{nextOptional: true}
repeatParser := LoopedParser{wrappedParser: &TagParser{}, wsPaser: &wsParser}
elements = append(elements, &NameParser{}, &wsParser, &ValueParser{}, &wsPa... | [
"func",
"NewWavefrontElements",
"(",
")",
"[",
"]",
"ElementParser",
"{",
"var",
"elements",
"[",
"]",
"ElementParser",
"\n",
"wsParser",
":=",
"WhiteSpaceParser",
"{",
"}",
"\n",
"wsParserNextOpt",
":=",
"WhiteSpaceParser",
"{",
"nextOptional",
":",
"true",
"}"... | // Returns a slice of ElementParser's for the Graphite format | [
"Returns",
"a",
"slice",
"of",
"ElementParser",
"s",
"for",
"the",
"Graphite",
"format"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/parsers/wavefront/parser.go#L46-L54 |
128,236 | influxdata/telegraf | plugins/parsers/wavefront/parser.go | scan | func (p *PointParser) scan() (Token, string) {
// If we have a token on the buffer, then return it.
if p.buf.n != 0 {
idx := p.buf.n % MAX_BUFFER_SIZE
tok, lit := p.buf.tok[idx], p.buf.lit[idx]
p.buf.n -= 1
return tok, lit
}
// Otherwise read the next token from the scanner.
tok, lit := p.s.Scan()
// Sa... | go | func (p *PointParser) scan() (Token, string) {
// If we have a token on the buffer, then return it.
if p.buf.n != 0 {
idx := p.buf.n % MAX_BUFFER_SIZE
tok, lit := p.buf.tok[idx], p.buf.lit[idx]
p.buf.n -= 1
return tok, lit
}
// Otherwise read the next token from the scanner.
tok, lit := p.s.Scan()
// Sa... | [
"func",
"(",
"p",
"*",
"PointParser",
")",
"scan",
"(",
")",
"(",
"Token",
",",
"string",
")",
"{",
"// If we have a token on the buffer, then return it.",
"if",
"p",
".",
"buf",
".",
"n",
"!=",
"0",
"{",
"idx",
":=",
"p",
".",
"buf",
".",
"n",
"%",
... | // scan returns the next token from the underlying scanner.
// If a token has been unscanned then read that from the internal buffer instead. | [
"scan",
"returns",
"the",
"next",
"token",
"from",
"the",
"underlying",
"scanner",
".",
"If",
"a",
"token",
"has",
"been",
"unscanned",
"then",
"read",
"that",
"from",
"the",
"internal",
"buffer",
"instead",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/parsers/wavefront/parser.go#L170-L186 |
128,237 | influxdata/telegraf | internal/models/running_aggregator.go | Add | func (r *RunningAggregator) Add(m telegraf.Metric) bool {
if ok := r.Config.Filter.Select(m); !ok {
return false
}
// Make a copy of the metric but don't retain tracking. We do not fail a
// delivery due to the aggregation not being sent because we can't create
// aggregations of historical data. Additionally... | go | func (r *RunningAggregator) Add(m telegraf.Metric) bool {
if ok := r.Config.Filter.Select(m); !ok {
return false
}
// Make a copy of the metric but don't retain tracking. We do not fail a
// delivery due to the aggregation not being sent because we can't create
// aggregations of historical data. Additionally... | [
"func",
"(",
"r",
"*",
"RunningAggregator",
")",
"Add",
"(",
"m",
"telegraf",
".",
"Metric",
")",
"bool",
"{",
"if",
"ok",
":=",
"r",
".",
"Config",
".",
"Filter",
".",
"Select",
"(",
"m",
")",
";",
"!",
"ok",
"{",
"return",
"false",
"\n",
"}",
... | // Add a metric to the aggregator and return true if the original metric
// should be dropped. | [
"Add",
"a",
"metric",
"to",
"the",
"aggregator",
"and",
"return",
"true",
"if",
"the",
"original",
"metric",
"should",
"be",
"dropped",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/internal/models/running_aggregator.go#L108-L137 |
128,238 | influxdata/telegraf | plugins/inputs/win_perf_counters/performance_query.go | Open | func (m *PerformanceQueryImpl) Open() error {
if m.query != 0 {
err := m.Close()
if err != nil {
return err
}
}
var handle PDH_HQUERY
if ret := PdhOpenQuery(0, 0, &handle); ret != ERROR_SUCCESS {
return NewPdhError(ret)
}
m.query = handle
return nil
} | go | func (m *PerformanceQueryImpl) Open() error {
if m.query != 0 {
err := m.Close()
if err != nil {
return err
}
}
var handle PDH_HQUERY
if ret := PdhOpenQuery(0, 0, &handle); ret != ERROR_SUCCESS {
return NewPdhError(ret)
}
m.query = handle
return nil
} | [
"func",
"(",
"m",
"*",
"PerformanceQueryImpl",
")",
"Open",
"(",
")",
"error",
"{",
"if",
"m",
".",
"query",
"!=",
"0",
"{",
"err",
":=",
"m",
".",
"Close",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
... | // Open creates a new counterPath that is used to manage the collection of performance data.
// It returns counterPath handle used for subsequent calls for adding counters and querying data | [
"Open",
"creates",
"a",
"new",
"counterPath",
"that",
"is",
"used",
"to",
"manage",
"the",
"collection",
"of",
"performance",
"data",
".",
"It",
"returns",
"counterPath",
"handle",
"used",
"for",
"subsequent",
"calls",
"for",
"adding",
"counters",
"and",
"quer... | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/win_perf_counters/performance_query.go#L58-L72 |
128,239 | influxdata/telegraf | plugins/inputs/win_perf_counters/performance_query.go | Close | func (m *PerformanceQueryImpl) Close() error {
if m.query == 0 {
return errors.New("uninitialised query")
}
if ret := PdhCloseQuery(m.query); ret != ERROR_SUCCESS {
return NewPdhError(ret)
}
m.query = 0
return nil
} | go | func (m *PerformanceQueryImpl) Close() error {
if m.query == 0 {
return errors.New("uninitialised query")
}
if ret := PdhCloseQuery(m.query); ret != ERROR_SUCCESS {
return NewPdhError(ret)
}
m.query = 0
return nil
} | [
"func",
"(",
"m",
"*",
"PerformanceQueryImpl",
")",
"Close",
"(",
")",
"error",
"{",
"if",
"m",
".",
"query",
"==",
"0",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"ret",
":=",
"PdhCloseQuery",
"(",
"m",
"... | // Close closes the counterPath, releases associated counter handles and frees resources | [
"Close",
"closes",
"the",
"counterPath",
"releases",
"associated",
"counter",
"handles",
"and",
"frees",
"resources"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/win_perf_counters/performance_query.go#L75-L85 |
128,240 | influxdata/telegraf | plugins/inputs/win_perf_counters/performance_query.go | GetCounterPath | func (m *PerformanceQueryImpl) GetCounterPath(counterHandle PDH_HCOUNTER) (string, error) {
var bufSize uint32
var buff []byte
var ret uint32
if ret = PdhGetCounterInfo(counterHandle, 0, &bufSize, nil); ret == PDH_MORE_DATA {
buff = make([]byte, bufSize)
bufSize = uint32(len(buff))
if ret = PdhGetCounterInfo(... | go | func (m *PerformanceQueryImpl) GetCounterPath(counterHandle PDH_HCOUNTER) (string, error) {
var bufSize uint32
var buff []byte
var ret uint32
if ret = PdhGetCounterInfo(counterHandle, 0, &bufSize, nil); ret == PDH_MORE_DATA {
buff = make([]byte, bufSize)
bufSize = uint32(len(buff))
if ret = PdhGetCounterInfo(... | [
"func",
"(",
"m",
"*",
"PerformanceQueryImpl",
")",
"GetCounterPath",
"(",
"counterHandle",
"PDH_HCOUNTER",
")",
"(",
"string",
",",
"error",
")",
"{",
"var",
"bufSize",
"uint32",
"\n",
"var",
"buff",
"[",
"]",
"byte",
"\n",
"var",
"ret",
"uint32",
"\n",
... | //GetCounterPath return counter information for given handle | [
"GetCounterPath",
"return",
"counter",
"information",
"for",
"given",
"handle"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/win_perf_counters/performance_query.go#L111-L124 |
128,241 | influxdata/telegraf | plugins/inputs/win_perf_counters/performance_query.go | ExpandWildCardPath | func (m *PerformanceQueryImpl) ExpandWildCardPath(counterPath string) ([]string, error) {
var bufSize uint32
var buff []uint16
var ret uint32
if ret = PdhExpandWildCardPath(counterPath, nil, &bufSize); ret == PDH_MORE_DATA {
buff = make([]uint16, bufSize)
bufSize = uint32(len(buff))
ret = PdhExpandWildCardPa... | go | func (m *PerformanceQueryImpl) ExpandWildCardPath(counterPath string) ([]string, error) {
var bufSize uint32
var buff []uint16
var ret uint32
if ret = PdhExpandWildCardPath(counterPath, nil, &bufSize); ret == PDH_MORE_DATA {
buff = make([]uint16, bufSize)
bufSize = uint32(len(buff))
ret = PdhExpandWildCardPa... | [
"func",
"(",
"m",
"*",
"PerformanceQueryImpl",
")",
"ExpandWildCardPath",
"(",
"counterPath",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"var",
"bufSize",
"uint32",
"\n",
"var",
"buff",
"[",
"]",
"uint16",
"\n",
"var",
"ret",
"uint32... | // ExpandWildCardPath examines local computer and returns those counter paths that match the given counter path which contains wildcard characters. | [
"ExpandWildCardPath",
"examines",
"local",
"computer",
"and",
"returns",
"those",
"counter",
"paths",
"that",
"match",
"the",
"given",
"counter",
"path",
"which",
"contains",
"wildcard",
"characters",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/win_perf_counters/performance_query.go#L127-L142 |
128,242 | influxdata/telegraf | plugins/inputs/win_perf_counters/performance_query.go | GetFormattedCounterValueDouble | func (m *PerformanceQueryImpl) GetFormattedCounterValueDouble(hCounter PDH_HCOUNTER) (float64, error) {
var counterType uint32
var value PDH_FMT_COUNTERVALUE_DOUBLE
var ret uint32
if ret = PdhGetFormattedCounterValueDouble(hCounter, &counterType, &value); ret == ERROR_SUCCESS {
if value.CStatus == PDH_CSTATUS_VA... | go | func (m *PerformanceQueryImpl) GetFormattedCounterValueDouble(hCounter PDH_HCOUNTER) (float64, error) {
var counterType uint32
var value PDH_FMT_COUNTERVALUE_DOUBLE
var ret uint32
if ret = PdhGetFormattedCounterValueDouble(hCounter, &counterType, &value); ret == ERROR_SUCCESS {
if value.CStatus == PDH_CSTATUS_VA... | [
"func",
"(",
"m",
"*",
"PerformanceQueryImpl",
")",
"GetFormattedCounterValueDouble",
"(",
"hCounter",
"PDH_HCOUNTER",
")",
"(",
"float64",
",",
"error",
")",
"{",
"var",
"counterType",
"uint32",
"\n",
"var",
"value",
"PDH_FMT_COUNTERVALUE_DOUBLE",
"\n",
"var",
"r... | //GetFormattedCounterValueDouble computes a displayable value for the specified counter | [
"GetFormattedCounterValueDouble",
"computes",
"a",
"displayable",
"value",
"for",
"the",
"specified",
"counter"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/win_perf_counters/performance_query.go#L145-L159 |
128,243 | influxdata/telegraf | plugins/inputs/win_perf_counters/performance_query.go | UTF16ToStringArray | func UTF16ToStringArray(buf []uint16) []string {
var strings []string
nextLineStart := 0
stringLine := UTF16PtrToString(&buf[0])
for stringLine != "" {
strings = append(strings, stringLine)
nextLineStart += len([]rune(stringLine)) + 1
remainingBuf := buf[nextLineStart:]
stringLine = UTF16PtrToString(&remain... | go | func UTF16ToStringArray(buf []uint16) []string {
var strings []string
nextLineStart := 0
stringLine := UTF16PtrToString(&buf[0])
for stringLine != "" {
strings = append(strings, stringLine)
nextLineStart += len([]rune(stringLine)) + 1
remainingBuf := buf[nextLineStart:]
stringLine = UTF16PtrToString(&remain... | [
"func",
"UTF16ToStringArray",
"(",
"buf",
"[",
"]",
"uint16",
")",
"[",
"]",
"string",
"{",
"var",
"strings",
"[",
"]",
"string",
"\n",
"nextLineStart",
":=",
"0",
"\n",
"stringLine",
":=",
"UTF16PtrToString",
"(",
"&",
"buf",
"[",
"0",
"]",
")",
"\n",... | // UTF16ToStringArray converts list of Windows API NULL terminated strings to go string array | [
"UTF16ToStringArray",
"converts",
"list",
"of",
"Windows",
"API",
"NULL",
"terminated",
"strings",
"to",
"go",
"string",
"array"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/win_perf_counters/performance_query.go#L220-L231 |
128,244 | influxdata/telegraf | plugins/inputs/bind/xml_stats_v2.go | addXMLv2Counter | func addXMLv2Counter(acc telegraf.Accumulator, commonTags map[string]string, stats []v2Counter) {
grouper := metric.NewSeriesGrouper()
ts := time.Now()
for _, c := range stats {
tags := make(map[string]string)
// Create local copy of tags since maps are reference types
for k, v := range commonTags {
tags[k... | go | func addXMLv2Counter(acc telegraf.Accumulator, commonTags map[string]string, stats []v2Counter) {
grouper := metric.NewSeriesGrouper()
ts := time.Now()
for _, c := range stats {
tags := make(map[string]string)
// Create local copy of tags since maps are reference types
for k, v := range commonTags {
tags[k... | [
"func",
"addXMLv2Counter",
"(",
"acc",
"telegraf",
".",
"Accumulator",
",",
"commonTags",
"map",
"[",
"string",
"]",
"string",
",",
"stats",
"[",
"]",
"v2Counter",
")",
"{",
"grouper",
":=",
"metric",
".",
"NewSeriesGrouper",
"(",
")",
"\n",
"ts",
":=",
... | // addXMLv2Counter adds a v2Counter array to a Telegraf Accumulator, with the specified tags | [
"addXMLv2Counter",
"adds",
"a",
"v2Counter",
"array",
"to",
"a",
"Telegraf",
"Accumulator",
"with",
"the",
"specified",
"tags"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/bind/xml_stats_v2.go#L67-L85 |
128,245 | influxdata/telegraf | plugins/inputs/fibaro/fibaro.go | getJSON | func (f *Fibaro) getJSON(path string, dataStruct interface{}) error {
var requestURL = f.URL + path
req, err := http.NewRequest("GET", requestURL, nil)
if err != nil {
return err
}
req.SetBasicAuth(f.Username, f.Password)
resp, err := f.client.Do(req)
if err != nil {
return err
}
if resp.StatusCode != h... | go | func (f *Fibaro) getJSON(path string, dataStruct interface{}) error {
var requestURL = f.URL + path
req, err := http.NewRequest("GET", requestURL, nil)
if err != nil {
return err
}
req.SetBasicAuth(f.Username, f.Password)
resp, err := f.client.Do(req)
if err != nil {
return err
}
if resp.StatusCode != h... | [
"func",
"(",
"f",
"*",
"Fibaro",
")",
"getJSON",
"(",
"path",
"string",
",",
"dataStruct",
"interface",
"{",
"}",
")",
"error",
"{",
"var",
"requestURL",
"=",
"f",
".",
"URL",
"+",
"path",
"\n\n",
"req",
",",
"err",
":=",
"http",
".",
"NewRequest",
... | // getJSON connects, authenticates and reads JSON payload returned by Fibaro box | [
"getJSON",
"connects",
"authenticates",
"and",
"reads",
"JSON",
"payload",
"returned",
"by",
"Fibaro",
"box"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/fibaro/fibaro.go#L84-L117 |
128,246 | influxdata/telegraf | internal/templating/engine.go | Apply | func (e *Engine) Apply(line string) (string, map[string]string, string, error) {
return e.matcher.match(line).Apply(line, e.joiner)
} | go | func (e *Engine) Apply(line string) (string, map[string]string, string, error) {
return e.matcher.match(line).Apply(line, e.joiner)
} | [
"func",
"(",
"e",
"*",
"Engine",
")",
"Apply",
"(",
"line",
"string",
")",
"(",
"string",
",",
"map",
"[",
"string",
"]",
"string",
",",
"string",
",",
"error",
")",
"{",
"return",
"e",
".",
"matcher",
".",
"match",
"(",
"line",
")",
".",
"Apply"... | // Apply extracts the template fields from the given line and returns the measurement
// name, tags and field name | [
"Apply",
"extracts",
"the",
"template",
"fields",
"from",
"the",
"given",
"line",
"and",
"returns",
"the",
"measurement",
"name",
"tags",
"and",
"field",
"name"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/internal/templating/engine.go#L22-L24 |
128,247 | influxdata/telegraf | internal/templating/engine.go | NewEngine | func NewEngine(joiner string, defaultTemplate *Template, templates []string) (*Engine, error) {
engine := Engine{
joiner: joiner,
matcher: newMatcher(defaultTemplate),
}
templateSpecs := parseTemplateSpecs(templates)
for _, templateSpec := range templateSpecs {
if err := engine.matcher.addSpec(templateSpec)... | go | func NewEngine(joiner string, defaultTemplate *Template, templates []string) (*Engine, error) {
engine := Engine{
joiner: joiner,
matcher: newMatcher(defaultTemplate),
}
templateSpecs := parseTemplateSpecs(templates)
for _, templateSpec := range templateSpecs {
if err := engine.matcher.addSpec(templateSpec)... | [
"func",
"NewEngine",
"(",
"joiner",
"string",
",",
"defaultTemplate",
"*",
"Template",
",",
"templates",
"[",
"]",
"string",
")",
"(",
"*",
"Engine",
",",
"error",
")",
"{",
"engine",
":=",
"Engine",
"{",
"joiner",
":",
"joiner",
",",
"matcher",
":",
"... | // NewEngine creates a new templating engine | [
"NewEngine",
"creates",
"a",
"new",
"templating",
"engine"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/internal/templating/engine.go#L27-L41 |
128,248 | influxdata/telegraf | plugins/inputs/zipkin/codec/codec.go | MicroToTime | func MicroToTime(micro int64) time.Time {
return time.Unix(0, micro*int64(time.Microsecond)).UTC()
} | go | func MicroToTime(micro int64) time.Time {
return time.Unix(0, micro*int64(time.Microsecond)).UTC()
} | [
"func",
"MicroToTime",
"(",
"micro",
"int64",
")",
"time",
".",
"Time",
"{",
"return",
"time",
".",
"Unix",
"(",
"0",
",",
"micro",
"*",
"int64",
"(",
"time",
".",
"Microsecond",
")",
")",
".",
"UTC",
"(",
")",
"\n",
"}"
] | // MicroToTime converts zipkin's native time of microseconds into time.Time | [
"MicroToTime",
"converts",
"zipkin",
"s",
"native",
"time",
"of",
"microseconds",
"into",
"time",
".",
"Time"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/zipkin/codec/codec.go#L63-L65 |
128,249 | influxdata/telegraf | plugins/inputs/zipkin/codec/codec.go | NewAnnotations | func NewAnnotations(annotations []Annotation, endpoint Endpoint) []trace.Annotation {
formatted := make([]trace.Annotation, len(annotations))
for i, annotation := range annotations {
formatted[i] = trace.Annotation{
Host: endpoint.Host(),
ServiceName: endpoint.Name(),
Timestamp: annotation.Timesta... | go | func NewAnnotations(annotations []Annotation, endpoint Endpoint) []trace.Annotation {
formatted := make([]trace.Annotation, len(annotations))
for i, annotation := range annotations {
formatted[i] = trace.Annotation{
Host: endpoint.Host(),
ServiceName: endpoint.Name(),
Timestamp: annotation.Timesta... | [
"func",
"NewAnnotations",
"(",
"annotations",
"[",
"]",
"Annotation",
",",
"endpoint",
"Endpoint",
")",
"[",
"]",
"trace",
".",
"Annotation",
"{",
"formatted",
":=",
"make",
"(",
"[",
"]",
"trace",
".",
"Annotation",
",",
"len",
"(",
"annotations",
")",
... | // NewAnnotations converts a slice of Annotation into a slice of new Annotations | [
"NewAnnotations",
"converts",
"a",
"slice",
"of",
"Annotation",
"into",
"a",
"slice",
"of",
"new",
"Annotations"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/zipkin/codec/codec.go#L107-L119 |
128,250 | influxdata/telegraf | plugins/inputs/zipkin/codec/codec.go | NewBinaryAnnotations | func NewBinaryAnnotations(annotations []BinaryAnnotation, endpoint Endpoint) []trace.BinaryAnnotation {
formatted := make([]trace.BinaryAnnotation, len(annotations))
for i, annotation := range annotations {
formatted[i] = trace.BinaryAnnotation{
Host: endpoint.Host(),
ServiceName: endpoint.Name(),
K... | go | func NewBinaryAnnotations(annotations []BinaryAnnotation, endpoint Endpoint) []trace.BinaryAnnotation {
formatted := make([]trace.BinaryAnnotation, len(annotations))
for i, annotation := range annotations {
formatted[i] = trace.BinaryAnnotation{
Host: endpoint.Host(),
ServiceName: endpoint.Name(),
K... | [
"func",
"NewBinaryAnnotations",
"(",
"annotations",
"[",
"]",
"BinaryAnnotation",
",",
"endpoint",
"Endpoint",
")",
"[",
"]",
"trace",
".",
"BinaryAnnotation",
"{",
"formatted",
":=",
"make",
"(",
"[",
"]",
"trace",
".",
"BinaryAnnotation",
",",
"len",
"(",
... | // NewBinaryAnnotations is very similar to NewAnnotations, but it
// converts BinaryAnnotations instead of the normal Annotation | [
"NewBinaryAnnotations",
"is",
"very",
"similar",
"to",
"NewAnnotations",
"but",
"it",
"converts",
"BinaryAnnotations",
"instead",
"of",
"the",
"normal",
"Annotation"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/zipkin/codec/codec.go#L123-L134 |
128,251 | influxdata/telegraf | plugins/inputs/jti_openconfig_telemetry/openconfig_telemetry.go | extractData | func (m *OpenConfigTelemetry) extractData(r *telemetry.OpenConfigData, grpcServer string) []DataGroup {
// Use empty prefix. We will update this when we iterate over key-value pairs
prefix := ""
dgroups := []DataGroup{}
for _, v := range r.Kv {
kv := make(map[string]interface{})
if v.Key == "__prefix__" {
... | go | func (m *OpenConfigTelemetry) extractData(r *telemetry.OpenConfigData, grpcServer string) []DataGroup {
// Use empty prefix. We will update this when we iterate over key-value pairs
prefix := ""
dgroups := []DataGroup{}
for _, v := range r.Kv {
kv := make(map[string]interface{})
if v.Key == "__prefix__" {
... | [
"func",
"(",
"m",
"*",
"OpenConfigTelemetry",
")",
"extractData",
"(",
"r",
"*",
"telemetry",
".",
"OpenConfigData",
",",
"grpcServer",
"string",
")",
"[",
"]",
"DataGroup",
"{",
"// Use empty prefix. We will update this when we iterate over key-value pairs",
"prefix",
... | // Takes in a OC response, extracts tag information from keys and returns a
// list of groups with unique sets of tags+values | [
"Takes",
"in",
"a",
"OC",
"response",
"extracts",
"tag",
"information",
"from",
"keys",
"and",
"returns",
"a",
"list",
"of",
"groups",
"with",
"unique",
"sets",
"of",
"tags",
"+",
"values"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/jti_openconfig_telemetry/openconfig_telemetry.go#L139-L205 |
128,252 | influxdata/telegraf | plugins/inputs/jti_openconfig_telemetry/openconfig_telemetry.go | splitSensorConfig | func (m *OpenConfigTelemetry) splitSensorConfig() int {
var pathlist []*telemetry.Path
var measurementName string
var reportingRate uint32
m.sensorsConfig = make([]sensorConfig, 0)
for _, sensor := range m.Sensors {
spathSplit := strings.Fields(sensor)
reportingRate = uint32(m.SampleFrequency.Duration / time.... | go | func (m *OpenConfigTelemetry) splitSensorConfig() int {
var pathlist []*telemetry.Path
var measurementName string
var reportingRate uint32
m.sensorsConfig = make([]sensorConfig, 0)
for _, sensor := range m.Sensors {
spathSplit := strings.Fields(sensor)
reportingRate = uint32(m.SampleFrequency.Duration / time.... | [
"func",
"(",
"m",
"*",
"OpenConfigTelemetry",
")",
"splitSensorConfig",
"(",
")",
"int",
"{",
"var",
"pathlist",
"[",
"]",
"*",
"telemetry",
".",
"Path",
"\n",
"var",
"measurementName",
"string",
"\n",
"var",
"reportingRate",
"uint32",
"\n\n",
"m",
".",
"s... | // Takes in sensor configuration and converts it into slice of sensorConfig objects | [
"Takes",
"in",
"sensor",
"configuration",
"and",
"converts",
"it",
"into",
"slice",
"of",
"sensorConfig",
"objects"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/jti_openconfig_telemetry/openconfig_telemetry.go#L214-L272 |
128,253 | influxdata/telegraf | plugins/inputs/jti_openconfig_telemetry/openconfig_telemetry.go | collectData | func (m *OpenConfigTelemetry) collectData(ctx context.Context,
grpcServer string, grpcClientConn *grpc.ClientConn,
acc telegraf.Accumulator) error {
c := telemetry.NewOpenConfigTelemetryClient(grpcClientConn)
for _, sensor := range m.sensorsConfig {
m.wg.Add(1)
go func(ctx context.Context, sensor sensorConfig) ... | go | func (m *OpenConfigTelemetry) collectData(ctx context.Context,
grpcServer string, grpcClientConn *grpc.ClientConn,
acc telegraf.Accumulator) error {
c := telemetry.NewOpenConfigTelemetryClient(grpcClientConn)
for _, sensor := range m.sensorsConfig {
m.wg.Add(1)
go func(ctx context.Context, sensor sensorConfig) ... | [
"func",
"(",
"m",
"*",
"OpenConfigTelemetry",
")",
"collectData",
"(",
"ctx",
"context",
".",
"Context",
",",
"grpcServer",
"string",
",",
"grpcClientConn",
"*",
"grpc",
".",
"ClientConn",
",",
"acc",
"telegraf",
".",
"Accumulator",
")",
"error",
"{",
"c",
... | // Subscribes and collects OpenConfig telemetry data from given server | [
"Subscribes",
"and",
"collects",
"OpenConfig",
"telemetry",
"data",
"from",
"given",
"server"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/jti_openconfig_telemetry/openconfig_telemetry.go#L275-L343 |
128,254 | influxdata/telegraf | plugins/inputs/pf/pf.go | Gather | func (pf *PF) Gather(acc telegraf.Accumulator) error {
if pf.PfctlCommand == "" {
var err error
if pf.PfctlCommand, pf.PfctlArgs, err = pf.buildPfctlCmd(); err != nil {
acc.AddError(fmt.Errorf("Can't construct pfctl commandline: %s", err))
return nil
}
}
o, err := pf.infoFunc()
if err != nil {
acc.Ad... | go | func (pf *PF) Gather(acc telegraf.Accumulator) error {
if pf.PfctlCommand == "" {
var err error
if pf.PfctlCommand, pf.PfctlArgs, err = pf.buildPfctlCmd(); err != nil {
acc.AddError(fmt.Errorf("Can't construct pfctl commandline: %s", err))
return nil
}
}
o, err := pf.infoFunc()
if err != nil {
acc.Ad... | [
"func",
"(",
"pf",
"*",
"PF",
")",
"Gather",
"(",
"acc",
"telegraf",
".",
"Accumulator",
")",
"error",
"{",
"if",
"pf",
".",
"PfctlCommand",
"==",
"\"",
"\"",
"{",
"var",
"err",
"error",
"\n",
"if",
"pf",
".",
"PfctlCommand",
",",
"pf",
".",
"Pfctl... | // Gather is the entrypoint for the plugin. | [
"Gather",
"is",
"the",
"entrypoint",
"for",
"the",
"plugin",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/pf/pf.go#L41-L60 |
128,255 | influxdata/telegraf | plugins/inputs/zipkin/handler.go | Register | func (s *SpanHandler) Register(router *mux.Router, recorder Recorder) error {
handler := cors(http.HandlerFunc(s.Spans))
router.Handle(s.Path, handler).Methods("POST", "OPTIONS")
s.recorder = recorder
return nil
} | go | func (s *SpanHandler) Register(router *mux.Router, recorder Recorder) error {
handler := cors(http.HandlerFunc(s.Spans))
router.Handle(s.Path, handler).Methods("POST", "OPTIONS")
s.recorder = recorder
return nil
} | [
"func",
"(",
"s",
"*",
"SpanHandler",
")",
"Register",
"(",
"router",
"*",
"mux",
".",
"Router",
",",
"recorder",
"Recorder",
")",
"error",
"{",
"handler",
":=",
"cors",
"(",
"http",
".",
"HandlerFunc",
"(",
"s",
".",
"Spans",
")",
")",
"\n",
"router... | // Register implements the Service interface. Register accepts zipkin thrift data
// POSTed to the path of the mux router | [
"Register",
"implements",
"the",
"Service",
"interface",
".",
"Register",
"accepts",
"zipkin",
"thrift",
"data",
"POSTed",
"to",
"the",
"path",
"of",
"the",
"mux",
"router"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/zipkin/handler.go#L62-L67 |
128,256 | influxdata/telegraf | plugins/inputs/zipkin/handler.go | Spans | func (s *SpanHandler) Spans(w http.ResponseWriter, r *http.Request) {
defer r.Body.Close()
body := r.Body
var err error
// Handle gzip decoding of the body
if r.Header.Get("Content-Encoding") == "gzip" {
body, err = gzip.NewReader(r.Body)
if err != nil {
s.recorder.Error(err)
w.WriteHeader(http.StatusInt... | go | func (s *SpanHandler) Spans(w http.ResponseWriter, r *http.Request) {
defer r.Body.Close()
body := r.Body
var err error
// Handle gzip decoding of the body
if r.Header.Get("Content-Encoding") == "gzip" {
body, err = gzip.NewReader(r.Body)
if err != nil {
s.recorder.Error(err)
w.WriteHeader(http.StatusInt... | [
"func",
"(",
"s",
"*",
"SpanHandler",
")",
"Spans",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"defer",
"r",
".",
"Body",
".",
"Close",
"(",
")",
"\n",
"body",
":=",
"r",
".",
"Body",
"\n",
"var",
... | // Spans handles zipkin thrift spans | [
"Spans",
"handles",
"zipkin",
"thrift",
"spans"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/zipkin/handler.go#L70-L119 |
128,257 | influxdata/telegraf | plugins/inputs/vsphere/selfhealth.go | NewStopwatch | func NewStopwatch(name, vCenter string) *Stopwatch {
return &Stopwatch{
stat: selfstat.RegisterTiming("vsphere", name+"_ns", map[string]string{"vcenter": vCenter}),
start: time.Now(),
}
} | go | func NewStopwatch(name, vCenter string) *Stopwatch {
return &Stopwatch{
stat: selfstat.RegisterTiming("vsphere", name+"_ns", map[string]string{"vcenter": vCenter}),
start: time.Now(),
}
} | [
"func",
"NewStopwatch",
"(",
"name",
",",
"vCenter",
"string",
")",
"*",
"Stopwatch",
"{",
"return",
"&",
"Stopwatch",
"{",
"stat",
":",
"selfstat",
".",
"RegisterTiming",
"(",
"\"",
"\"",
",",
"name",
"+",
"\"",
"\"",
",",
"map",
"[",
"string",
"]",
... | // NewStopwatch creates a new StopWatch and starts measuring time
// its creation. | [
"NewStopwatch",
"creates",
"a",
"new",
"StopWatch",
"and",
"starts",
"measuring",
"time",
"its",
"creation",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/vsphere/selfhealth.go#L18-L23 |
128,258 | influxdata/telegraf | plugins/inputs/vsphere/selfhealth.go | NewStopwatchWithTags | func NewStopwatchWithTags(name, vCenter string, tags map[string]string) *Stopwatch {
tags["vcenter"] = vCenter
return &Stopwatch{
stat: selfstat.RegisterTiming("vsphere", name+"_ns", tags),
start: time.Now(),
}
} | go | func NewStopwatchWithTags(name, vCenter string, tags map[string]string) *Stopwatch {
tags["vcenter"] = vCenter
return &Stopwatch{
stat: selfstat.RegisterTiming("vsphere", name+"_ns", tags),
start: time.Now(),
}
} | [
"func",
"NewStopwatchWithTags",
"(",
"name",
",",
"vCenter",
"string",
",",
"tags",
"map",
"[",
"string",
"]",
"string",
")",
"*",
"Stopwatch",
"{",
"tags",
"[",
"\"",
"\"",
"]",
"=",
"vCenter",
"\n",
"return",
"&",
"Stopwatch",
"{",
"stat",
":",
"self... | // NewStopwatchWithTags creates a new StopWatch and starts measuring time
// its creation. Allows additional tags. | [
"NewStopwatchWithTags",
"creates",
"a",
"new",
"StopWatch",
"and",
"starts",
"measuring",
"time",
"its",
"creation",
".",
"Allows",
"additional",
"tags",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/vsphere/selfhealth.go#L27-L33 |
128,259 | influxdata/telegraf | plugins/inputs/vsphere/selfhealth.go | Stop | func (s *Stopwatch) Stop() {
s.stat.Set(time.Since(s.start).Nanoseconds())
} | go | func (s *Stopwatch) Stop() {
s.stat.Set(time.Since(s.start).Nanoseconds())
} | [
"func",
"(",
"s",
"*",
"Stopwatch",
")",
"Stop",
"(",
")",
"{",
"s",
".",
"stat",
".",
"Set",
"(",
"time",
".",
"Since",
"(",
"s",
".",
"start",
")",
".",
"Nanoseconds",
"(",
")",
")",
"\n",
"}"
] | // Stop stops a Stopwatch and records the time. | [
"Stop",
"stops",
"a",
"Stopwatch",
"and",
"records",
"the",
"time",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/vsphere/selfhealth.go#L36-L38 |
128,260 | influxdata/telegraf | plugins/inputs/vsphere/selfhealth.go | SendInternalCounter | func SendInternalCounter(name, vCenter string, value int64) {
s := selfstat.Register("vsphere", name, map[string]string{"vcenter": vCenter})
s.Set(value)
} | go | func SendInternalCounter(name, vCenter string, value int64) {
s := selfstat.Register("vsphere", name, map[string]string{"vcenter": vCenter})
s.Set(value)
} | [
"func",
"SendInternalCounter",
"(",
"name",
",",
"vCenter",
"string",
",",
"value",
"int64",
")",
"{",
"s",
":=",
"selfstat",
".",
"Register",
"(",
"\"",
"\"",
",",
"name",
",",
"map",
"[",
"string",
"]",
"string",
"{",
"\"",
"\"",
":",
"vCenter",
"}... | // SendInternalCounter is a convenience method for sending
// non-timing internal metrics. | [
"SendInternalCounter",
"is",
"a",
"convenience",
"method",
"for",
"sending",
"non",
"-",
"timing",
"internal",
"metrics",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/vsphere/selfhealth.go#L42-L45 |
128,261 | influxdata/telegraf | plugins/inputs/vsphere/selfhealth.go | SendInternalCounterWithTags | func SendInternalCounterWithTags(name, vCenter string, tags map[string]string, value int64) {
tags["vcenter"] = vCenter
s := selfstat.Register("vsphere", name, tags)
s.Set(value)
} | go | func SendInternalCounterWithTags(name, vCenter string, tags map[string]string, value int64) {
tags["vcenter"] = vCenter
s := selfstat.Register("vsphere", name, tags)
s.Set(value)
} | [
"func",
"SendInternalCounterWithTags",
"(",
"name",
",",
"vCenter",
"string",
",",
"tags",
"map",
"[",
"string",
"]",
"string",
",",
"value",
"int64",
")",
"{",
"tags",
"[",
"\"",
"\"",
"]",
"=",
"vCenter",
"\n",
"s",
":=",
"selfstat",
".",
"Register",
... | // SendInternalCounterWithTags is a convenience method for sending
// non-timing internal metrics. Allows additional tags | [
"SendInternalCounterWithTags",
"is",
"a",
"convenience",
"method",
"for",
"sending",
"non",
"-",
"timing",
"internal",
"metrics",
".",
"Allows",
"additional",
"tags"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/vsphere/selfhealth.go#L49-L53 |
128,262 | influxdata/telegraf | plugins/inputs/bind/xml_stats_v3.go | addStatsXMLv3 | func (b *Bind) addStatsXMLv3(stats v3Stats, acc telegraf.Accumulator, hostPort string) {
grouper := metric.NewSeriesGrouper()
ts := time.Now()
host, port, _ := net.SplitHostPort(hostPort)
// Counter groups
for _, cg := range stats.Server.CounterGroups {
for _, c := range cg.Counters {
if cg.Type == "opcode" &... | go | func (b *Bind) addStatsXMLv3(stats v3Stats, acc telegraf.Accumulator, hostPort string) {
grouper := metric.NewSeriesGrouper()
ts := time.Now()
host, port, _ := net.SplitHostPort(hostPort)
// Counter groups
for _, cg := range stats.Server.CounterGroups {
for _, c := range cg.Counters {
if cg.Type == "opcode" &... | [
"func",
"(",
"b",
"*",
"Bind",
")",
"addStatsXMLv3",
"(",
"stats",
"v3Stats",
",",
"acc",
"telegraf",
".",
"Accumulator",
",",
"hostPort",
"string",
")",
"{",
"grouper",
":=",
"metric",
".",
"NewSeriesGrouper",
"(",
")",
"\n",
"ts",
":=",
"time",
".",
... | // addStatsXMLv3 walks a v3Stats struct and adds the values to the telegraf.Accumulator. | [
"addStatsXMLv3",
"walks",
"a",
"v3Stats",
"struct",
"and",
"adds",
"the",
"values",
"to",
"the",
"telegraf",
".",
"Accumulator",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/bind/xml_stats_v3.go#L71-L131 |
128,263 | influxdata/telegraf | plugins/serializers/influx/influx.go | SerializeBatch | func (s *Serializer) SerializeBatch(metrics []telegraf.Metric) ([]byte, error) {
s.buf.Reset()
for _, m := range metrics {
_, err := s.Write(&s.buf, m)
if err != nil {
return nil, err
}
}
out := make([]byte, s.buf.Len())
copy(out, s.buf.Bytes())
return out, nil
} | go | func (s *Serializer) SerializeBatch(metrics []telegraf.Metric) ([]byte, error) {
s.buf.Reset()
for _, m := range metrics {
_, err := s.Write(&s.buf, m)
if err != nil {
return nil, err
}
}
out := make([]byte, s.buf.Len())
copy(out, s.buf.Bytes())
return out, nil
} | [
"func",
"(",
"s",
"*",
"Serializer",
")",
"SerializeBatch",
"(",
"metrics",
"[",
"]",
"telegraf",
".",
"Metric",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"s",
".",
"buf",
".",
"Reset",
"(",
")",
"\n",
"for",
"_",
",",
"m",
":=",
"ran... | // SerializeBatch writes the slice of metrics and returns a byte slice of the
// results. The returned byte slice may contain multiple lines of data. | [
"SerializeBatch",
"writes",
"the",
"slice",
"of",
"metrics",
"and",
"returns",
"a",
"byte",
"slice",
"of",
"the",
"results",
".",
"The",
"returned",
"byte",
"slice",
"may",
"contain",
"multiple",
"lines",
"of",
"data",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/serializers/influx/influx.go#L111-L122 |
128,264 | influxdata/telegraf | plugins/inputs/syslog/framing.go | UnmarshalTOML | func (f *Framing) UnmarshalTOML(data []byte) (err error) {
return f.UnmarshalText(data)
} | go | func (f *Framing) UnmarshalTOML(data []byte) (err error) {
return f.UnmarshalText(data)
} | [
"func",
"(",
"f",
"*",
"Framing",
")",
"UnmarshalTOML",
"(",
"data",
"[",
"]",
"byte",
")",
"(",
"err",
"error",
")",
"{",
"return",
"f",
".",
"UnmarshalText",
"(",
"data",
")",
"\n",
"}"
] | // UnmarshalTOML implements ability to unmarshal framing from TOML files. | [
"UnmarshalTOML",
"implements",
"ability",
"to",
"unmarshal",
"framing",
"from",
"TOML",
"files",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/syslog/framing.go#L29-L31 |
128,265 | influxdata/telegraf | plugins/inputs/phpfpm/fcgi.go | writeRecord | func (c *conn) writeRecord(recType recType, reqId uint16, b []byte) error {
c.mutex.Lock()
defer c.mutex.Unlock()
c.buf.Reset()
c.h.init(recType, reqId, len(b))
if err := binary.Write(&c.buf, binary.BigEndian, c.h); err != nil {
return err
}
if _, err := c.buf.Write(b); err != nil {
return err
}
if _, err ... | go | func (c *conn) writeRecord(recType recType, reqId uint16, b []byte) error {
c.mutex.Lock()
defer c.mutex.Unlock()
c.buf.Reset()
c.h.init(recType, reqId, len(b))
if err := binary.Write(&c.buf, binary.BigEndian, c.h); err != nil {
return err
}
if _, err := c.buf.Write(b); err != nil {
return err
}
if _, err ... | [
"func",
"(",
"c",
"*",
"conn",
")",
"writeRecord",
"(",
"recType",
"recType",
",",
"reqId",
"uint16",
",",
"b",
"[",
"]",
"byte",
")",
"error",
"{",
"c",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"mutex",
".",
"Unlock",
"(",
... | // writeRecord writes and sends a single record. | [
"writeRecord",
"writes",
"and",
"sends",
"a",
"single",
"record",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/phpfpm/fcgi.go#L143-L159 |
128,266 | influxdata/telegraf | plugins/inputs/nginx_upstream_check/nginx_upstream_check.go | createHttpClient | func (check *NginxUpstreamCheck) createHttpClient() (*http.Client, error) {
tlsConfig, err := check.ClientConfig.TLSConfig()
if err != nil {
return nil, err
}
client := &http.Client{
Transport: &http.Transport{
TLSClientConfig: tlsConfig,
},
Timeout: check.Timeout.Duration,
}
return client, nil
} | go | func (check *NginxUpstreamCheck) createHttpClient() (*http.Client, error) {
tlsConfig, err := check.ClientConfig.TLSConfig()
if err != nil {
return nil, err
}
client := &http.Client{
Transport: &http.Transport{
TLSClientConfig: tlsConfig,
},
Timeout: check.Timeout.Duration,
}
return client, nil
} | [
"func",
"(",
"check",
"*",
"NginxUpstreamCheck",
")",
"createHttpClient",
"(",
")",
"(",
"*",
"http",
".",
"Client",
",",
"error",
")",
"{",
"tlsConfig",
",",
"err",
":=",
"check",
".",
"ClientConfig",
".",
"TLSConfig",
"(",
")",
"\n",
"if",
"err",
"!=... | // createHttpClient create a clients to access API | [
"createHttpClient",
"create",
"a",
"clients",
"to",
"access",
"API"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/nginx_upstream_check/nginx_upstream_check.go#L104-L118 |
128,267 | influxdata/telegraf | plugins/inputs/nginx_upstream_check/nginx_upstream_check.go | gatherJsonData | func (check *NginxUpstreamCheck) gatherJsonData(url string, value interface{}) error {
var method string
if check.Method != "" {
method = check.Method
} else {
method = "GET"
}
request, err := http.NewRequest(method, url, nil)
if err != nil {
return err
}
if (check.Username != "") || (check.Password !=... | go | func (check *NginxUpstreamCheck) gatherJsonData(url string, value interface{}) error {
var method string
if check.Method != "" {
method = check.Method
} else {
method = "GET"
}
request, err := http.NewRequest(method, url, nil)
if err != nil {
return err
}
if (check.Username != "") || (check.Password !=... | [
"func",
"(",
"check",
"*",
"NginxUpstreamCheck",
")",
"gatherJsonData",
"(",
"url",
"string",
",",
"value",
"interface",
"{",
"}",
")",
"error",
"{",
"var",
"method",
"string",
"\n",
"if",
"check",
".",
"Method",
"!=",
"\"",
"\"",
"{",
"method",
"=",
"... | // gatherJsonData query the data source and parse the response JSON | [
"gatherJsonData",
"query",
"the",
"data",
"source",
"and",
"parse",
"the",
"response",
"JSON"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/nginx_upstream_check/nginx_upstream_check.go#L121-L158 |
128,268 | influxdata/telegraf | plugins/inputs/zipkin/convert.go | Record | func (l *LineProtocolConverter) Record(t trace.Trace) error {
for _, s := range t {
fields := map[string]interface{}{
"duration_ns": s.Duration.Nanoseconds(),
}
tags := map[string]string{
"id": s.ID,
"parent_id": s.ParentID,
"trace_id": s.TraceID,
"name": formatName(s.Nam... | go | func (l *LineProtocolConverter) Record(t trace.Trace) error {
for _, s := range t {
fields := map[string]interface{}{
"duration_ns": s.Duration.Nanoseconds(),
}
tags := map[string]string{
"id": s.ID,
"parent_id": s.ParentID,
"trace_id": s.TraceID,
"name": formatName(s.Nam... | [
"func",
"(",
"l",
"*",
"LineProtocolConverter",
")",
"Record",
"(",
"t",
"trace",
".",
"Trace",
")",
"error",
"{",
"for",
"_",
",",
"s",
":=",
"range",
"t",
"{",
"fields",
":=",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"\"",
"\"",
"... | // Record is LineProtocolConverter's implementation of the Record method of
// the Recorder interface; it takes a trace as input, and adds it to an internal
// telegraf.Accumulator. | [
"Record",
"is",
"LineProtocolConverter",
"s",
"implementation",
"of",
"the",
"Record",
"method",
"of",
"the",
"Recorder",
"interface",
";",
"it",
"takes",
"a",
"trace",
"as",
"input",
"and",
"adds",
"it",
"to",
"an",
"internal",
"telegraf",
".",
"Accumulator",... | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/zipkin/convert.go#L28-L72 |
128,269 | influxdata/telegraf | internal/models/buffer.go | NewBuffer | func NewBuffer(name string, capacity int) *Buffer {
b := &Buffer{
buf: make([]telegraf.Metric, capacity),
first: 0,
last: 0,
size: 0,
cap: capacity,
MetricsAdded: selfstat.Register(
"write",
"metrics_added",
map[string]string{"output": name},
),
MetricsWritten: selfstat.Register(
"wr... | go | func NewBuffer(name string, capacity int) *Buffer {
b := &Buffer{
buf: make([]telegraf.Metric, capacity),
first: 0,
last: 0,
size: 0,
cap: capacity,
MetricsAdded: selfstat.Register(
"write",
"metrics_added",
map[string]string{"output": name},
),
MetricsWritten: selfstat.Register(
"wr... | [
"func",
"NewBuffer",
"(",
"name",
"string",
",",
"capacity",
"int",
")",
"*",
"Buffer",
"{",
"b",
":=",
"&",
"Buffer",
"{",
"buf",
":",
"make",
"(",
"[",
"]",
"telegraf",
".",
"Metric",
",",
"capacity",
")",
",",
"first",
":",
"0",
",",
"last",
"... | // NewBuffer returns a new empty Buffer with the given capacity. | [
"NewBuffer",
"returns",
"a",
"new",
"empty",
"Buffer",
"with",
"the",
"given",
"capacity",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/internal/models/buffer.go#L35-L72 |
128,270 | influxdata/telegraf | internal/models/buffer.go | Len | func (b *Buffer) Len() int {
b.Lock()
defer b.Unlock()
return b.length()
} | go | func (b *Buffer) Len() int {
b.Lock()
defer b.Unlock()
return b.length()
} | [
"func",
"(",
"b",
"*",
"Buffer",
")",
"Len",
"(",
")",
"int",
"{",
"b",
".",
"Lock",
"(",
")",
"\n",
"defer",
"b",
".",
"Unlock",
"(",
")",
"\n\n",
"return",
"b",
".",
"length",
"(",
")",
"\n",
"}"
] | // Len returns the number of metrics currently in the buffer. | [
"Len",
"returns",
"the",
"number",
"of",
"metrics",
"currently",
"in",
"the",
"buffer",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/internal/models/buffer.go#L75-L80 |
128,271 | influxdata/telegraf | internal/models/buffer.go | Add | func (b *Buffer) Add(metrics ...telegraf.Metric) {
b.Lock()
defer b.Unlock()
for i := range metrics {
b.add(metrics[i])
}
b.BufferSize.Set(int64(b.length()))
} | go | func (b *Buffer) Add(metrics ...telegraf.Metric) {
b.Lock()
defer b.Unlock()
for i := range metrics {
b.add(metrics[i])
}
b.BufferSize.Set(int64(b.length()))
} | [
"func",
"(",
"b",
"*",
"Buffer",
")",
"Add",
"(",
"metrics",
"...",
"telegraf",
".",
"Metric",
")",
"{",
"b",
".",
"Lock",
"(",
")",
"\n",
"defer",
"b",
".",
"Unlock",
"(",
")",
"\n\n",
"for",
"i",
":=",
"range",
"metrics",
"{",
"b",
".",
"add"... | // Add adds metrics to the buffer | [
"Add",
"adds",
"metrics",
"to",
"the",
"buffer"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/internal/models/buffer.go#L126-L135 |
128,272 | influxdata/telegraf | internal/models/buffer.go | Batch | func (b *Buffer) Batch(batchSize int) []telegraf.Metric {
b.Lock()
defer b.Unlock()
outLen := min(b.size, batchSize)
out := make([]telegraf.Metric, outLen)
if outLen == 0 {
return out
}
b.batchFirst = b.cap + b.last - outLen
b.batchFirst %= b.cap
b.batchSize = outLen
batchIndex := b.batchFirst
for i := ... | go | func (b *Buffer) Batch(batchSize int) []telegraf.Metric {
b.Lock()
defer b.Unlock()
outLen := min(b.size, batchSize)
out := make([]telegraf.Metric, outLen)
if outLen == 0 {
return out
}
b.batchFirst = b.cap + b.last - outLen
b.batchFirst %= b.cap
b.batchSize = outLen
batchIndex := b.batchFirst
for i := ... | [
"func",
"(",
"b",
"*",
"Buffer",
")",
"Batch",
"(",
"batchSize",
"int",
")",
"[",
"]",
"telegraf",
".",
"Metric",
"{",
"b",
".",
"Lock",
"(",
")",
"\n",
"defer",
"b",
".",
"Unlock",
"(",
")",
"\n\n",
"outLen",
":=",
"min",
"(",
"b",
".",
"size"... | // Batch returns a slice containing up to batchSize of the most recently added
// metrics. Metrics are ordered from newest to oldest in the batch. The
// batch must not be modified by the client. | [
"Batch",
"returns",
"a",
"slice",
"containing",
"up",
"to",
"batchSize",
"of",
"the",
"most",
"recently",
"added",
"metrics",
".",
"Metrics",
"are",
"ordered",
"from",
"newest",
"to",
"oldest",
"in",
"the",
"batch",
".",
"The",
"batch",
"must",
"not",
"be"... | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/internal/models/buffer.go#L140-L164 |
128,273 | influxdata/telegraf | internal/models/buffer.go | dist | func (b *Buffer) dist(begin, end int) int {
if begin <= end {
return end - begin
} else {
return b.cap - begin + end
}
} | go | func (b *Buffer) dist(begin, end int) int {
if begin <= end {
return end - begin
} else {
return b.cap - begin + end
}
} | [
"func",
"(",
"b",
"*",
"Buffer",
")",
"dist",
"(",
"begin",
",",
"end",
"int",
")",
"int",
"{",
"if",
"begin",
"<=",
"end",
"{",
"return",
"end",
"-",
"begin",
"\n",
"}",
"else",
"{",
"return",
"b",
".",
"cap",
"-",
"begin",
"+",
"end",
"\n",
... | // dist returns the distance between two indexes. Because this data structure
// uses a half open range the arguments must both either left side or right
// side pairs. | [
"dist",
"returns",
"the",
"distance",
"between",
"two",
"indexes",
".",
"Because",
"this",
"data",
"structure",
"uses",
"a",
"half",
"open",
"range",
"the",
"arguments",
"must",
"both",
"either",
"left",
"side",
"or",
"right",
"side",
"pairs",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/internal/models/buffer.go#L231-L237 |
128,274 | influxdata/telegraf | internal/models/buffer.go | next | func (b *Buffer) next(index int) int {
index++
if index == b.cap {
return 0
}
return index
} | go | func (b *Buffer) next(index int) int {
index++
if index == b.cap {
return 0
}
return index
} | [
"func",
"(",
"b",
"*",
"Buffer",
")",
"next",
"(",
"index",
"int",
")",
"int",
"{",
"index",
"++",
"\n",
"if",
"index",
"==",
"b",
".",
"cap",
"{",
"return",
"0",
"\n",
"}",
"\n",
"return",
"index",
"\n",
"}"
] | // next returns the next index with wrapping. | [
"next",
"returns",
"the",
"next",
"index",
"with",
"wrapping",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/internal/models/buffer.go#L240-L246 |
128,275 | influxdata/telegraf | internal/models/buffer.go | nextby | func (b *Buffer) nextby(index, count int) int {
index += count
index %= b.cap
return index
} | go | func (b *Buffer) nextby(index, count int) int {
index += count
index %= b.cap
return index
} | [
"func",
"(",
"b",
"*",
"Buffer",
")",
"nextby",
"(",
"index",
",",
"count",
"int",
")",
"int",
"{",
"index",
"+=",
"count",
"\n",
"index",
"%=",
"b",
".",
"cap",
"\n",
"return",
"index",
"\n",
"}"
] | // next returns the index that is count newer with wrapping. | [
"next",
"returns",
"the",
"index",
"that",
"is",
"count",
"newer",
"with",
"wrapping",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/internal/models/buffer.go#L249-L253 |
128,276 | influxdata/telegraf | internal/models/buffer.go | prev | func (b *Buffer) prev(index int) int {
index--
if index < 0 {
return b.cap - 1
}
return index
} | go | func (b *Buffer) prev(index int) int {
index--
if index < 0 {
return b.cap - 1
}
return index
} | [
"func",
"(",
"b",
"*",
"Buffer",
")",
"prev",
"(",
"index",
"int",
")",
"int",
"{",
"index",
"--",
"\n",
"if",
"index",
"<",
"0",
"{",
"return",
"b",
".",
"cap",
"-",
"1",
"\n",
"}",
"\n",
"return",
"index",
"\n",
"}"
] | // next returns the prev index with wrapping. | [
"next",
"returns",
"the",
"prev",
"index",
"with",
"wrapping",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/internal/models/buffer.go#L256-L262 |
128,277 | influxdata/telegraf | plugins/inputs/zipkin/zipkin.go | Start | func (z *Zipkin) Start(acc telegraf.Accumulator) error {
z.handler = NewSpanHandler(z.Path)
var wg sync.WaitGroup
z.waitGroup = &wg
router := mux.NewRouter()
converter := NewLineProtocolConverter(acc)
if err := z.handler.Register(router, converter); err != nil {
return err
}
z.server = &http.Server{
Hand... | go | func (z *Zipkin) Start(acc telegraf.Accumulator) error {
z.handler = NewSpanHandler(z.Path)
var wg sync.WaitGroup
z.waitGroup = &wg
router := mux.NewRouter()
converter := NewLineProtocolConverter(acc)
if err := z.handler.Register(router, converter); err != nil {
return err
}
z.server = &http.Server{
Hand... | [
"func",
"(",
"z",
"*",
"Zipkin",
")",
"Start",
"(",
"acc",
"telegraf",
".",
"Accumulator",
")",
"error",
"{",
"z",
".",
"handler",
"=",
"NewSpanHandler",
"(",
"z",
".",
"Path",
")",
"\n\n",
"var",
"wg",
"sync",
".",
"WaitGroup",
"\n",
"z",
".",
"wa... | // Start launches a separate goroutine for collecting zipkin client http requests,
// passing in a telegraf.Accumulator such that data can be collected. | [
"Start",
"launches",
"a",
"separate",
"goroutine",
"for",
"collecting",
"zipkin",
"client",
"http",
"requests",
"passing",
"in",
"a",
"telegraf",
".",
"Accumulator",
"such",
"that",
"data",
"can",
"be",
"collected",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/zipkin/zipkin.go#L85-L118 |
128,278 | influxdata/telegraf | plugins/inputs/zipkin/zipkin.go | Stop | func (z *Zipkin) Stop() {
ctx, cancel := context.WithTimeout(context.Background(), DefaultShutdownTimeout)
defer z.waitGroup.Wait()
defer cancel()
z.server.Shutdown(ctx)
} | go | func (z *Zipkin) Stop() {
ctx, cancel := context.WithTimeout(context.Background(), DefaultShutdownTimeout)
defer z.waitGroup.Wait()
defer cancel()
z.server.Shutdown(ctx)
} | [
"func",
"(",
"z",
"*",
"Zipkin",
")",
"Stop",
"(",
")",
"{",
"ctx",
",",
"cancel",
":=",
"context",
".",
"WithTimeout",
"(",
"context",
".",
"Background",
"(",
")",
",",
"DefaultShutdownTimeout",
")",
"\n\n",
"defer",
"z",
".",
"waitGroup",
".",
"Wait"... | // Stop shuts the internal http server down with via context.Context | [
"Stop",
"shuts",
"the",
"internal",
"http",
"server",
"down",
"with",
"via",
"context",
".",
"Context"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/zipkin/zipkin.go#L121-L128 |
128,279 | influxdata/telegraf | plugins/inputs/jolokia2/point_builder.go | extractFields | func (pb *pointBuilder) extractFields(mbean string, value interface{}) map[string]interface{} {
fieldMap := make(map[string]interface{})
valueMap, ok := value.(map[string]interface{})
if ok {
// complex value
if len(pb.objectAttributes) == 0 {
// if there were no attributes requested,
// then the keys are... | go | func (pb *pointBuilder) extractFields(mbean string, value interface{}) map[string]interface{} {
fieldMap := make(map[string]interface{})
valueMap, ok := value.(map[string]interface{})
if ok {
// complex value
if len(pb.objectAttributes) == 0 {
// if there were no attributes requested,
// then the keys are... | [
"func",
"(",
"pb",
"*",
"pointBuilder",
")",
"extractFields",
"(",
"mbean",
"string",
",",
"value",
"interface",
"{",
"}",
")",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"fieldMap",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"interface"... | // extractFields generates the map of fields for a given mbean name
// and value object. | [
"extractFields",
"generates",
"the",
"map",
"of",
"fields",
"for",
"a",
"given",
"mbean",
"name",
"and",
"value",
"object",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/jolokia2/point_builder.go#L92-L134 |
128,280 | influxdata/telegraf | plugins/inputs/jolokia2/point_builder.go | formatFieldName | func (pb *pointBuilder) formatFieldName(attribute, path string) string {
fieldName := attribute
fieldPrefix := pb.metric.FieldPrefix
fieldSeparator := pb.metric.FieldSeparator
if fieldPrefix != "" {
fieldName = fieldPrefix + fieldName
}
if path != "" {
fieldName = fieldName + fieldSeparator + strings.Replac... | go | func (pb *pointBuilder) formatFieldName(attribute, path string) string {
fieldName := attribute
fieldPrefix := pb.metric.FieldPrefix
fieldSeparator := pb.metric.FieldSeparator
if fieldPrefix != "" {
fieldName = fieldPrefix + fieldName
}
if path != "" {
fieldName = fieldName + fieldSeparator + strings.Replac... | [
"func",
"(",
"pb",
"*",
"pointBuilder",
")",
"formatFieldName",
"(",
"attribute",
",",
"path",
"string",
")",
"string",
"{",
"fieldName",
":=",
"attribute",
"\n",
"fieldPrefix",
":=",
"pb",
".",
"metric",
".",
"FieldPrefix",
"\n",
"fieldSeparator",
":=",
"pb... | // formatFieldName generates a field name from the supplied attribute and
// path. The return value has the configured FieldPrefix and FieldSuffix
// instructions applied. | [
"formatFieldName",
"generates",
"a",
"field",
"name",
"from",
"the",
"supplied",
"attribute",
"and",
"path",
".",
"The",
"return",
"value",
"has",
"the",
"configured",
"FieldPrefix",
"and",
"FieldSuffix",
"instructions",
"applied",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/jolokia2/point_builder.go#L139-L153 |
128,281 | influxdata/telegraf | plugins/inputs/jolokia2/point_builder.go | fillFields | func (pb *pointBuilder) fillFields(name string, value interface{}, fieldMap map[string]interface{}) {
if valueMap, ok := value.(map[string]interface{}); ok {
// keep going until we get to something that is not a map
for key, innerValue := range valueMap {
if _, ok := innerValue.([]interface{}); ok {
continu... | go | func (pb *pointBuilder) fillFields(name string, value interface{}, fieldMap map[string]interface{}) {
if valueMap, ok := value.(map[string]interface{}); ok {
// keep going until we get to something that is not a map
for key, innerValue := range valueMap {
if _, ok := innerValue.([]interface{}); ok {
continu... | [
"func",
"(",
"pb",
"*",
"pointBuilder",
")",
"fillFields",
"(",
"name",
"string",
",",
"value",
"interface",
"{",
"}",
",",
"fieldMap",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"{",
"if",
"valueMap",
",",
"ok",
":=",
"value",
".",
"(",
... | // fillFields recurses into the supplied value object, generating a named field
// for every value it discovers. | [
"fillFields",
"recurses",
"into",
"the",
"supplied",
"value",
"object",
"generating",
"a",
"named",
"field",
"for",
"every",
"value",
"it",
"discovers",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/jolokia2/point_builder.go#L157-L194 |
128,282 | influxdata/telegraf | plugins/inputs/salesforce/salesforce.go | NewSalesforce | func NewSalesforce() *Salesforce {
tr := &http.Transport{
ResponseHeaderTimeout: time.Duration(5 * time.Second),
}
client := &http.Client{
Transport: tr,
Timeout: time.Duration(10 * time.Second),
}
return &Salesforce{
client: client,
Version: defaultVersion,
Environment: defaultEnvironment}
... | go | func NewSalesforce() *Salesforce {
tr := &http.Transport{
ResponseHeaderTimeout: time.Duration(5 * time.Second),
}
client := &http.Client{
Transport: tr,
Timeout: time.Duration(10 * time.Second),
}
return &Salesforce{
client: client,
Version: defaultVersion,
Environment: defaultEnvironment}
... | [
"func",
"NewSalesforce",
"(",
")",
"*",
"Salesforce",
"{",
"tr",
":=",
"&",
"http",
".",
"Transport",
"{",
"ResponseHeaderTimeout",
":",
"time",
".",
"Duration",
"(",
"5",
"*",
"time",
".",
"Second",
")",
",",
"}",
"\n",
"client",
":=",
"&",
"http",
... | // returns a new Salesforce plugin instance | [
"returns",
"a",
"new",
"Salesforce",
"plugin",
"instance"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/salesforce/salesforce.go#L62-L74 |
128,283 | influxdata/telegraf | plugins/inputs/salesforce/salesforce.go | Gather | func (s *Salesforce) Gather(acc telegraf.Accumulator) error {
limits, err := s.fetchLimits()
if err != nil {
return err
}
tags := map[string]string{
"organization_id": s.OrganizationID,
"host": s.ServerURL.Host,
}
fields := make(map[string]interface{})
for k, v := range limits {
key := inter... | go | func (s *Salesforce) Gather(acc telegraf.Accumulator) error {
limits, err := s.fetchLimits()
if err != nil {
return err
}
tags := map[string]string{
"organization_id": s.OrganizationID,
"host": s.ServerURL.Host,
}
fields := make(map[string]interface{})
for k, v := range limits {
key := inter... | [
"func",
"(",
"s",
"*",
"Salesforce",
")",
"Gather",
"(",
"acc",
"telegraf",
".",
"Accumulator",
")",
"error",
"{",
"limits",
",",
"err",
":=",
"s",
".",
"fetchLimits",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n... | // Reads limits values from Salesforce API | [
"Reads",
"limits",
"values",
"from",
"Salesforce",
"API"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/salesforce/salesforce.go#L85-L105 |
128,284 | influxdata/telegraf | plugins/inputs/salesforce/salesforce.go | queryLimits | func (s *Salesforce) queryLimits() (*http.Response, error) {
endpoint := fmt.Sprintf("%s://%s/services/data/v%s/limits", s.ServerURL.Scheme, s.ServerURL.Host, s.Version)
req, err := http.NewRequest(http.MethodGet, endpoint, nil)
if err != nil {
return nil, err
}
req.Header.Add("Accept", "encoding/json")
req.Hea... | go | func (s *Salesforce) queryLimits() (*http.Response, error) {
endpoint := fmt.Sprintf("%s://%s/services/data/v%s/limits", s.ServerURL.Scheme, s.ServerURL.Host, s.Version)
req, err := http.NewRequest(http.MethodGet, endpoint, nil)
if err != nil {
return nil, err
}
req.Header.Add("Accept", "encoding/json")
req.Hea... | [
"func",
"(",
"s",
"*",
"Salesforce",
")",
"queryLimits",
"(",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"endpoint",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"s",
".",
"ServerURL",
".",
"Scheme",
",",
"s",
".",
"Ser... | // query the limits endpoint | [
"query",
"the",
"limits",
"endpoint"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/salesforce/salesforce.go#L108-L117 |
128,285 | influxdata/telegraf | plugins/inputs/salesforce/salesforce.go | login | func (s *Salesforce) login() error {
if s.Username == "" || s.Password == "" {
return errors.New("missing username or password")
}
body := fmt.Sprintf(`<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:urn="urn:enterprise.soap.sforce.com... | go | func (s *Salesforce) login() error {
if s.Username == "" || s.Password == "" {
return errors.New("missing username or password")
}
body := fmt.Sprintf(`<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:urn="urn:enterprise.soap.sforce.com... | [
"func",
"(",
"s",
"*",
"Salesforce",
")",
"login",
"(",
")",
"error",
"{",
"if",
"s",
".",
"Username",
"==",
"\"",
"\"",
"||",
"s",
".",
"Password",
"==",
"\"",
"\"",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",... | // Authenticate with Salesfroce | [
"Authenticate",
"with",
"Salesfroce"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/salesforce/salesforce.go#L169-L239 |
128,286 | influxdata/telegraf | plugins/parsers/grok/parser.go | Compile | func (p *Parser) Compile() error {
p.typeMap = make(map[string]map[string]string)
p.tsMap = make(map[string]map[string]string)
p.patterns = make(map[string]string)
p.tsModder = &tsModder{}
var err error
p.g, err = grok.NewWithConfig(&grok.Config{NamedCapturesOnly: true})
if err != nil {
return err
}
if p.Un... | go | func (p *Parser) Compile() error {
p.typeMap = make(map[string]map[string]string)
p.tsMap = make(map[string]map[string]string)
p.patterns = make(map[string]string)
p.tsModder = &tsModder{}
var err error
p.g, err = grok.NewWithConfig(&grok.Config{NamedCapturesOnly: true})
if err != nil {
return err
}
if p.Un... | [
"func",
"(",
"p",
"*",
"Parser",
")",
"Compile",
"(",
")",
"error",
"{",
"p",
".",
"typeMap",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"map",
"[",
"string",
"]",
"string",
")",
"\n",
"p",
".",
"tsMap",
"=",
"make",
"(",
"map",
"[",
"string"... | // Compile is a bound method to Parser which will process the options for our parser | [
"Compile",
"is",
"a",
"bound",
"method",
"to",
"Parser",
"which",
"will",
"process",
"the",
"options",
"for",
"our",
"parser"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/parsers/grok/parser.go#L128-L190 |
128,287 | influxdata/telegraf | plugins/inputs/kube_inventory/kube_state.go | Gather | func (ki *KubernetesInventory) Gather(acc telegraf.Accumulator) (err error) {
if ki.client == nil {
if ki.client, err = ki.initClient(); err != nil {
return err
}
}
resourceFilter, err := filter.NewIncludeExcludeFilter(ki.ResourceInclude, ki.ResourceExclude)
if err != nil {
return err
}
wg := sync.Wait... | go | func (ki *KubernetesInventory) Gather(acc telegraf.Accumulator) (err error) {
if ki.client == nil {
if ki.client, err = ki.initClient(); err != nil {
return err
}
}
resourceFilter, err := filter.NewIncludeExcludeFilter(ki.ResourceInclude, ki.ResourceExclude)
if err != nil {
return err
}
wg := sync.Wait... | [
"func",
"(",
"ki",
"*",
"KubernetesInventory",
")",
"Gather",
"(",
"acc",
"telegraf",
".",
"Accumulator",
")",
"(",
"err",
"error",
")",
"{",
"if",
"ki",
".",
"client",
"==",
"nil",
"{",
"if",
"ki",
".",
"client",
",",
"err",
"=",
"ki",
".",
"initC... | // Gather collects kubernetes metrics from a given URL. | [
"Gather",
"collects",
"kubernetes",
"metrics",
"from",
"a",
"given",
"URL",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/kube_inventory/kube_state.go#L81-L109 |
128,288 | influxdata/telegraf | plugins/inputs/webhooks/webhooks.go | AvailableWebhooks | func (wb *Webhooks) AvailableWebhooks() []Webhook {
webhooks := make([]Webhook, 0)
s := reflect.ValueOf(wb).Elem()
for i := 0; i < s.NumField(); i++ {
f := s.Field(i)
if !f.CanInterface() {
continue
}
if wbPlugin, ok := f.Interface().(Webhook); ok {
if !reflect.ValueOf(wbPlugin).IsNil() {
webhook... | go | func (wb *Webhooks) AvailableWebhooks() []Webhook {
webhooks := make([]Webhook, 0)
s := reflect.ValueOf(wb).Elem()
for i := 0; i < s.NumField(); i++ {
f := s.Field(i)
if !f.CanInterface() {
continue
}
if wbPlugin, ok := f.Interface().(Webhook); ok {
if !reflect.ValueOf(wbPlugin).IsNil() {
webhook... | [
"func",
"(",
"wb",
"*",
"Webhooks",
")",
"AvailableWebhooks",
"(",
")",
"[",
"]",
"Webhook",
"{",
"webhooks",
":=",
"make",
"(",
"[",
"]",
"Webhook",
",",
"0",
")",
"\n",
"s",
":=",
"reflect",
".",
"ValueOf",
"(",
"wb",
")",
".",
"Elem",
"(",
")"... | // Looks for fields which implement Webhook interface | [
"Looks",
"for",
"fields",
"which",
"implement",
"Webhook",
"interface"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/webhooks/webhooks.go#L82-L100 |
128,289 | influxdata/telegraf | plugins/serializers/graphite/graphite.go | InsertField | func InsertField(bucket, fieldName string) string {
// if the field name is "value", then dont use it
if fieldName == "value" {
return fieldDeleter.Replace(bucket)
}
return strings.Replace(bucket, "FIELDNAME", fieldName, 1)
} | go | func InsertField(bucket, fieldName string) string {
// if the field name is "value", then dont use it
if fieldName == "value" {
return fieldDeleter.Replace(bucket)
}
return strings.Replace(bucket, "FIELDNAME", fieldName, 1)
} | [
"func",
"InsertField",
"(",
"bucket",
",",
"fieldName",
"string",
")",
"string",
"{",
"// if the field name is \"value\", then dont use it",
"if",
"fieldName",
"==",
"\"",
"\"",
"{",
"return",
"fieldDeleter",
".",
"Replace",
"(",
"bucket",
")",
"\n",
"}",
"\n",
... | // InsertField takes the bucket string from SerializeBucketName and replaces the
// FIELDNAME portion. If fieldName == "value", it will simply delete the
// FIELDNAME portion. | [
"InsertField",
"takes",
"the",
"bucket",
"string",
"from",
"SerializeBucketName",
"and",
"replaces",
"the",
"FIELDNAME",
"portion",
".",
"If",
"fieldName",
"==",
"value",
"it",
"will",
"simply",
"delete",
"the",
"FIELDNAME",
"portion",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/serializers/graphite/graphite.go#L229-L235 |
128,290 | influxdata/telegraf | plugins/outputs/graphite/graphite.go | Write | func (g *Graphite) Write(metrics []telegraf.Metric) error {
// Prepare data
var batch []byte
s, err := serializers.NewGraphiteSerializer(g.Prefix, g.Template, g.GraphiteTagSupport)
if err != nil {
return err
}
for _, metric := range metrics {
buf, err := s.Serialize(metric)
if err != nil {
log.Printf("E... | go | func (g *Graphite) Write(metrics []telegraf.Metric) error {
// Prepare data
var batch []byte
s, err := serializers.NewGraphiteSerializer(g.Prefix, g.Template, g.GraphiteTagSupport)
if err != nil {
return err
}
for _, metric := range metrics {
buf, err := s.Serialize(metric)
if err != nil {
log.Printf("E... | [
"func",
"(",
"g",
"*",
"Graphite",
")",
"Write",
"(",
"metrics",
"[",
"]",
"telegraf",
".",
"Metric",
")",
"error",
"{",
"// Prepare data",
"var",
"batch",
"[",
"]",
"byte",
"\n",
"s",
",",
"err",
":=",
"serializers",
".",
"NewGraphiteSerializer",
"(",
... | // Choose a random server in the cluster to write to until a successful write
// occurs, logging each unsuccessful. If all servers fail, return error. | [
"Choose",
"a",
"random",
"server",
"in",
"the",
"cluster",
"to",
"write",
"to",
"until",
"a",
"successful",
"write",
"occurs",
"logging",
"each",
"unsuccessful",
".",
"If",
"all",
"servers",
"fail",
"return",
"error",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/outputs/graphite/graphite.go#L134-L160 |
128,291 | influxdata/telegraf | plugins/outputs/influxdb/http.go | CreateDatabase | func (c *httpClient) CreateDatabase(ctx context.Context, database string) error {
query := fmt.Sprintf(`CREATE DATABASE "%s"`,
escapeIdentifier.Replace(database))
req, err := c.makeQueryRequest(query)
resp, err := c.client.Do(req.WithContext(ctx))
if err != nil {
return err
}
defer resp.Body.Close()
query... | go | func (c *httpClient) CreateDatabase(ctx context.Context, database string) error {
query := fmt.Sprintf(`CREATE DATABASE "%s"`,
escapeIdentifier.Replace(database))
req, err := c.makeQueryRequest(query)
resp, err := c.client.Do(req.WithContext(ctx))
if err != nil {
return err
}
defer resp.Body.Close()
query... | [
"func",
"(",
"c",
"*",
"httpClient",
")",
"CreateDatabase",
"(",
"ctx",
"context",
".",
"Context",
",",
"database",
"string",
")",
"error",
"{",
"query",
":=",
"fmt",
".",
"Sprintf",
"(",
"`CREATE DATABASE \"%s\"`",
",",
"escapeIdentifier",
".",
"Replace",
"... | // CreateDatabase attempts to create a new database in the InfluxDB server.
// Note that some names are not allowed by the server, notably those with
// non-printable characters or slashes. | [
"CreateDatabase",
"attempts",
"to",
"create",
"a",
"new",
"database",
"in",
"the",
"InfluxDB",
"server",
".",
"Note",
"that",
"some",
"names",
"are",
"not",
"allowed",
"by",
"the",
"server",
"notably",
"those",
"with",
"non",
"-",
"printable",
"characters",
... | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/outputs/influxdb/http.go#L193-L232 |
128,292 | influxdata/telegraf | plugins/outputs/influxdb/http.go | Write | func (c *httpClient) Write(ctx context.Context, metrics []telegraf.Metric) error {
batches := make(map[string][]telegraf.Metric)
if c.config.DatabaseTag == "" {
err := c.writeBatch(ctx, c.config.Database, metrics)
if err != nil {
return err
}
} else {
for _, metric := range metrics {
db, ok := metric.G... | go | func (c *httpClient) Write(ctx context.Context, metrics []telegraf.Metric) error {
batches := make(map[string][]telegraf.Metric)
if c.config.DatabaseTag == "" {
err := c.writeBatch(ctx, c.config.Database, metrics)
if err != nil {
return err
}
} else {
for _, metric := range metrics {
db, ok := metric.G... | [
"func",
"(",
"c",
"*",
"httpClient",
")",
"Write",
"(",
"ctx",
"context",
".",
"Context",
",",
"metrics",
"[",
"]",
"telegraf",
".",
"Metric",
")",
"error",
"{",
"batches",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"[",
"]",
"telegraf",
".",
"M... | // Write sends the metrics to InfluxDB | [
"Write",
"sends",
"the",
"metrics",
"to",
"InfluxDB"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/outputs/influxdb/http.go#L235-L272 |
128,293 | influxdata/telegraf | plugins/parsers/csv/parser.go | ParseLine | func (p *Parser) ParseLine(line string) (telegraf.Metric, error) {
r := bytes.NewReader([]byte(line))
csvReader, err := p.compile(r)
if err != nil {
return nil, err
}
// if there is nothing in DataColumns, ParseLine will fail
if len(p.ColumnNames) == 0 {
return nil, fmt.Errorf("[parsers.csv] data columns mus... | go | func (p *Parser) ParseLine(line string) (telegraf.Metric, error) {
r := bytes.NewReader([]byte(line))
csvReader, err := p.compile(r)
if err != nil {
return nil, err
}
// if there is nothing in DataColumns, ParseLine will fail
if len(p.ColumnNames) == 0 {
return nil, fmt.Errorf("[parsers.csv] data columns mus... | [
"func",
"(",
"p",
"*",
"Parser",
")",
"ParseLine",
"(",
"line",
"string",
")",
"(",
"telegraf",
".",
"Metric",
",",
"error",
")",
"{",
"r",
":=",
"bytes",
".",
"NewReader",
"(",
"[",
"]",
"byte",
"(",
"line",
")",
")",
"\n",
"csvReader",
",",
"er... | // ParseLine does not use any information in header and assumes DataColumns is set
// it will also not skip any rows | [
"ParseLine",
"does",
"not",
"use",
"any",
"information",
"in",
"header",
"and",
"assumes",
"DataColumns",
"is",
"set",
"it",
"will",
"also",
"not",
"skip",
"any",
"rows"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/parsers/csv/parser.go#L109-L130 |
128,294 | influxdata/telegraf | plugins/parsers/csv/parser.go | parseTimestamp | func parseTimestamp(timeFunc func() time.Time, recordFields map[string]interface{},
timestampColumn, timestampFormat string,
) (metricTime time.Time, err error) {
metricTime = timeFunc()
if timestampColumn != "" {
if recordFields[timestampColumn] == nil {
err = fmt.Errorf("timestamp column: %v could not be fou... | go | func parseTimestamp(timeFunc func() time.Time, recordFields map[string]interface{},
timestampColumn, timestampFormat string,
) (metricTime time.Time, err error) {
metricTime = timeFunc()
if timestampColumn != "" {
if recordFields[timestampColumn] == nil {
err = fmt.Errorf("timestamp column: %v could not be fou... | [
"func",
"parseTimestamp",
"(",
"timeFunc",
"func",
"(",
")",
"time",
".",
"Time",
",",
"recordFields",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"timestampColumn",
",",
"timestampFormat",
"string",
",",
")",
"(",
"metricTime",
"time",
".",
"Ti... | // ParseTimestamp return a timestamp, if there is no timestamp on the csv it
// will be the current timestamp, else it will try to parse the time according
// to the format. | [
"ParseTimestamp",
"return",
"a",
"timestamp",
"if",
"there",
"is",
"no",
"timestamp",
"on",
"the",
"csv",
"it",
"will",
"be",
"the",
"current",
"timestamp",
"else",
"it",
"will",
"try",
"to",
"parse",
"the",
"time",
"according",
"to",
"the",
"format",
"."
... | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/parsers/csv/parser.go#L226-L251 |
128,295 | influxdata/telegraf | metric/tracking.go | WithTracking | func WithTracking(metric telegraf.Metric, fn NotifyFunc) (telegraf.Metric, telegraf.TrackingID) {
return newTrackingMetric(metric, fn)
} | go | func WithTracking(metric telegraf.Metric, fn NotifyFunc) (telegraf.Metric, telegraf.TrackingID) {
return newTrackingMetric(metric, fn)
} | [
"func",
"WithTracking",
"(",
"metric",
"telegraf",
".",
"Metric",
",",
"fn",
"NotifyFunc",
")",
"(",
"telegraf",
".",
"Metric",
",",
"telegraf",
".",
"TrackingID",
")",
"{",
"return",
"newTrackingMetric",
"(",
"metric",
",",
"fn",
")",
"\n",
"}"
] | // WithTracking adds tracking to the metric and registers the notify function
// to be called when processing is complete. | [
"WithTracking",
"adds",
"tracking",
"to",
"the",
"metric",
"and",
"registers",
"the",
"notify",
"function",
"to",
"be",
"called",
"when",
"processing",
"is",
"complete",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/metric/tracking.go#L17-L19 |
128,296 | influxdata/telegraf | metric/tracking.go | WithGroupTracking | func WithGroupTracking(metric []telegraf.Metric, fn NotifyFunc) ([]telegraf.Metric, telegraf.TrackingID) {
return newTrackingMetricGroup(metric, fn)
} | go | func WithGroupTracking(metric []telegraf.Metric, fn NotifyFunc) ([]telegraf.Metric, telegraf.TrackingID) {
return newTrackingMetricGroup(metric, fn)
} | [
"func",
"WithGroupTracking",
"(",
"metric",
"[",
"]",
"telegraf",
".",
"Metric",
",",
"fn",
"NotifyFunc",
")",
"(",
"[",
"]",
"telegraf",
".",
"Metric",
",",
"telegraf",
".",
"TrackingID",
")",
"{",
"return",
"newTrackingMetricGroup",
"(",
"metric",
",",
"... | // WithBatchTracking adds tracking to the metrics and registers the notify
// function to be called when processing is complete. | [
"WithBatchTracking",
"adds",
"tracking",
"to",
"the",
"metrics",
"and",
"registers",
"the",
"notify",
"function",
"to",
"be",
"called",
"when",
"processing",
"is",
"complete",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/metric/tracking.go#L23-L25 |
128,297 | influxdata/telegraf | plugins/aggregators/valuecounter/valuecounter.go | Add | func (vc *ValueCounter) Add(in telegraf.Metric) {
id := in.HashID()
// Check if the cache already has an entry for this metric, if not create it
if _, ok := vc.cache[id]; !ok {
a := aggregate{
name: in.Name(),
tags: in.Tags(),
fieldCount: make(map[string]int),
}
vc.cache[id] = a
}
// C... | go | func (vc *ValueCounter) Add(in telegraf.Metric) {
id := in.HashID()
// Check if the cache already has an entry for this metric, if not create it
if _, ok := vc.cache[id]; !ok {
a := aggregate{
name: in.Name(),
tags: in.Tags(),
fieldCount: make(map[string]int),
}
vc.cache[id] = a
}
// C... | [
"func",
"(",
"vc",
"*",
"ValueCounter",
")",
"Add",
"(",
"in",
"telegraf",
".",
"Metric",
")",
"{",
"id",
":=",
"in",
".",
"HashID",
"(",
")",
"\n\n",
"// Check if the cache already has an entry for this metric, if not create it",
"if",
"_",
",",
"ok",
":=",
"... | // Add is run on every metric which passes the plugin | [
"Add",
"is",
"run",
"on",
"every",
"metric",
"which",
"passes",
"the",
"plugin"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/aggregators/valuecounter/valuecounter.go#L52-L75 |
128,298 | influxdata/telegraf | plugins/aggregators/valuecounter/valuecounter.go | Push | func (vc *ValueCounter) Push(acc telegraf.Accumulator) {
for _, agg := range vc.cache {
fields := map[string]interface{}{}
for field, count := range agg.fieldCount {
fields[field] = count
}
acc.AddFields(agg.name, fields, agg.tags)
}
} | go | func (vc *ValueCounter) Push(acc telegraf.Accumulator) {
for _, agg := range vc.cache {
fields := map[string]interface{}{}
for field, count := range agg.fieldCount {
fields[field] = count
}
acc.AddFields(agg.name, fields, agg.tags)
}
} | [
"func",
"(",
"vc",
"*",
"ValueCounter",
")",
"Push",
"(",
"acc",
"telegraf",
".",
"Accumulator",
")",
"{",
"for",
"_",
",",
"agg",
":=",
"range",
"vc",
".",
"cache",
"{",
"fields",
":=",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"}",
... | // Push emits the counters | [
"Push",
"emits",
"the",
"counters"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/aggregators/valuecounter/valuecounter.go#L78-L88 |
128,299 | influxdata/telegraf | plugins/inputs/fluentd/fluentd.go | Gather | func (h *Fluentd) Gather(acc telegraf.Accumulator) error {
_, err := url.Parse(h.Endpoint)
if err != nil {
return fmt.Errorf("Invalid URL \"%s\"", h.Endpoint)
}
if h.client == nil {
tr := &http.Transport{
ResponseHeaderTimeout: time.Duration(3 * time.Second),
}
client := &http.Client{
Transport: t... | go | func (h *Fluentd) Gather(acc telegraf.Accumulator) error {
_, err := url.Parse(h.Endpoint)
if err != nil {
return fmt.Errorf("Invalid URL \"%s\"", h.Endpoint)
}
if h.client == nil {
tr := &http.Transport{
ResponseHeaderTimeout: time.Duration(3 * time.Second),
}
client := &http.Client{
Transport: t... | [
"func",
"(",
"h",
"*",
"Fluentd",
")",
"Gather",
"(",
"acc",
"telegraf",
".",
"Accumulator",
")",
"error",
"{",
"_",
",",
"err",
":=",
"url",
".",
"Parse",
"(",
"h",
".",
"Endpoint",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",... | // Gather - Main code responsible for gathering, processing and creating metrics | [
"Gather",
"-",
"Main",
"code",
"responsible",
"for",
"gathering",
"processing",
"and",
"creating",
"metrics"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/fluentd/fluentd.go#L83-L169 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.