Skip to content

Commit

Permalink
Making it more readable
Browse files Browse the repository at this point in the history
  • Loading branch information
atshaw43 committed Oct 4, 2023
1 parent 6f9429b commit 45a6623
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions exporter/awsxrayexporter/internal/translator/segment.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,16 +226,7 @@ func CreateNonLocalRootSegment(span ptrace.Span, resource pcommon.Resource, inde
return []*awsxray.Segment{segment}, nil
}

// MakeSegmentsFromSpan creates one or more segments from a span
func MakeSegmentsFromSpan(span ptrace.Span, resource pcommon.Resource, indexedAttrs []string, indexAllAttrs bool, logGroupNames []string, skipTimestampValidation bool) ([]*awsxray.Segment, error) {
if !IsLocalRoot(span) {
return CreateNonLocalRootSegment(span, resource, indexedAttrs, indexAllAttrs, logGroupNames, skipTimestampValidation)
}

if !HasDependencySubsegment(span) {
return CreateServiceSegmentWithoutDependency(span, resource, indexedAttrs, indexAllAttrs, logGroupNames, skipTimestampValidation)
}

func MakeServiceSegmentAndDependencySubsegment(span ptrace.Span, resource pcommon.Resource, indexedAttrs []string, indexAllAttrs bool, logGroupNames []string, skipTimestampValidation bool) ([]*awsxray.Segment, error) {
// If it is a local root span and a dependency span, we need to make a segment and subsegment representing the local service and remote service, respectively.
var serviceSegmentID = newSegmentID()
var segments []*awsxray.Segment
Expand All @@ -257,6 +248,19 @@ func MakeSegmentsFromSpan(span ptrace.Span, resource pcommon.Resource, indexedAt
return segments, err
}

// MakeSegmentsFromSpan creates one or more segments from a span
func MakeSegmentsFromSpan(span ptrace.Span, resource pcommon.Resource, indexedAttrs []string, indexAllAttrs bool, logGroupNames []string, skipTimestampValidation bool) ([]*awsxray.Segment, error) {
if !IsLocalRoot(span) {
return CreateNonLocalRootSegment(span, resource, indexedAttrs, indexAllAttrs, logGroupNames, skipTimestampValidation)
}

if !HasDependencySubsegment(span) {
return CreateServiceSegmentWithoutDependency(span, resource, indexedAttrs, indexAllAttrs, logGroupNames, skipTimestampValidation)
}

return MakeServiceSegmentAndDependencySubsegment(span, resource, indexedAttrs, indexAllAttrs, logGroupNames, skipTimestampValidation)
}

// MakeSegmentDocumentString converts an OpenTelemetry Span to an X-Ray Segment and then serialzies to JSON
func MakeSegmentDocumentString(span ptrace.Span, resource pcommon.Resource, indexedAttrs []string, indexAllAttrs bool, logGroupNames []string, skipTimestampValidation bool) (string, error) {
segment, err := MakeSegment(span, resource, indexedAttrs, indexAllAttrs, logGroupNames, skipTimestampValidation)
Expand Down

0 comments on commit 45a6623

Please sign in to comment.