PrimeIntellect/SWE-rebench-V2 huggingface dataset:
Repository: apple/swift-distributed-tracing (swift)

Issue:
Use nanosecondsSinceEpoch in `SpanEvent`
In #114 we added `nanosecondsSinceEpoch` to the `TracerInstant`. `SpanEvent`, however, still uses `millisecondsSinceEpoch`. 
We should also base `SpanEvent` on nanoseconds, exposing the same convenience `millisecondsSinceEpoch` accessor we do with `TracerInstant`.

Pull request:
- Closes #117

Patch:
diff --git a/Sources/Tracing/SpanProtocol.swift b/Sources/Tracing/SpanProtocol.swift
index 2b3bea10..2dea4b59 100644
--- a/Sources/Tracing/SpanProtocol.swift
+++ b/Sources/Tracing/SpanProtocol.swift
@@ -149,8 +149,13 @@ public struct SpanEvent: Equatable {
 
     /// The timestamp at which this event occurred.
     ///
-    /// It should be expressed as the number of milliseconds since UNIX Epoch (January 1st 1970).
-    public let millisecondsSinceEpoch: UInt64
+    /// It should be expressed as the number of nanoseconds since UNIX Epoch (January 1st 1970).
+    public let nanosecondsSinceEpoch: UInt64
+
+    /// Representation of the timestamp this event occured as the number of milliseconds since UNIX Epoch (January 1st 1970).
+    public var millisecondsSinceEpoch: UInt64 {
+        self.nanosecondsSinceEpoch / 1_000_000
+    }
 
     /// Create a new `SpanEvent`.
     /// - Parameters:
@@ -163,7 +168,7 @@ public struct SpanEvent: Equatable {
     {
         self.name = name
         self.attributes = attributes
-        self.millisecondsSinceEpoch = clock.now.millisecondsSinceEpoch
+        self.nanosecondsSinceEpoch = clock.now.nanosecondsSinceEpoch
     }
 
     public init(name: String,
@@ -171,7 +176,7 @@ public struct SpanEvent: Equatable {
     {
         self.name = name
         self.attributes = attributes
-        self.millisecondsSinceEpoch = DefaultTracerClock.now.millisecondsSinceEpoch
+        self.nanosecondsSinceEpoch = DefaultTracerClock.now.nanosecondsSinceEpoch
     }
 }
 


Test patch:
diff --git a/Tests/TracingTests/SpanTests.swift b/Tests/TracingTests/SpanTests.swift
index 52cb06f7..b34ad34d 100644
--- a/Tests/TracingTests/SpanTests.swift
+++ b/Tests/TracingTests/SpanTests.swift
@@ -24,6 +24,17 @@ final class SpanTests: XCTestCase {
         XCTAssertEqual(event.name, "test")
     }
 
+    func testSpanEventUsesNanosecondsFromClock() {
+        let clock = MockClock()
+        clock.setTime(42_000_000)
+
+        let event = SpanEvent(name: "test", clock: clock)
+
+        XCTAssertEqual(event.name, "test")
+        XCTAssertEqual(event.nanosecondsSinceEpoch, 42_000_000)
+        XCTAssertEqual(event.millisecondsSinceEpoch, 42)
+    }
+
     func testSpanAttributeIsExpressibleByStringLiteral() {
         let stringAttribute: SpanAttribute = "test"
         guard case .string(let stringValue) = stringAttribute else {