chore: Fix linter findings for `revive:enforce-repeated-arg-type-style` in `plugins/inputs/[a-g]*` (#15849)
This commit is contained in:
parent
ffee74c188
commit
e6d82bd996
|
|
@ -198,7 +198,7 @@ func (a *Aerospike) getNodeInfo(n *as.Node, infoPolicy *as.InfoPolicy) (map[stri
|
||||||
return stats, nil
|
return stats, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Aerospike) parseNodeInfo(acc telegraf.Accumulator, stats map[string]string, hostPort string, nodeName string) {
|
func (a *Aerospike) parseNodeInfo(acc telegraf.Accumulator, stats map[string]string, hostPort, nodeName string) {
|
||||||
nTags := map[string]string{
|
nTags := map[string]string{
|
||||||
"aerospike_host": hostPort,
|
"aerospike_host": hostPort,
|
||||||
"node_name": nodeName,
|
"node_name": nodeName,
|
||||||
|
|
@ -239,7 +239,7 @@ func (a *Aerospike) getNamespaceInfo(namespace string, n *as.Node, infoPolicy *a
|
||||||
|
|
||||||
return stats, err
|
return stats, err
|
||||||
}
|
}
|
||||||
func (a *Aerospike) parseNamespaceInfo(acc telegraf.Accumulator, stats map[string]string, hostPort string, namespace string, nodeName string) {
|
func (a *Aerospike) parseNamespaceInfo(acc telegraf.Accumulator, stats map[string]string, hostPort, namespace, nodeName string) {
|
||||||
nTags := map[string]string{
|
nTags := map[string]string{
|
||||||
"aerospike_host": hostPort,
|
"aerospike_host": hostPort,
|
||||||
"node_name": nodeName,
|
"node_name": nodeName,
|
||||||
|
|
@ -304,7 +304,7 @@ func (a *Aerospike) getSetInfo(namespaceSet string, n *as.Node, infoPolicy *as.I
|
||||||
return stats, nil
|
return stats, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Aerospike) parseSetInfo(acc telegraf.Accumulator, stats map[string]string, hostPort string, namespaceSet string, nodeName string) {
|
func (a *Aerospike) parseSetInfo(acc telegraf.Accumulator, stats map[string]string, hostPort, namespaceSet, nodeName string) {
|
||||||
stat := strings.Split(
|
stat := strings.Split(
|
||||||
strings.TrimSuffix(
|
strings.TrimSuffix(
|
||||||
stats["sets/"+namespaceSet], ";"), ":")
|
stats["sets/"+namespaceSet], ";"), ":")
|
||||||
|
|
@ -326,7 +326,7 @@ func (a *Aerospike) parseSetInfo(acc telegraf.Accumulator, stats map[string]stri
|
||||||
acc.AddFields("aerospike_set", nFields, nTags, time.Now())
|
acc.AddFields("aerospike_set", nFields, nTags, time.Now())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Aerospike) getTTLHistogram(acc telegraf.Accumulator, hostPort string, namespace string, set string, n *as.Node, infoPolicy *as.InfoPolicy) error {
|
func (a *Aerospike) getTTLHistogram(acc telegraf.Accumulator, hostPort, namespace, set string, n *as.Node, infoPolicy *as.InfoPolicy) error {
|
||||||
stats, err := a.getHistogram(namespace, set, "ttl", n, infoPolicy)
|
stats, err := a.getHistogram(namespace, set, "ttl", n, infoPolicy)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
@ -338,14 +338,7 @@ func (a *Aerospike) getTTLHistogram(acc telegraf.Accumulator, hostPort string, n
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Aerospike) getObjectSizeLinearHistogram(
|
func (a *Aerospike) getObjectSizeLinearHistogram(acc telegraf.Accumulator, hostPort, namespace, set string, n *as.Node, infoPolicy *as.InfoPolicy) error {
|
||||||
acc telegraf.Accumulator,
|
|
||||||
hostPort string,
|
|
||||||
namespace string,
|
|
||||||
set string,
|
|
||||||
n *as.Node,
|
|
||||||
infoPolicy *as.InfoPolicy,
|
|
||||||
) error {
|
|
||||||
stats, err := a.getHistogram(namespace, set, "object-size-linear", n, infoPolicy)
|
stats, err := a.getHistogram(namespace, set, "object-size-linear", n, infoPolicy)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
@ -357,7 +350,7 @@ func (a *Aerospike) getObjectSizeLinearHistogram(
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Aerospike) getHistogram(namespace string, set string, histogramType string, n *as.Node, infoPolicy *as.InfoPolicy) (map[string]string, error) {
|
func (a *Aerospike) getHistogram(namespace, set, histogramType string, n *as.Node, infoPolicy *as.InfoPolicy) (map[string]string, error) {
|
||||||
var queryArg string
|
var queryArg string
|
||||||
if len(set) > 0 {
|
if len(set) > 0 {
|
||||||
queryArg = fmt.Sprintf("histogram:type=%s;namespace=%v;set=%v", histogramType, namespace, set)
|
queryArg = fmt.Sprintf("histogram:type=%s;namespace=%v;set=%v", histogramType, namespace, set)
|
||||||
|
|
@ -372,7 +365,7 @@ func (a *Aerospike) getHistogram(namespace string, set string, histogramType str
|
||||||
return stats, nil
|
return stats, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Aerospike) parseHistogram(acc telegraf.Accumulator, stats map[string]string, nTags map[string]string, histogramType string) {
|
func (a *Aerospike) parseHistogram(acc telegraf.Accumulator, stats, nTags map[string]string, histogramType string) {
|
||||||
nFields := make(map[string]interface{})
|
nFields := make(map[string]interface{})
|
||||||
|
|
||||||
for _, stat := range stats {
|
for _, stat := range stats {
|
||||||
|
|
@ -422,12 +415,12 @@ func (a *Aerospike) parseHistogram(acc telegraf.Accumulator, stats map[string]st
|
||||||
acc.AddFields(fmt.Sprintf("aerospike_histogram_%v", strings.ReplaceAll(histogramType, "-", "_")), nFields, nTags, time.Now())
|
acc.AddFields(fmt.Sprintf("aerospike_histogram_%v", strings.ReplaceAll(histogramType, "-", "_")), nFields, nTags, time.Now())
|
||||||
}
|
}
|
||||||
|
|
||||||
func splitNamespaceSet(namespaceSet string) (namespace string, set string) {
|
func splitNamespaceSet(namespaceSet string) (namespace, set string) {
|
||||||
split := strings.Split(namespaceSet, "/")
|
split := strings.Split(namespaceSet, "/")
|
||||||
return split[0], split[1]
|
return split[0], split[1]
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseAerospikeValue(key string, v string) interface{} {
|
func parseAerospikeValue(key, v string) interface{} {
|
||||||
if protectedHexFields[key] {
|
if protectedHexFields[key] {
|
||||||
return v
|
return v
|
||||||
} else if parsed, err := strconv.ParseInt(v, 10, 64); err == nil {
|
} else if parsed, err := strconv.ParseInt(v, 10, 64); err == nil {
|
||||||
|
|
@ -443,7 +436,7 @@ func parseAerospikeValue(key string, v string) interface{} {
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
|
||||||
func createTags(hostPort string, nodeName string, namespace string, set string) map[string]string {
|
func createTags(hostPort, nodeName, namespace, set string) map[string]string {
|
||||||
nTags := map[string]string{
|
nTags := map[string]string{
|
||||||
"aerospike_host": hostPort,
|
"aerospike_host": hostPort,
|
||||||
"node_name": nodeName,
|
"node_name": nodeName,
|
||||||
|
|
|
||||||
|
|
@ -473,7 +473,7 @@ func TestAerospikeParseValue(t *testing.T) {
|
||||||
require.Equal(t, `1992929191`, val, "must be left as a string")
|
require.Equal(t, `1992929191`, val, "must be left as a string")
|
||||||
}
|
}
|
||||||
|
|
||||||
func FindTagValue(acc *testutil.Accumulator, measurement string, key string, value string) bool {
|
func FindTagValue(acc *testutil.Accumulator, measurement, key, value string) bool {
|
||||||
for _, p := range acc.Metrics {
|
for _, p := range acc.Metrics {
|
||||||
if p.Measurement == measurement {
|
if p.Measurement == measurement {
|
||||||
v, ok := p.Tags[key]
|
v, ok := p.Tags[key]
|
||||||
|
|
|
||||||
|
|
@ -342,7 +342,7 @@ func (s *AliyunCMS) gatherMetric(acc telegraf.Accumulator, metricName string, me
|
||||||
}
|
}
|
||||||
|
|
||||||
// tag helper
|
// tag helper
|
||||||
func parseTag(tagSpec string, data interface{}) (tagKey string, tagValue string, err error) {
|
func parseTag(tagSpec string, data interface{}) (tagKey, tagValue string, err error) {
|
||||||
var (
|
var (
|
||||||
ok bool
|
ok bool
|
||||||
queryPath = tagSpec
|
queryPath = tagSpec
|
||||||
|
|
@ -474,7 +474,7 @@ L:
|
||||||
}
|
}
|
||||||
|
|
||||||
// Formatting helpers
|
// Formatting helpers
|
||||||
func formatField(metricName string, statistic string) string {
|
func formatField(metricName, statistic string) string {
|
||||||
if metricName == statistic {
|
if metricName == statistic {
|
||||||
statistic = "value"
|
statistic = "value"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -171,10 +171,7 @@ func (am *AzureMonitor) setReceiver() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (acm *azureClientsManager) createAzureClients(
|
func (acm *azureClientsManager) createAzureClients(
|
||||||
subscriptionID string,
|
subscriptionID, clientID, clientSecret, tenantID string,
|
||||||
clientID string,
|
|
||||||
clientSecret string,
|
|
||||||
tenantID string,
|
|
||||||
clientOptions azcore.ClientOptions,
|
clientOptions azcore.ClientOptions,
|
||||||
) (*receiver.AzureClients, error) {
|
) (*receiver.AzureClients, error) {
|
||||||
if clientSecret != "" {
|
if clientSecret != "" {
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ type mockAzureMetricDefinitionsClient struct{}
|
||||||
|
|
||||||
type mockAzureMetricsClient struct{}
|
type mockAzureMetricsClient struct{}
|
||||||
|
|
||||||
func (mam *mockAzureClientsManager) createAzureClients(_ string, _ string, _ string, _ string, _ azcore.ClientOptions) (*receiver.AzureClients, error) {
|
func (mam *mockAzureClientsManager) createAzureClients(_, _, _, _ string, _ azcore.ClientOptions) (*receiver.AzureClients, error) {
|
||||||
return &receiver.AzureClients{
|
return &receiver.AzureClients{
|
||||||
Ctx: context.Background(),
|
Ctx: context.Background(),
|
||||||
ResourcesClient: &mockAzureResourcesClient{},
|
ResourcesClient: &mockAzureResourcesClient{},
|
||||||
|
|
|
||||||
|
|
@ -345,7 +345,7 @@ func getOverviewTags(server string) map[string]string {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getTubeTags(server string, tube string) map[string]string {
|
func getTubeTags(server, tube string) map[string]string {
|
||||||
return map[string]string{
|
return map[string]string{
|
||||||
"name": tube,
|
"name": tube,
|
||||||
"server": server,
|
"server": server,
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ func (bond *Bond) Gather(acc telegraf.Accumulator) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bond *Bond) gatherBondInterface(bondName string, rawFile string, acc telegraf.Accumulator) error {
|
func (bond *Bond) gatherBondInterface(bondName, rawFile string, acc telegraf.Accumulator) error {
|
||||||
splitIndex := strings.Index(rawFile, "Slave Interface:")
|
splitIndex := strings.Index(rawFile, "Slave Interface:")
|
||||||
if splitIndex == -1 {
|
if splitIndex == -1 {
|
||||||
splitIndex = len(rawFile)
|
splitIndex = len(rawFile)
|
||||||
|
|
@ -98,7 +98,7 @@ func (bond *Bond) gatherBondInterface(bondName string, rawFile string, acc teleg
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bond *Bond) gatherBondPart(bondName string, rawFile string, acc telegraf.Accumulator) error {
|
func (bond *Bond) gatherBondPart(bondName, rawFile string, acc telegraf.Accumulator) error {
|
||||||
fields := make(map[string]interface{})
|
fields := make(map[string]interface{})
|
||||||
tags := map[string]string{
|
tags := map[string]string{
|
||||||
"bond": bondName,
|
"bond": bondName,
|
||||||
|
|
@ -210,7 +210,7 @@ func (bond *Bond) gatherSysDetails(bondName string, files sysFiles, acc telegraf
|
||||||
acc.AddFields("bond_sys", fields, tags)
|
acc.AddFields("bond_sys", fields, tags)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bond *Bond) gatherSlavePart(bondName string, rawFile string, acc telegraf.Accumulator) error {
|
func (bond *Bond) gatherSlavePart(bondName, rawFile string, acc telegraf.Accumulator) error {
|
||||||
var slaveCount int
|
var slaveCount int
|
||||||
tags := map[string]string{
|
tags := map[string]string{
|
||||||
"bond": bondName,
|
"bond": bondName,
|
||||||
|
|
|
||||||
|
|
@ -649,8 +649,13 @@ func (c *CiscoTelemetryMDT) getMeasurementName(encodingPath string) string {
|
||||||
return measurement
|
return measurement
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *CiscoTelemetryMDT) parseContentField(grouper *metric.SeriesGrouper, field *telemetry.TelemetryField, prefix string,
|
func (c *CiscoTelemetryMDT) parseContentField(
|
||||||
encodingPath string, tags map[string]string, timestamp time.Time) {
|
grouper *metric.SeriesGrouper,
|
||||||
|
field *telemetry.TelemetryField,
|
||||||
|
prefix, encodingPath string,
|
||||||
|
tags map[string]string,
|
||||||
|
timestamp time.Time,
|
||||||
|
) {
|
||||||
name := strings.ReplaceAll(field.Name, "-", "_")
|
name := strings.ReplaceAll(field.Name, "-", "_")
|
||||||
|
|
||||||
if (name == "modTs" || name == "createTs") && decodeValue(field) == "never" {
|
if (name == "modTs" || name == "createTs") && decodeValue(field) == "never" {
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ func getHTTPSClient() *http.Client {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func createURL(scheme string, path string) string {
|
func createURL(scheme, path string) string {
|
||||||
u := url.URL{
|
u := url.URL{
|
||||||
Scheme: scheme,
|
Scheme: scheme,
|
||||||
Host: "localhost:8080",
|
Host: "localhost:8080",
|
||||||
|
|
|
||||||
|
|
@ -180,7 +180,7 @@ func (cb *Couchbase) basicBucketStats(basicStats map[string]interface{}) map[str
|
||||||
return fields
|
return fields
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cb *Couchbase) gatherDetailedBucketStats(server, bucket string, nodeHostname string, fields map[string]interface{}) error {
|
func (cb *Couchbase) gatherDetailedBucketStats(server, bucket, nodeHostname string, fields map[string]interface{}) error {
|
||||||
extendedBucketStats := &BucketStats{}
|
extendedBucketStats := &BucketStats{}
|
||||||
err := cb.queryDetailedBucketStats(server, bucket, nodeHostname, extendedBucketStats)
|
err := cb.queryDetailedBucketStats(server, bucket, nodeHostname, extendedBucketStats)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -421,7 +421,7 @@ func (cb *Couchbase) addBucketFieldChecked(fields map[string]interface{}, fieldK
|
||||||
cb.addBucketField(fields, fieldKey, values[len(values)-1])
|
cb.addBucketField(fields, fieldKey, values[len(values)-1])
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cb *Couchbase) queryDetailedBucketStats(server, bucket string, nodeHostname string, bucketStats *BucketStats) error {
|
func (cb *Couchbase) queryDetailedBucketStats(server, bucket, nodeHostname string, bucketStats *BucketStats) error {
|
||||||
url := server + "/pools/default/buckets/" + bucket
|
url := server + "/pools/default/buckets/" + bucket
|
||||||
if nodeHostname != "" {
|
if nodeHostname != "" {
|
||||||
url += "/nodes/" + nodeHostname
|
url += "/nodes/" + nodeHostname
|
||||||
|
|
|
||||||
|
|
@ -124,8 +124,7 @@ func assertContainsTaggedFloat(
|
||||||
t *testing.T,
|
t *testing.T,
|
||||||
acc *testutil.Accumulator,
|
acc *testutil.Accumulator,
|
||||||
field string,
|
field string,
|
||||||
expectedValue float64,
|
expectedValue, delta float64,
|
||||||
delta float64,
|
|
||||||
) {
|
) {
|
||||||
var actualValue float64
|
var actualValue float64
|
||||||
measurement := "cpu" // always cpu
|
measurement := "cpu" // always cpu
|
||||||
|
|
|
||||||
|
|
@ -254,7 +254,7 @@ func (c *clusterClient) GetAppMetrics(ctx context.Context, node, container strin
|
||||||
return c.getMetrics(ctx, c.toURL(path))
|
return c.getMetrics(ctx, c.toURL(path))
|
||||||
}
|
}
|
||||||
|
|
||||||
func createGetRequest(address string, token string) (*http.Request, error) {
|
func createGetRequest(address, token string) (*http.Request, error) {
|
||||||
req, err := http.NewRequest("GET", address, nil)
|
req, err := http.NewRequest("GET", address, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
||||||
|
|
@ -336,7 +336,7 @@ func (monitor *DirectoryMonitor) sendMetrics(metrics []telegraf.Metric) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (monitor *DirectoryMonitor) moveFile(srcPath string, dstBaseDir string) {
|
func (monitor *DirectoryMonitor) moveFile(srcPath, dstBaseDir string) {
|
||||||
// Appends any subdirectories in the srcPath to the dstBaseDir and
|
// Appends any subdirectories in the srcPath to the dstBaseDir and
|
||||||
// creates those subdirectories.
|
// creates those subdirectories.
|
||||||
basePath := strings.Replace(srcPath, monitor.Directory, "", 1)
|
basePath := strings.Replace(srcPath, monitor.Directory, "", 1)
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,7 @@ func (d *DNSQuery) Gather(acc telegraf.Accumulator) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DNSQuery) query(domain string, server string) (map[string]interface{}, map[string]string, error) {
|
func (d *DNSQuery) query(domain, server string) (map[string]interface{}, map[string]string, error) {
|
||||||
tags := map[string]string{
|
tags := map[string]string{
|
||||||
"server": server,
|
"server": server,
|
||||||
"domain": domain,
|
"domain": domain,
|
||||||
|
|
|
||||||
|
|
@ -608,8 +608,7 @@ func (d *Docker) parseContainerStats(
|
||||||
stat *typeContainer.StatsResponse,
|
stat *typeContainer.StatsResponse,
|
||||||
acc telegraf.Accumulator,
|
acc telegraf.Accumulator,
|
||||||
tags map[string]string,
|
tags map[string]string,
|
||||||
id string,
|
id, daemonOSType string,
|
||||||
daemonOSType string,
|
|
||||||
) {
|
) {
|
||||||
tm := stat.Read
|
tm := stat.Read
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ func CalculateMemUsageUnixNoCache(mem container.MemoryStats) float64 {
|
||||||
return float64(mem.Usage)
|
return float64(mem.Usage)
|
||||||
}
|
}
|
||||||
|
|
||||||
func CalculateMemPercentUnixNoCache(limit float64, usedNoCache float64) float64 {
|
func CalculateMemPercentUnixNoCache(limit, usedNoCache float64) float64 {
|
||||||
// MemoryStats.Limit will never be 0 unless the container is not running and we haven't
|
// MemoryStats.Limit will never be 0 unless the container is not running and we haven't
|
||||||
// got any data from cgroup
|
// got any data from cgroup
|
||||||
if limit != 0 {
|
if limit != 0 {
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ func (d *Dovecot) Gather(acc telegraf.Accumulator) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Dovecot) gatherServer(addr string, acc telegraf.Accumulator, qtype string, filter string) error {
|
func (d *Dovecot) gatherServer(addr string, acc telegraf.Accumulator, qtype, filter string) error {
|
||||||
var proto string
|
var proto string
|
||||||
|
|
||||||
if strings.HasPrefix(addr, "/") {
|
if strings.HasPrefix(addr, "/") {
|
||||||
|
|
@ -124,7 +124,7 @@ func (d *Dovecot) gatherServer(addr string, acc telegraf.Accumulator, qtype stri
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func gatherStats(buf *bytes.Buffer, acc telegraf.Accumulator, host string, qtype string) {
|
func gatherStats(buf *bytes.Buffer, acc telegraf.Accumulator, host, qtype string) {
|
||||||
lines := strings.Split(buf.String(), "\n")
|
lines := strings.Split(buf.String(), "\n")
|
||||||
head := strings.Split(lines[0], "\t")
|
head := strings.Split(lines[0], "\t")
|
||||||
vals := lines[1:]
|
vals := lines[1:]
|
||||||
|
|
@ -160,7 +160,7 @@ func gatherStats(buf *bytes.Buffer, acc telegraf.Accumulator, host string, qtype
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func splitSec(tm string) (sec int64, msec int64) {
|
func splitSec(tm string) (sec, msec int64) {
|
||||||
var err error
|
var err error
|
||||||
ss := strings.Split(tm, ".")
|
ss := strings.Split(tm, ".")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ import (
|
||||||
"github.com/influxdata/telegraf/filter"
|
"github.com/influxdata/telegraf/filter"
|
||||||
)
|
)
|
||||||
|
|
||||||
func commandWithParams(command string, params string) string {
|
func commandWithParams(command, params string) string {
|
||||||
if params != "" {
|
if params != "" {
|
||||||
return command + "," + params
|
return command + "," + params
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -193,7 +193,7 @@ func copyTags(in map[string]string) map[string]string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns a new map with the merged content values of the two input maps
|
// returns a new map with the merged content values of the two input maps
|
||||||
func mergeTags(a map[string]string, b map[string]string) map[string]string {
|
func mergeTags(a, b map[string]string) map[string]string {
|
||||||
c := copyTags(a)
|
c := copyTags(a)
|
||||||
for k, v := range b {
|
for k, v := range b {
|
||||||
c[k] = v
|
c[k] = v
|
||||||
|
|
|
||||||
|
|
@ -124,7 +124,7 @@ func recurseResponse(acc telegraf.Accumulator, aggNameFunction map[string]string
|
||||||
return m, nil
|
return m, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getResponseAggregation(function string, aggName string, aggs elastic5.Aggregations) (agg interface{}) {
|
func getResponseAggregation(function, aggName string, aggs elastic5.Aggregations) (agg interface{}) {
|
||||||
switch function {
|
switch function {
|
||||||
case "avg":
|
case "avg":
|
||||||
agg, _ = aggs.Avg(aggName)
|
agg, _ = aggs.Avg(aggName)
|
||||||
|
|
|
||||||
|
|
@ -197,7 +197,7 @@ func (aggregation *esAggregation) buildAggregationQuery() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getFunctionAggregation(function string, aggfield string) (elastic5.Aggregation, error) {
|
func getFunctionAggregation(function, aggfield string) (elastic5.Aggregation, error) {
|
||||||
var agg elastic5.Aggregation
|
var agg elastic5.Aggregation
|
||||||
|
|
||||||
switch function {
|
switch function {
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ type runnerMock struct {
|
||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
|
||||||
func newRunnerMock(out []byte, errout []byte, err error) Runner {
|
func newRunnerMock(out, errout []byte, err error) Runner {
|
||||||
return &runnerMock{
|
return &runnerMock{
|
||||||
out: out,
|
out: out,
|
||||||
errout: errout,
|
errout: errout,
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ func TestShimStdinSignalingWorks(t *testing.T) {
|
||||||
<-exited
|
<-exited
|
||||||
}
|
}
|
||||||
|
|
||||||
func runInputPlugin(t *testing.T, interval time.Duration, stdin io.Reader, stdout, stderr io.Writer) (metricProcessed chan bool, exited chan bool) {
|
func runInputPlugin(t *testing.T, interval time.Duration, stdin io.Reader, stdout, stderr io.Writer) (metricProcessed, exited chan bool) {
|
||||||
metricProcessed = make(chan bool)
|
metricProcessed = make(chan bool)
|
||||||
exited = make(chan bool)
|
exited = make(chan bool)
|
||||||
inp := &testInput{
|
inp := &testInput{
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Parse(acc telegraf.Accumulator, sectionBytes []byte, roomBytes []byte, deviecsBytes []byte) error {
|
func Parse(acc telegraf.Accumulator, sectionBytes, roomBytes, deviecsBytes []byte) error {
|
||||||
var tmpSections []Sections
|
var tmpSections []Sections
|
||||||
if err := json.Unmarshal(sectionBytes, &tmpSections); err != nil {
|
if err := json.Unmarshal(sectionBytes, &tmpSections); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import (
|
||||||
"github.com/influxdata/telegraf/internal"
|
"github.com/influxdata/telegraf/internal"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Parse(acc telegraf.Accumulator, sectionBytes []byte, roomBytes []byte, deviecsBytes []byte) error {
|
func Parse(acc telegraf.Accumulator, sectionBytes, roomBytes, deviecsBytes []byte) error {
|
||||||
var tmpSections []Sections
|
var tmpSections []Sections
|
||||||
if err := json.Unmarshal(sectionBytes, &tmpSections); err != nil {
|
if err := json.Unmarshal(sectionBytes, &tmpSections); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
||||||
|
|
@ -239,7 +239,7 @@ func getFakeFileSystem(basePath string) fakeFileSystem {
|
||||||
return fakeFileSystem{files: fileList}
|
return fakeFileSystem{files: fileList}
|
||||||
}
|
}
|
||||||
|
|
||||||
func fileCountEquals(t *testing.T, fc FileCount, expectedCount int, expectedSize int) {
|
func fileCountEquals(t *testing.T, fc FileCount, expectedCount, expectedSize int) {
|
||||||
tags := map[string]string{"directory": getTestdataDir()}
|
tags := map[string]string{"directory": getTestdataDir()}
|
||||||
acc := testutil.Accumulator{}
|
acc := testutil.Accumulator{}
|
||||||
require.NoError(t, acc.GatherError(fc.Gather))
|
require.NoError(t, acc.GatherError(fc.Gather))
|
||||||
|
|
|
||||||
|
|
@ -158,7 +158,7 @@ func (g *GitHub) handleRateLimit(response *githubLib.Response, err error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func splitRepositoryName(repositoryName string) (owner string, repository string, err error) {
|
func splitRepositoryName(repositoryName string) (owner, repository string, err error) {
|
||||||
splits := strings.SplitN(repositoryName, "/", 2)
|
splits := strings.SplitN(repositoryName, "/", 2)
|
||||||
|
|
||||||
if len(splits) != 2 {
|
if len(splits) != 2 {
|
||||||
|
|
|
||||||
|
|
@ -377,7 +377,7 @@ func (c *GNMI) newSubscribeRequest() (*gnmiLib.SubscribeRequest, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ParsePath from XPath-like string to gNMI path structure
|
// ParsePath from XPath-like string to gNMI path structure
|
||||||
func parsePath(origin string, pathToParse string, target string) (*gnmiLib.Path, error) {
|
func parsePath(origin, pathToParse, target string) (*gnmiLib.Path, error) {
|
||||||
gnmiPath, err := xpath.ToGNMIPath(pathToParse)
|
gnmiPath, err := xpath.ToGNMIPath(pathToParse)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
||||||
|
|
@ -333,7 +333,7 @@ func stateFullGCSServer(t *testing.T) *httptest.Server {
|
||||||
return srv
|
return srv
|
||||||
}
|
}
|
||||||
|
|
||||||
func serveBlobs(t *testing.T, w http.ResponseWriter, urlPath string, offsetKey string) {
|
func serveBlobs(t *testing.T, w http.ResponseWriter, urlPath, offsetKey string) {
|
||||||
singleObjectNotFound := readJSON(t, "testdata/single_object_not_found.json")
|
singleObjectNotFound := readJSON(t, "testdata/single_object_not_found.json")
|
||||||
firstFile := readJSON(t, "testdata/first_file.json")
|
firstFile := readJSON(t, "testdata/first_file.json")
|
||||||
secondFile := readJSON(t, "testdata/second_file.json")
|
secondFile := readJSON(t, "testdata/second_file.json")
|
||||||
|
|
|
||||||
|
|
@ -173,7 +173,7 @@ func (h *GrayLog) gatherServer(
|
||||||
// Returns:
|
// Returns:
|
||||||
//
|
//
|
||||||
// void
|
// void
|
||||||
func (h *GrayLog) flatten(item map[string]interface{}, fields map[string]interface{}, id string) {
|
func (h *GrayLog) flatten(item, fields map[string]interface{}, id string) {
|
||||||
if id != "" {
|
if id != "" {
|
||||||
id = id + "_"
|
id = id + "_"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue