Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify Application Signals export template #1430

Merged
merged 2 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

This file was deleted.

36 changes: 2 additions & 34 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,13 +43,7 @@ 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
//go:embed awsemf_default_appsignals.yaml
var appSignalsConfigGeneric string

//go:embed awsemf_jmx_config.yaml
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
bjrara marked this conversation as resolved.
Show resolved Hide resolved
} 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
16 changes: 8 additions & 8 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("awsemf_default_appsignals.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("awsemf_default_appsignals.yaml"), map[string]any{
"local_mode": "true",
"region": "us-east-1",
"role_arn": "global_arn",
Expand All @@ -960,7 +960,7 @@ func TestTranslateAppSignals(t *testing.T) {
"application_signals": map[string]any{},
},
}},
want: testutil.GetConfWithOverrides(t, filepath.Join("appsignals_config_generic.yaml"), map[string]any{
want: testutil.GetConfWithOverrides(t, filepath.Join("awsemf_default_appsignals.yaml"), map[string]any{
"local_mode": "true",
"region": "us-east-1",
"role_arn": "global_arn",
Expand All @@ -976,7 +976,7 @@ func TestTranslateAppSignals(t *testing.T) {
"application_signals": map[string]any{},
},
}},
want: testutil.GetConfWithOverrides(t, filepath.Join("appsignals_config_generic.yaml"), map[string]any{
want: testutil.GetConfWithOverrides(t, filepath.Join("awsemf_default_appsignals.yaml"), map[string]any{
"local_mode": "false",
"region": "us-east-1",
"role_arn": "global_arn",
Expand All @@ -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("awsemf_default_appsignals.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("awsemf_default_appsignals.yaml"), map[string]any{
"local_mode": "true",
"region": "us-east-1",
"role_arn": "global_arn",
Expand All @@ -1024,7 +1024,7 @@ func TestTranslateAppSignals(t *testing.T) {
"app_signals": map[string]any{},
},
}},
want: testutil.GetConfWithOverrides(t, filepath.Join("appsignals_config_generic.yaml"), map[string]any{
want: testutil.GetConfWithOverrides(t, filepath.Join("awsemf_default_appsignals.yaml"), map[string]any{
"local_mode": "true",
"region": "us-east-1",
"role_arn": "global_arn",
Expand All @@ -1040,7 +1040,7 @@ func TestTranslateAppSignals(t *testing.T) {
"app_signals": map[string]any{},
},
}},
want: testutil.GetConfWithOverrides(t, filepath.Join("appsignals_config_generic.yaml"), map[string]any{
want: testutil.GetConfWithOverrides(t, filepath.Join("awsemf_default_appsignals.yaml"), map[string]any{
"local_mode": "false",
"region": "us-east-1",
"role_arn": "global_arn",
Expand Down
Loading