Skip to content

Commit

Permalink
[AppSignals][Bug Fix] Ensure IsEKS function is only called once and r…
Browse files Browse the repository at this point in the history
…esults are reused (#1019)
  • Loading branch information
JayPolanco authored Jan 31, 2024
1 parent 7c0e647 commit f7e093d
Show file tree
Hide file tree
Showing 15 changed files with 162 additions and 406 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ func (h *kubernetesHostedInAttributeResolver) Process(attributes, resourceAttrib
}
}

if isEks, _ := common.IsEKS(); isEks {
if isEks := common.IsEKS(); isEks.Value {
attributes.PutStr(attr.HostedInClusterNameEKS, h.clusterName)
} else {
attributes.PutStr(attr.HostedInClusterNameK8s, h.clusterName)
Expand Down
286 changes: 0 additions & 286 deletions translator/tocwconfig/sampleConfig/base_appsignals_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -144,290 +144,6 @@ processors:
platform: generic
rules: []
limiter: null
resourcedetection:
aks:
resource_attributes:
cloud.platform:
enabled: true
cloud.provider:
enabled: true
attributes: []
auth: null
azure:
resource_attributes:
azure.resourcegroup.name:
enabled: true
azure.vm.name:
enabled: true
azure.vm.scaleset.name:
enabled: true
azure.vm.size:
enabled: true
cloud.account.id:
enabled: true
cloud.platform:
enabled: true
cloud.provider:
enabled: true
cloud.region:
enabled: true
host.id:
enabled: true
host.name:
enabled: true
compression: ""
consul:
address: ""
datacenter: ""
meta: {}
namespace: ""
resource_attributes:
azure.resourcegroup.name:
enabled: true
azure.vm.name:
enabled: true
azure.vm.scaleset.name:
enabled: true
azure.vm.size:
enabled: true
cloud.account.id:
enabled: true
cloud.platform:
enabled: true
cloud.provider:
enabled: true
cloud.region:
enabled: true
host.id:
enabled: true
host.name:
enabled: true
token: '[REDACTED]'
token_file: ""
detectors:
- eks
- env
- ec2
disable_keep_alives: false
docker:
resource_attributes:
host.name:
enabled: true
os.type:
enabled: true
ec2:
resource_attributes:
cloud.account.id:
enabled: true
cloud.availability_zone:
enabled: true
cloud.platform:
enabled: true
cloud.provider:
enabled: true
cloud.region:
enabled: true
host.id:
enabled: true
host.image.id:
enabled: true
host.name:
enabled: true
host.type:
enabled: true
tags:
- ^kubernetes.io/cluster/.*$
ecs:
resource_attributes:
aws.ecs.cluster.arn:
enabled: true
aws.ecs.launchtype:
enabled: true
aws.ecs.task.arn:
enabled: true
aws.ecs.task.family:
enabled: true
aws.ecs.task.revision:
enabled: true
aws.log.group.arns:
enabled: true
aws.log.group.names:
enabled: true
aws.log.stream.arns:
enabled: true
aws.log.stream.names:
enabled: true
cloud.account.id:
enabled: true
cloud.availability_zone:
enabled: true
cloud.platform:
enabled: true
cloud.provider:
enabled: true
cloud.region:
enabled: true
eks:
resource_attributes:
cloud.platform:
enabled: true
cloud.provider:
enabled: true
elasticbeanstalk:
resource_attributes:
cloud.platform:
enabled: true
cloud.provider:
enabled: true
deployment.environment:
enabled: true
service.instance.id:
enabled: true
service.version:
enabled: true
endpoint: ""
gcp:
resource_attributes:
cloud.account.id:
enabled: true
cloud.availability_zone:
enabled: true
cloud.platform:
enabled: true
cloud.provider:
enabled: true
cloud.region:
enabled: true
faas.id:
enabled: true
faas.instance:
enabled: true
faas.name:
enabled: true
faas.version:
enabled: true
gcp.cloud_run.job.execution:
enabled: true
gcp.cloud_run.job.task_index:
enabled: true
gcp.gce.instance.hostname:
enabled: false
gcp.gce.instance.name:
enabled: false
host.id:
enabled: true
host.name:
enabled: true
host.type:
enabled: true
k8s.cluster.name:
enabled: true
headers: {}
heroku:
resource_attributes:
cloud.provider:
enabled: true
heroku.app.id:
enabled: true
heroku.dyno.id:
enabled: true
heroku.release.commit:
enabled: true
heroku.release.creation_timestamp:
enabled: true
service.instance.id:
enabled: true
service.name:
enabled: true
service.version:
enabled: true
idle_conn_timeout: 1m30s
k8snode:
auth_type: serviceAccount
context: ""
node_from_env_var: ""
resource_attributes:
k8s.node.name:
enabled: true
k8s.node.uid:
enabled: true
lambda:
resource_attributes:
aws.log.group.names:
enabled: true
aws.log.stream.names:
enabled: true
cloud.platform:
enabled: true
cloud.provider:
enabled: true
cloud.region:
enabled: true
faas.instance:
enabled: true
faas.max_memory:
enabled: true
faas.name:
enabled: true
faas.version:
enabled: true
max_conns_per_host: null
max_idle_conns: 100
max_idle_conns_per_host: null
openshift:
address: ""
resource_attributes:
cloud.platform:
enabled: true
cloud.provider:
enabled: true
cloud.region:
enabled: true
k8s.cluster.name:
enabled: true
tls:
ca_file: ""
ca_pem: '[REDACTED]'
cert_file: ""
cert_pem: '[REDACTED]'
insecure: false
insecure_skip_verify: false
key_file: ""
key_pem: '[REDACTED]'
max_version: ""
min_version: ""
reload_interval: 0s
server_name_override: ""
token: ""
override: true
read_buffer_size: 0
system:
hostname_sources: []
resource_attributes:
host.arch:
enabled: false
host.cpu.cache.l2.size:
enabled: false
host.cpu.family:
enabled: false
host.cpu.model.id:
enabled: false
host.cpu.model.name:
enabled: false
host.cpu.stepping:
enabled: false
host.cpu.vendor.id:
enabled: false
host.id:
enabled: false
host.name:
enabled: true
os.description:
enabled: false
os.type:
enabled: true
timeout: 2s
write_buffer_size: 0
receivers:
otlp/app_signals:
protocols:
Expand Down Expand Up @@ -463,15 +179,13 @@ service:
exporters:
- awsemf/app_signals
processors:
- resourcedetection
- awsappsignals
receivers:
- otlp/app_signals
traces/app_signals:
exporters:
- awsxray/app_signals
processors:
- resourcedetection
- awsappsignals
receivers:
- otlp/app_signals
Expand Down
3 changes: 3 additions & 0 deletions translator/tocwconfig/tocwconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func TestBaseContainerInsightsConfig(t *testing.T) {

func TestGenericAppSignalsConfig(t *testing.T) {
common.NewDetector = common.TestEKSDetector
common.IsEKS = common.TestIsEKSCacheEKS
resetContext(t)
context.CurrentContext().SetRunInContainer(true)
t.Setenv(config.HOST_NAME, "host_name_from_env")
Expand All @@ -87,6 +88,7 @@ func TestAppSignalsAndKubernetesConfig(t *testing.T) {
t.Setenv(config.HOST_IP, "127.0.0.1")
t.Setenv(common.KubernetesEnvVar, "use_appsignals_eks_config")
common.NewDetector = common.TestEKSDetector
common.IsEKS = common.TestIsEKSCacheEKS

expectedEnvVars := map[string]string{}
checkTranslation(t, "appsignals_and_eks_config", "linux", expectedEnvVars, "")
Expand All @@ -95,6 +97,7 @@ func TestAppSignalsAndKubernetesConfig(t *testing.T) {
common.NewDetector = func() (common.Detector, error) {
return &common.EksDetector{Clientset: fake.NewSimpleClientset()}, nil
}
common.IsEKS = common.TestIsEKSCacheK8s

checkTranslation(t, "appsignals_and_k8s_config", "linux", expectedEnvVars, "")
checkTranslation(t, "appsignals_and_k8s_config", "windows", expectedEnvVars, "")
Expand Down
Loading

0 comments on commit f7e093d

Please sign in to comment.