Skip to content

Commit

Permalink
Unify Application Signals export template
Browse files Browse the repository at this point in the history
  • Loading branch information
bjrara committed Nov 21, 2024
1 parent 1b8ad16 commit 7ef7653
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 129 deletions.
30 changes: 30 additions & 0 deletions translator/tocwconfig/sampleConfig/appsignals_and_ecs_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,47 @@ exporters:
- dimensions:
- - Environment
- Operation
- RemoteEnvironment
- RemoteOperation
- RemoteResourceIdentifier
- RemoteResourceType
- RemoteService
- Service
- - Environment
- Operation
- RemoteEnvironment
- RemoteOperation
- RemoteService
- Service
- - Environment
- Operation
- RemoteOperation
- RemoteResourceIdentifier
- RemoteResourceType
- RemoteService
- Service
- - Environment
- Operation
- RemoteOperation
- RemoteService
- Service
- - Environment
- RemoteEnvironment
- RemoteService
- Service
- - Environment
- RemoteService
- Service
- - Environment
- RemoteEnvironment
- RemoteOperation
- RemoteResourceIdentifier
- RemoteResourceType
- RemoteService
- Service
- - Environment
- RemoteEnvironment
- RemoteOperation
- RemoteService
- Service
- - Environment
Expand Down
30 changes: 30 additions & 0 deletions translator/tocwconfig/sampleConfig/base_appsignals_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,47 @@ exporters:
- dimensions:
- - Environment
- Operation
- RemoteEnvironment
- RemoteOperation
- RemoteResourceIdentifier
- RemoteResourceType
- RemoteService
- Service
- - Environment
- Operation
- RemoteEnvironment
- RemoteOperation
- RemoteService
- Service
- - Environment
- Operation
- RemoteOperation
- RemoteResourceIdentifier
- RemoteResourceType
- RemoteService
- Service
- - Environment
- Operation
- RemoteOperation
- RemoteService
- Service
- - Environment
- RemoteEnvironment
- RemoteService
- Service
- - Environment
- RemoteService
- Service
- - Environment
- RemoteEnvironment
- RemoteOperation
- RemoteResourceIdentifier
- RemoteResourceType
- RemoteService
- Service
- - Environment
- RemoteEnvironment
- RemoteOperation
- RemoteService
- Service
- - Environment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,47 @@ exporters:
- dimensions:
- - Environment
- Operation
- RemoteEnvironment
- RemoteOperation
- RemoteResourceIdentifier
- RemoteResourceType
- RemoteService
- Service
- - Environment
- Operation
- RemoteEnvironment
- RemoteOperation
- RemoteService
- Service
- - Environment
- Operation
- RemoteOperation
- RemoteResourceIdentifier
- RemoteResourceType
- RemoteService
- Service
- - Environment
- Operation
- RemoteOperation
- RemoteService
- Service
- - Environment
- RemoteEnvironment
- RemoteService
- Service
- - Environment
- RemoteService
- Service
- - Environment
- RemoteEnvironment
- RemoteOperation
- RemoteResourceIdentifier
- RemoteResourceType
- RemoteService
- Service
- - Environment
- RemoteEnvironment
- RemoteOperation
- RemoteService
- Service
- - Environment
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,14 @@ metric_declarations:
- Fault
- Error
- dimensions:
- [Environment, Service, Operation, RemoteService, RemoteOperation, RemoteEnvironment, RemoteResourceIdentifier, RemoteResourceType]
- [Environment, Service, Operation, RemoteService, RemoteOperation, RemoteEnvironment]
- [Environment, Service, Operation, RemoteService, RemoteOperation, RemoteResourceIdentifier, RemoteResourceType]
- [Environment, Service, Operation, RemoteService, RemoteOperation]
- [Environment, Service, RemoteService, RemoteEnvironment]
- [Environment, Service, RemoteService]
- [Environment, Service, RemoteService, RemoteOperation, RemoteEnvironment, RemoteResourceIdentifier, RemoteResourceType]
- [Environment, Service, RemoteService, RemoteOperation, RemoteEnvironment]
- [Environment, Service, RemoteService, RemoteOperation, RemoteResourceIdentifier, RemoteResourceType]
- [Environment, Service, RemoteService, RemoteOperation]
- [Environment, Service, RemoteService, RemoteResourceIdentifier, RemoteResourceType]
Expand Down

This file was deleted.

