Skip to content

Commit

Permalink
[exporter/awsemf] Update ApplicationSignals log group name and adjust…
Browse files Browse the repository at this point in the history
… AWS service name (#33798)

**Description:** 
Cherry-picking from downstream:
amazon-contributing#197

Changes:
- unify the log group name to /aws/application-signals/data.
- rename Application Signals metric namespace.
- removed OTelLib name label from EMF log

---------

Co-authored-by: Mengyi Zhou (bjrara) <[email protected]>
  • Loading branch information
jj22ee and bjrara authored Aug 1, 2024
1 parent 67a5891 commit 23013d3
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 20 deletions.
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

0 comments on commit 23013d3

Please sign in to comment.