Skip to content

Commit

Permalink
Added also the usage of eventsSyncLock to wrap the toSpanData operation
Browse files Browse the repository at this point in the history
  • Loading branch information
ArielDemarco committed Nov 6, 2024
1 parent 1137364 commit fcc80ee
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions Sources/OpenTelemetrySdk/Trace/RecordEventsReadableSpan.swift
Original file line number Diff line number Diff line change
Expand Up @@ -192,27 +192,29 @@ public class RecordEventsReadableSpan: ReadableSpan {
}

public func toSpanData() -> SpanData {
attributesSyncLock.withLock {
return SpanData(traceId: context.traceId,
spanId: context.spanId,
traceFlags: context.traceFlags,
traceState: context.traceState,
parentSpanId: parentContext?.spanId,
resource: resource,
instrumentationScope: instrumentationScopeInfo,
name: name,
kind: kind,
startTime: startTime,
attributes: attributes.attributes,
events: adaptEvents(),
links: adaptLinks(),
status: status,
endTime: endTime ?? clock.now,
hasRemoteParent: hasRemoteParent,
hasEnded: hasEnded,
totalRecordedEvents: getTotalRecordedEvents(),
totalRecordedLinks: totalRecordedLinks,
totalAttributeCount: totalAttributeCount)
eventsSyncLock.withLock {
attributesSyncLock.withLock {
return SpanData(traceId: context.traceId,
spanId: context.spanId,
traceFlags: context.traceFlags,
traceState: context.traceState,
parentSpanId: parentContext?.spanId,
resource: resource,
instrumentationScope: instrumentationScopeInfo,
name: name,
kind: kind,
startTime: startTime,
attributes: attributes.attributes,
events: adaptEvents(),
links: adaptLinks(),
status: status,
endTime: endTime ?? clock.now,
hasRemoteParent: hasRemoteParent,
hasEnded: hasEnded,
totalRecordedEvents: getTotalRecordedEvents(),
totalRecordedLinks: totalRecordedLinks,
totalAttributeCount: totalAttributeCount)
}
}
}

Expand Down

0 comments on commit fcc80ee

Please sign in to comment.