Skip to content

Commit

Permalink
adding to unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Paramadon committed Jun 7, 2024
1 parent 0ae3c59 commit f40a693
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
5 changes: 4 additions & 1 deletion translator/config/sampleSchema/validEthtoolConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
"pps_allowance_exceeded",
"conntrack_allowance_exceeded",
"linklocal_allowance_exceeded"
]
],
"append_dimensions": {
"name":"sampleName"
}
}
},
"append_dimensions": {
Expand Down
11 changes: 4 additions & 7 deletions translator/translate/metrics/metrics_collect/ethtool/ethtool.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package ethtool

import (
"github.com/aws/amazon-cloudwatch-agent/translator"
"github.com/aws/amazon-cloudwatch-agent/translator/translate/agent"
parent "github.com/aws/amazon-cloudwatch-agent/translator/translate/metrics/metrics_collect"
"github.com/aws/amazon-cloudwatch-agent/translator/translate/metrics/util"
)
Expand All @@ -17,18 +18,13 @@ var ChildRule = map[string]translator.Rule{}
// "metrics_include": [
// "bw_in_allowance_exceeded",
// "bw_out_allowance_exceeded"
// ]
// ],
// "append_dimensions":{
// key:value
// }
// }
const SectionKey_Ethtool = "ethtool"

func GetCurPath() string {
curPath := parent.GetCurPath() + SectionKey_Ethtool + "/"
return curPath
}

func RegisterRule(fieldname string, r translator.Rule) {
ChildRule[fieldname] = r
}
Expand All @@ -54,7 +50,8 @@ func (n *Ethtool) ApplyRule(input interface{}) (returnKey string, returnVal inte
returnKey = SectionKey_Ethtool
returnVal = resArr
//Process tags
util.ProcessAppendDimension(m[SectionKey_Ethtool].(map[string]interface{}), SectionKey_Ethtool, GetCurPath(), result)
isHighResolution := util.IsHighResolution(agent.Global_Config.Interval)
util.ProcessAppendDimensions(m, SectionKey_Ethtool, isHighResolution, result)
}
return
}
Expand Down
9 changes: 4 additions & 5 deletions translator/translate/metrics/util/commonconfigutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,13 @@ func ProcessLinuxCommonConfig(input interface{}, pluginName string, path string,
} else {
return false
}
ProcessAppendDimension(inputMap, pluginName, path, result)
return true
}
func ProcessAppendDimension(inputMap map[string]interface{}, pluginName string, path string, result map[string]interface{}) {
isHighResolution := IsHighResolution(agent.Global_Config.Interval)
// Set input plugin specific interval
ProcessAppendDimensions(inputMap, pluginName, isHighResolution, result)
return true
}
func ProcessAppendDimensions(inputMap map[string]interface{}, pluginName string, isHighResolution bool, result map[string]interface{}) {
isHighResolution = setTimeInterval(inputMap, result, isHighResolution, pluginName)

// Set append_dimensions as tags
if val, ok := inputMap[Append_Dimensions_Key]; ok {
result[Append_Dimensions_Mapped_Key] = util.FilterReservedKeys(val)
Expand Down

0 comments on commit f40a693

Please sign in to comment.