34 changes: 1 addition & 33 deletions translator/translate/otel/exporter/awsemf/translator.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"github.com/aws/amazon-cloudwatch-agent/translator/translate/otel/common"
"github.com/aws/amazon-cloudwatch-agent/translator/translate/otel/extension/agenthealth"
"github.com/aws/amazon-cloudwatch-agent/translator/translate/otel/receiver/awscontainerinsight"
"github.com/aws/amazon-cloudwatch-agent/translator/util/ecsutil"
)

const (
Expand All @@ -44,12 +43,6 @@ var defaultKubernetesKueueConfig string
//go:embed awsemf_default_prometheus.yaml
var defaultPrometheusConfig string

//go:embed appsignals_config_eks.yaml
var appSignalsConfigEks string

//go:embed appsignals_config_k8s.yaml
var appSignalsConfigK8s string

//go:embed appsignals_config_generic.yaml
var appSignalsConfigGeneric string

Expand Down Expand Up @@ -92,7 +85,7 @@ func (t *translator) Translate(c *confmap.Conf) (component.Config, error) {

defaultConfig := defaultGenericConfig
if t.isAppSignals(c) {
defaultConfig = getAppSignalsConfig()
defaultConfig = appSignalsConfigGeneric
} else if t.isCiJMX(c) {
defaultConfig = defaultJmxConfig
} else if isEcs(c) {
Expand Down Expand Up @@ -163,31 +156,6 @@ func (t *translator) Translate(c *confmap.Conf) (component.Config, error) {
return cfg, nil
}

func getAppSignalsConfig() string {
ctx := context.CurrentContext()

mode := ctx.KubernetesMode()
if mode == "" {
mode = ctx.Mode()
}
if mode == config.ModeEC2 {
if ecsutil.GetECSUtilSingleton().IsECS() {
mode = config.ModeECS
}
}

switch mode {
case config.ModeEKS:
return appSignalsConfigEks
case config.ModeK8sEC2, config.ModeK8sOnPrem:
return appSignalsConfigK8s
case config.ModeEC2, config.ModeECS:
return appSignalsConfigGeneric
default:
return appSignalsConfigGeneric
}
}

func (t *translator) isAppSignals(conf *confmap.Conf) bool {
return (t.name == common.AppSignals || t.name == common.AppSignalsFallback) && (conf.IsSet(common.AppSignalsMetrics) || conf.IsSet(common.AppSignalsTraces) || conf.IsSet(common.AppSignalsMetricsFallback) || conf.IsSet(common.AppSignalsTracesFallback))
}
Expand Down
8 changes: 4 additions & 4 deletions translator/translate/otel/exporter/awsemf/translator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,7 @@ func TestTranslateAppSignals(t *testing.T) {
"application_signals": map[string]any{},
},
}},
want: testutil.GetConfWithOverrides(t, filepath.Join("appsignals_config_eks.yaml"), map[string]any{
want: testutil.GetConfWithOverrides(t, filepath.Join("appsignals_config_generic.yaml"), map[string]any{
"local_mode": "false",
"region": "us-east-1",
"role_arn": "global_arn",
Expand All @@ -944,7 +944,7 @@ func TestTranslateAppSignals(t *testing.T) {
"application_signals": map[string]any{},
},
}},
want: testutil.GetConfWithOverrides(t, filepath.Join("appsignals_config_k8s.yaml"), map[string]any{
want: testutil.GetConfWithOverrides(t, filepath.Join("appsignals_config_generic.yaml"), map[string]any{
"local_mode": "true",
"region": "us-east-1",
"role_arn": "global_arn",
Expand Down Expand Up @@ -992,7 +992,7 @@ func TestTranslateAppSignals(t *testing.T) {
"app_signals": map[string]any{},
},
}},
want: testutil.GetConfWithOverrides(t, filepath.Join("appsignals_config_eks.yaml"), map[string]any{
want: testutil.GetConfWithOverrides(t, filepath.Join("appsignals_config_generic.yaml"), map[string]any{
"local_mode": "false",
"region": "us-east-1",
"role_arn": "global_arn",
Expand All @@ -1008,7 +1008,7 @@ func TestTranslateAppSignals(t *testing.T) {
"app_signals": map[string]any{},
},
}},
want: testutil.GetConfWithOverrides(t, filepath.Join("appsignals_config_k8s.yaml"), map[string]any{
want: testutil.GetConfWithOverrides(t, filepath.Join("appsignals_config_generic.yaml"), map[string]any{
"local_mode": "true",
"region": "us-east-1",
"role_arn": "global_arn",
Expand Down

0 comments on commit 7ef7653

Please sign in to comment.