-
Notifications
You must be signed in to change notification settings - Fork 188
/
metrics.go
50 lines (39 loc) · 1.32 KB
/
metrics.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: MIT
package config
import (
"github.com/aws/amazon-cloudwatch-agent/tool/data/config/metric"
"github.com/aws/amazon-cloudwatch-agent/tool/runtime"
)
type Metrics struct {
AppendDimensions *metric.AppendDimensions
MetricsCollect *metric.Collection
}
func (config *Metrics) ToMap(ctx *runtime.Context) (string, map[string]interface{}) {
resultMap := make(map[string]interface{})
//Add the global dimensions if this is for ec2 host and customer want ec2 dimensions added.
if config.AppendDimensions == nil && ctx.WantEC2TagDimensions {
config.AppendDimensions = new(metric.AppendDimensions)
}
if config.AppendDimensions != nil {
mapKey, mapValue := config.AppendDimensions.ToMap(ctx)
if mapValue != nil {
resultMap[mapKey] = mapValue
}
}
if config.MetricsCollect != nil {
mapKey, mapValue := config.MetricsCollect.ToMap(ctx)
resultMap[mapKey] = mapValue
}
return "metrics", resultMap
}
func (config *Metrics) CollectAllMetrics(ctx *runtime.Context) {
config.MetricsCollect = new(metric.Collection)
config.MetricsCollect.EnableAll(ctx)
}
func (config *Metrics) Collection() *metric.Collection {
if config.MetricsCollect == nil {
config.MetricsCollect = new(metric.Collection)
}
return config.MetricsCollect
}