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

[exporter/awsemf] Update ApplicationSignals log group name and adjust AWS service name #33798

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
27 changes: 27 additions & 0 deletions .chloggen/appsignals-and-awssdk-name-adjustments.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: awsemfexporter

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: AWS EMF Exporter to update ApplicationSignals log group name and namespace, and adjust AWS service name prefix logic in spans

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [33798]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: [user]
26 changes: 13 additions & 13 deletions exporter/awsemfexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,35 +271,35 @@ func TestNoDimensionRollupFeatureGate(t *testing.T) {
_ = featuregate.GlobalRegistry().Set("awsemf.nodimrollupdefault", false)
}

func TestIsAppSignalsEnabled(t *testing.T) {
func TestIsApplicationSignalsEnabled(t *testing.T) {
tests := []struct {
name string
metricNameSpace string
logGroupName string
expectedResult bool
}{
{
"validAppSignalsEMF",
"AppSignals",
"/aws/appsignals/eks",
"validApplicationSignalsEMF",
"ApplicationSignals",
"/aws/application-signals/data",
true,
},
{
"invalidAppSignalsLogsGroup",
"AppSignals",
"/nonaws/appsignals/eks",
"invalidApplicationSignalsLogsGroup",
"ApplicationSignals",
"/nonaws/application-signals/eks",
false,
},
{
"invalidAppSignalsMetricNamespace",
"NonAppSignals",
"/aws/appsignals/eks",
"invalidApplicationSignalsMetricNamespace",
"NonApplicationSignals",
"/aws/application-signals/data",
false,
},
{
"invalidAppSignalsEMF",
"NonAppSignals",
"/nonaws/appsignals/eks",
"invalidApplicationSignalsEMF",
"NonApplicationSignals",
"/nonaws/application-signals/eks",
false,
},
{
Expand Down
4 changes: 2 additions & 2 deletions exporter/awsemfexporter/emf_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ const (
outputDestinationStdout = "stdout"

// AppSignals EMF config
appSignalsMetricNamespace = "AppSignals"
appSignalsLogGroupNamePrefix = "/aws/appsignals/"
appSignalsMetricNamespace = "ApplicationSignals"
appSignalsLogGroupNamePrefix = "/aws/application-signals/"
)

type emfExporter struct {
Expand Down
8 changes: 6 additions & 2 deletions exporter/awsxrayexporter/internal/translator/segment.go
Original file line number Diff line number Diff line change
Expand Up @@ -770,8 +770,12 @@ func fixAnnotationKey(key string) string {
}

func trimAwsSdkPrefix(name string, span ptrace.Span) string {
if isAwsSdkSpan(span) && strings.HasPrefix(name, "AWS.SDK.") {
return strings.TrimPrefix(name, "AWS.SDK.")
if isAwsSdkSpan(span) {
if strings.HasPrefix(name, "AWS.SDK.") {
return strings.TrimPrefix(name, "AWS.SDK.")
} else if strings.HasPrefix(name, "AWS::") {
return strings.TrimPrefix(name, "AWS::")
}
}
return name
}
30 changes: 29 additions & 1 deletion exporter/awsxrayexporter/internal/translator/segment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1093,7 +1093,7 @@ func TestClientSpanWithAwsRemoteServiceName(t *testing.T) {
assert.False(t, strings.Contains(jsonStr, "user"))
}

func TestAwsSdkSpanWithAwsRemoteServiceName(t *testing.T) {
func TestAwsSdkSpanWithDeprecatedAwsRemoteServiceName(t *testing.T) {
spanName := "DynamoDB.PutItem"
parentSpanID := newSegmentID()
user := "testingT"
Expand Down Expand Up @@ -1121,6 +1121,34 @@ func TestAwsSdkSpanWithAwsRemoteServiceName(t *testing.T) {
assert.False(t, strings.Contains(jsonStr, "user"))
}

func TestAwsSdkSpanWithAwsRemoteServiceName(t *testing.T) {
spanName := "DynamoDB.PutItem"
parentSpanID := newSegmentID()
user := "testingT"
attributes := make(map[string]any)
attributes[conventions.AttributeRPCSystem] = "aws-api"
attributes[conventions.AttributeHTTPMethod] = "POST"
attributes[conventions.AttributeHTTPScheme] = "https"
attributes[conventions.AttributeRPCService] = "DynamoDb"
attributes[awsRemoteService] = "AWS::DynamoDB"

resource := constructDefaultResource()
span := constructClientSpan(parentSpanID, spanName, 0, "OK", attributes)

segment, _ := MakeSegment(span, resource, nil, false, nil, false)
assert.Equal(t, "DynamoDB", *segment.Name)
assert.Equal(t, "subsegment", *segment.Type)

jsonStr, err := MakeSegmentDocumentString(span, resource, nil, false, nil, false)

assert.NotNil(t, jsonStr)
assert.Nil(t, err)
assert.True(t, strings.Contains(jsonStr, "DynamoDb"))
assert.False(t, strings.Contains(jsonStr, "DynamoDb.PutItem"))
assert.False(t, strings.Contains(jsonStr, user))
assert.False(t, strings.Contains(jsonStr, "user"))
}

func TestProducerSpanWithAwsRemoteServiceName(t *testing.T) {
spanName := "ABC.payment"
parentSpanID := newSegmentID()
Expand Down
11 changes: 9 additions & 2 deletions internal/aws/cwlogs/cwlog_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -600,14 +600,14 @@ func TestUserAgent(t *testing.T) {
{
"validAppSignalsLogGroupAndAgentString",
component.BuildInfo{Command: "opentelemetry-collector-contrib", Version: "1.0"},
"/aws/appsignals",
"/aws/application-signals",
[]ClientOption{WithUserAgentExtras("AppSignals")},
fmt.Sprintf("opentelemetry-collector-contrib/1.0 (%s; AppSignals)", expectedComponentName),
},
{
"multipleAgentStringExtras",
component.BuildInfo{Command: "opentelemetry-collector-contrib", Version: "1.0"},
"/aws/appsignals",
"/aws/application-signals",
[]ClientOption{WithUserAgentExtras("abcde", "vwxyz", "12345")},
fmt.Sprintf("opentelemetry-collector-contrib/1.0 (%s; abcde; vwxyz; 12345)", expectedComponentName),
},
Expand All @@ -618,6 +618,13 @@ func TestUserAgent(t *testing.T) {
[]ClientOption{WithUserAgentExtras("extra0", "extra1", "extra2")},
fmt.Sprintf("opentelemetry-collector-contrib/1.0 (%s; extra0; extra1; extra2; ContainerInsights)", expectedComponentName),
},
{
"validAppSignalsEMFEnabled",
component.BuildInfo{Command: "opentelemetry-collector-contrib", Version: "1.0"},
"/aws/application-signals",
[]ClientOption{WithUserAgentExtras("AppSignals")},
fmt.Sprintf("opentelemetry-collector-contrib/1.0 (%s; AppSignals)", expectedComponentName),
},
}

testSession, _ := session.NewSession()
Expand Down