forked from aws/amazon-cloudwatch-agent-test
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Traces Test to High Cardinality Test Cases
- Loading branch information
1 parent
5aff0ec
commit b717a65
Showing
9 changed files
with
561 additions
and
0 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
test/app_signals/high_cardinality_drop/resources/traceid_generator.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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[:])) | ||
} |
90 changes: 90 additions & 0 deletions
90
test/app_signals/high_cardinality_drop/resources/traces/traces.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
20 changes: 20 additions & 0 deletions
20
test/app_signals/high_cardinality_keep/resources/traceid_generator.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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[:])) | ||
} |
90 changes: 90 additions & 0 deletions
90
test/app_signals/high_cardinality_keep/resources/traces/traces.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
Oops, something went wrong.