diff --git a/test/app_signals/high_cardinality_drop/resources/traceid_generator.go b/test/app_signals/high_cardinality_drop/resources/traceid_generator.go new file mode 100644 index 000000000..a56fde0f8 --- /dev/null +++ b/test/app_signals/high_cardinality_drop/resources/traceid_generator.go @@ -0,0 +1,20 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: MIT + +package main + +import ( + "crypto/rand" + "encoding/binary" + "encoding/hex" + "fmt" + "time" +) + +func main() { + var r [16]byte + epochNow := time.Now().Unix() + binary.BigEndian.PutUint32(r[0:4], uint32(epochNow)) + rand.Read(r[4:]) + fmt.Printf("%s", hex.EncodeToString(r[:])) +} \ No newline at end of file diff --git a/test/app_signals/high_cardinality_drop/resources/traces/traces.json b/test/app_signals/high_cardinality_drop/resources/traces/traces.json new file mode 100644 index 000000000..b809f1dd7 --- /dev/null +++ b/test/app_signals/high_cardinality_drop/resources/traces/traces.json @@ -0,0 +1,90 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "k8s.namespace.name", + "value": { + "stringValue": "default" + } + }, + { + "key": "k8s.pod.name", + "value": { + "stringValue": "pod-name" + } + }, + { + "key": "aws.deployment.name", + "value": { + "stringValue": "deployment-name" + } + }, + { + "key": "host.id", + "value": { + "stringValue": "i-00000000000000000" + } + } + ] + }, + "scopeSpans": [ + { + "scope": { + "name": "app-signals-integration-test" + }, + "spans": [ + { + "traceId": "TRACE_ID", + "spanId": "EEE19B7EC3C1B174", + "parentSpanId": "EEE19B7EC3C1B173", + "name": "app-signals-integration-test-traces", + "startTimeUnixNano": START_TIME, + "endTimeUnixNano": START_TIME, + "kind": 2, + "attributes": [ + { + "key": "aws.span.kind", + "value": { + "stringValue": "CLIENT" + } + }, + { + "key": "aws.local.operation", + "value": { + "stringValue": "operation" + } + }, + { + "key": "aws.local.service", + "value": { + "stringValue": "service-name" + } + }, + { + "key": "aws.remote.operation", + "value": { + "stringValue": "remote-operation" + } + }, + { + "key": "aws.remote.service", + "value": { + "stringValue": "service-name-remote" + } + }, + { + "key": "aws.remote.target", + "value": { + "stringValue": "remote-target" + } + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/test/app_signals/high_cardinality_drop/traces_test.go b/test/app_signals/high_cardinality_drop/traces_test.go new file mode 100644 index 000000000..fe84a2b0f --- /dev/null +++ b/test/app_signals/high_cardinality_drop/traces_test.go @@ -0,0 +1,77 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: MIT + +//go:build !windows + +package app_signals + +import ( + "fmt" + "time" + + "github.com/aws/amazon-cloudwatch-agent-test/test/status" + "github.com/aws/amazon-cloudwatch-agent-test/test/test_runner" + "github.com/aws/amazon-cloudwatch-agent-test/util/awsservice" +) + +const ( + lookbackDuration = time.Duration(-5) * time.Minute + EKSClusterAnnotation = "HostedIn_EKS_Cluster" +) + +var annotations = map[string]interface{}{ + "aws_remote_target": "remote-target", + "aws_remote_operation": "remote-operation", + "aws_local_service": "service-name", + "aws_remote_service": "service-name-remote", + "HostedIn_K8s_Namespace": "default", + "aws_local_operation": "operation", +} + +type AppSignalsTracesRunner struct { + test_runner.BaseTestRunner + testName string + clusterName string +} + +func (t *AppSignalsTracesRunner) Validate() status.TestGroupResult { + testResults := status.TestResult{ + Name: t.testName, + Status: status.FAILED, + } + timeNow := time.Now() + annotations[EKSClusterAnnotation] = t.clusterName + xrayFilter := awsservice.FilterExpression(annotations) + traceIds, err := awsservice.GetTraceIDs(timeNow.Add(lookbackDuration), timeNow, xrayFilter) + if err != nil { + fmt.Printf("error getting trace ids: %v", err) + } else { + fmt.Printf("Trace IDs: %v\n", traceIds) + if len(traceIds) > 0 { + testResults.Status = status.SUCCESSFUL + } + } + + return status.TestGroupResult{ + Name: t.GetTestName(), + TestResults: []status.TestResult{testResults}, + } +} + +func (t *AppSignalsTracesRunner) GetTestName() string { + return t.testName +} + +func (t *AppSignalsTracesRunner) GetAgentRunDuration() time.Duration { + return 3 * time.Minute +} + +func (t *AppSignalsTracesRunner) GetMeasuredMetrics() []string { + return nil +} + +func (e *AppSignalsTracesRunner) GetAgentConfigFileName() string { + return "" +} + +var _ test_runner.ITestRunner = (*AppSignalsTracesRunner)(nil) diff --git a/test/app_signals/high_cardinality_keep/resources/traceid_generator.go b/test/app_signals/high_cardinality_keep/resources/traceid_generator.go new file mode 100644 index 000000000..a56fde0f8 --- /dev/null +++ b/test/app_signals/high_cardinality_keep/resources/traceid_generator.go @@ -0,0 +1,20 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: MIT + +package main + +import ( + "crypto/rand" + "encoding/binary" + "encoding/hex" + "fmt" + "time" +) + +func main() { + var r [16]byte + epochNow := time.Now().Unix() + binary.BigEndian.PutUint32(r[0:4], uint32(epochNow)) + rand.Read(r[4:]) + fmt.Printf("%s", hex.EncodeToString(r[:])) +} \ No newline at end of file diff --git a/test/app_signals/high_cardinality_keep/resources/traces/traces.json b/test/app_signals/high_cardinality_keep/resources/traces/traces.json new file mode 100644 index 000000000..b809f1dd7 --- /dev/null +++ b/test/app_signals/high_cardinality_keep/resources/traces/traces.json @@ -0,0 +1,90 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "k8s.namespace.name", + "value": { + "stringValue": "default" + } + }, + { + "key": "k8s.pod.name", + "value": { + "stringValue": "pod-name" + } + }, + { + "key": "aws.deployment.name", + "value": { + "stringValue": "deployment-name" + } + }, + { + "key": "host.id", + "value": { + "stringValue": "i-00000000000000000" + } + } + ] + }, + "scopeSpans": [ + { + "scope": { + "name": "app-signals-integration-test" + }, + "spans": [ + { + "traceId": "TRACE_ID", + "spanId": "EEE19B7EC3C1B174", + "parentSpanId": "EEE19B7EC3C1B173", + "name": "app-signals-integration-test-traces", + "startTimeUnixNano": START_TIME, + "endTimeUnixNano": START_TIME, + "kind": 2, + "attributes": [ + { + "key": "aws.span.kind", + "value": { + "stringValue": "CLIENT" + } + }, + { + "key": "aws.local.operation", + "value": { + "stringValue": "operation" + } + }, + { + "key": "aws.local.service", + "value": { + "stringValue": "service-name" + } + }, + { + "key": "aws.remote.operation", + "value": { + "stringValue": "remote-operation" + } + }, + { + "key": "aws.remote.service", + "value": { + "stringValue": "service-name-remote" + } + }, + { + "key": "aws.remote.target", + "value": { + "stringValue": "remote-target" + } + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/test/app_signals/high_cardinality_keep/traces_test.go b/test/app_signals/high_cardinality_keep/traces_test.go new file mode 100644 index 000000000..fe84a2b0f --- /dev/null +++ b/test/app_signals/high_cardinality_keep/traces_test.go @@ -0,0 +1,77 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: MIT + +//go:build !windows + +package app_signals + +import ( + "fmt" + "time" + + "github.com/aws/amazon-cloudwatch-agent-test/test/status" + "github.com/aws/amazon-cloudwatch-agent-test/test/test_runner" + "github.com/aws/amazon-cloudwatch-agent-test/util/awsservice" +) + +const ( + lookbackDuration = time.Duration(-5) * time.Minute + EKSClusterAnnotation = "HostedIn_EKS_Cluster" +) + +var annotations = map[string]interface{}{ + "aws_remote_target": "remote-target", + "aws_remote_operation": "remote-operation", + "aws_local_service": "service-name", + "aws_remote_service": "service-name-remote", + "HostedIn_K8s_Namespace": "default", + "aws_local_operation": "operation", +} + +type AppSignalsTracesRunner struct { + test_runner.BaseTestRunner + testName string + clusterName string +} + +func (t *AppSignalsTracesRunner) Validate() status.TestGroupResult { + testResults := status.TestResult{ + Name: t.testName, + Status: status.FAILED, + } + timeNow := time.Now() + annotations[EKSClusterAnnotation] = t.clusterName + xrayFilter := awsservice.FilterExpression(annotations) + traceIds, err := awsservice.GetTraceIDs(timeNow.Add(lookbackDuration), timeNow, xrayFilter) + if err != nil { + fmt.Printf("error getting trace ids: %v", err) + } else { + fmt.Printf("Trace IDs: %v\n", traceIds) + if len(traceIds) > 0 { + testResults.Status = status.SUCCESSFUL + } + } + + return status.TestGroupResult{ + Name: t.GetTestName(), + TestResults: []status.TestResult{testResults}, + } +} + +func (t *AppSignalsTracesRunner) GetTestName() string { + return t.testName +} + +func (t *AppSignalsTracesRunner) GetAgentRunDuration() time.Duration { + return 3 * time.Minute +} + +func (t *AppSignalsTracesRunner) GetMeasuredMetrics() []string { + return nil +} + +func (e *AppSignalsTracesRunner) GetAgentConfigFileName() string { + return "" +} + +var _ test_runner.ITestRunner = (*AppSignalsTracesRunner)(nil) diff --git a/test/app_signals/high_cardinality_replace/resources/traceid_generator.go b/test/app_signals/high_cardinality_replace/resources/traceid_generator.go new file mode 100644 index 000000000..a56fde0f8 --- /dev/null +++ b/test/app_signals/high_cardinality_replace/resources/traceid_generator.go @@ -0,0 +1,20 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: MIT + +package main + +import ( + "crypto/rand" + "encoding/binary" + "encoding/hex" + "fmt" + "time" +) + +func main() { + var r [16]byte + epochNow := time.Now().Unix() + binary.BigEndian.PutUint32(r[0:4], uint32(epochNow)) + rand.Read(r[4:]) + fmt.Printf("%s", hex.EncodeToString(r[:])) +} \ No newline at end of file diff --git a/test/app_signals/high_cardinality_replace/resources/traces/traces.json b/test/app_signals/high_cardinality_replace/resources/traces/traces.json new file mode 100644 index 000000000..b809f1dd7 --- /dev/null +++ b/test/app_signals/high_cardinality_replace/resources/traces/traces.json @@ -0,0 +1,90 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "k8s.namespace.name", + "value": { + "stringValue": "default" + } + }, + { + "key": "k8s.pod.name", + "value": { + "stringValue": "pod-name" + } + }, + { + "key": "aws.deployment.name", + "value": { + "stringValue": "deployment-name" + } + }, + { + "key": "host.id", + "value": { + "stringValue": "i-00000000000000000" + } + } + ] + }, + "scopeSpans": [ + { + "scope": { + "name": "app-signals-integration-test" + }, + "spans": [ + { + "traceId": "TRACE_ID", + "spanId": "EEE19B7EC3C1B174", + "parentSpanId": "EEE19B7EC3C1B173", + "name": "app-signals-integration-test-traces", + "startTimeUnixNano": START_TIME, + "endTimeUnixNano": START_TIME, + "kind": 2, + "attributes": [ + { + "key": "aws.span.kind", + "value": { + "stringValue": "CLIENT" + } + }, + { + "key": "aws.local.operation", + "value": { + "stringValue": "operation" + } + }, + { + "key": "aws.local.service", + "value": { + "stringValue": "service-name" + } + }, + { + "key": "aws.remote.operation", + "value": { + "stringValue": "remote-operation" + } + }, + { + "key": "aws.remote.service", + "value": { + "stringValue": "service-name-remote" + } + }, + { + "key": "aws.remote.target", + "value": { + "stringValue": "remote-target" + } + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/test/app_signals/high_cardinality_replace/traces_test.go b/test/app_signals/high_cardinality_replace/traces_test.go new file mode 100644 index 000000000..fe84a2b0f --- /dev/null +++ b/test/app_signals/high_cardinality_replace/traces_test.go @@ -0,0 +1,77 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: MIT + +//go:build !windows + +package app_signals + +import ( + "fmt" + "time" + + "github.com/aws/amazon-cloudwatch-agent-test/test/status" + "github.com/aws/amazon-cloudwatch-agent-test/test/test_runner" + "github.com/aws/amazon-cloudwatch-agent-test/util/awsservice" +) + +const ( + lookbackDuration = time.Duration(-5) * time.Minute + EKSClusterAnnotation = "HostedIn_EKS_Cluster" +) + +var annotations = map[string]interface{}{ + "aws_remote_target": "remote-target", + "aws_remote_operation": "remote-operation", + "aws_local_service": "service-name", + "aws_remote_service": "service-name-remote", + "HostedIn_K8s_Namespace": "default", + "aws_local_operation": "operation", +} + +type AppSignalsTracesRunner struct { + test_runner.BaseTestRunner + testName string + clusterName string +} + +func (t *AppSignalsTracesRunner) Validate() status.TestGroupResult { + testResults := status.TestResult{ + Name: t.testName, + Status: status.FAILED, + } + timeNow := time.Now() + annotations[EKSClusterAnnotation] = t.clusterName + xrayFilter := awsservice.FilterExpression(annotations) + traceIds, err := awsservice.GetTraceIDs(timeNow.Add(lookbackDuration), timeNow, xrayFilter) + if err != nil { + fmt.Printf("error getting trace ids: %v", err) + } else { + fmt.Printf("Trace IDs: %v\n", traceIds) + if len(traceIds) > 0 { + testResults.Status = status.SUCCESSFUL + } + } + + return status.TestGroupResult{ + Name: t.GetTestName(), + TestResults: []status.TestResult{testResults}, + } +} + +func (t *AppSignalsTracesRunner) GetTestName() string { + return t.testName +} + +func (t *AppSignalsTracesRunner) GetAgentRunDuration() time.Duration { + return 3 * time.Minute +} + +func (t *AppSignalsTracesRunner) GetMeasuredMetrics() []string { + return nil +} + +func (e *AppSignalsTracesRunner) GetAgentConfigFileName() string { + return "" +} + +var _ test_runner.ITestRunner = (*AppSignalsTracesRunner)(nil)