Skip to content

Commit

Permalink
Pull Request review changes for #27232
Browse files Browse the repository at this point in the history
- Define "aws-api" as a const
- Rename some variables in cause.go to make the intended behavior a little more clear
- PR: #27232
  • Loading branch information
jknollmeyer committed Oct 9, 2023
1 parent 7c037ad commit e846069
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 4 additions & 3 deletions exporter/awsxrayexporter/internal/translator/cause.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,23 @@ func makeCause(span ptrace.Span, attributes map[string]pcommon.Value, resource p
)

isAwsSdkSpan := isAwsSdkSpan(span)
hasExceptions := false
hasExceptionEvents := false
hasAwsIndividualHTTPError := false
for i := 0; i < span.Events().Len(); i++ {
event := span.Events().At(i)
if event.Name() == ExceptionEventName {
hasExceptions = true
hasExceptionEvents = true
break
}
if isAwsSdkSpan && event.Name() == AwsIndividualHTTPEventName {
hasAwsIndividualHTTPError = true
break
}
}
hasExceptions := hasExceptionEvents || hasAwsIndividualHTTPError

switch {
case hasExceptions || hasAwsIndividualHTTPError:
case hasExceptions:
language := ""
if val, ok := resource.Attributes().Get(conventions.AttributeTelemetrySDKLanguage); ok {
language = val.Str()
Expand Down
4 changes: 3 additions & 1 deletion exporter/awsxrayexporter/internal/translator/segment.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ const (
defaultSegmentName = "span"
// maxSegmentNameLength the maximum length of a Segment name
maxSegmentNameLength = 200
// rpc.system value for AWS service remotes
awsAPIRPCSystem = "aws-api"
)

const (
Expand Down Expand Up @@ -82,7 +84,7 @@ func MakeSegmentDocumentString(span ptrace.Span, resource pcommon.Resource, inde
func isAwsSdkSpan(span ptrace.Span) bool {
attributes := span.Attributes()
if rpcSystem, ok := attributes.Get(conventions.AttributeRPCSystem); ok {
return rpcSystem.Str() == "aws-api"
return rpcSystem.Str() == awsAPIRPCSystem
}
return false
}
Expand Down

0 comments on commit e846069

Please sign in to comment.