@@ -18,9 +18,11 @@ class AdapterTests: XCTestCase {
1818 static let spanId = " 0000000000def456 "
1919 static let parentSpanId = " 0000000000aef789 "
2020
21+ let microsecondsInSecond : Double = 1000000
22+
2123 func testProtoSpans( ) {
2224 let duration = 900 // microseconds
23- let startMicroseconds = UInt64 ( Date ( ) . timeIntervalSince1970 * 1000000 )
25+ let startMicroseconds = UInt64 ( Date ( ) . timeIntervalSince1970 * microsecondsInSecond )
2426 let endMicroseconds = startMicroseconds + UInt64( duration)
2527
2628 let span = getSpanData ( startMicroseconds: startMicroseconds, endMicroseconds: endMicroseconds)
@@ -34,7 +36,7 @@ class AdapterTests: XCTestCase {
3436
3537 func testProtoSpan( ) {
3638 let duration = 900 // microseconds
37- let startMicroseconds = UInt64 ( Date ( ) . timeIntervalSince1970 * 1000000 )
39+ let startMicroseconds = UInt64 ( Date ( ) . timeIntervalSince1970 * microsecondsInSecond )
3840 let endMicroseconds = startMicroseconds + UInt64( duration)
3941
4042 let span = getSpanData ( startMicroseconds: startMicroseconds, endMicroseconds: endMicroseconds)
@@ -181,7 +183,7 @@ class AdapterTests: XCTestCase {
181183 }
182184
183185 func testStatusNotOk( ) {
184- let startMicroseconds = UInt64 ( Date ( ) . timeIntervalSince1970 * 1000000 )
186+ let startMicroseconds = UInt64 ( Date ( ) . timeIntervalSince1970 * microsecondsInSecond )
185187 let endMicroseconds = startMicroseconds + 900
186188
187189 let span = SpanData ( traceId: TraceId ( fromHexString: AdapterTests . traceId) ,
@@ -192,9 +194,9 @@ class AdapterTests: XCTestCase {
192194 instrumentationLibraryInfo: InstrumentationLibraryInfo ( ) ,
193195 name: " GET /api/endpoint " ,
194196 kind: . server,
195- startTime: Date ( timeIntervalSince1970: Double ( startMicroseconds) / 1000000 ) ,
197+ startTime: Date ( timeIntervalSince1970: Double ( startMicroseconds) / microsecondsInSecond ) ,
196198 status: . error( description: " GenericError " ) ,
197- endTime: Date ( timeIntervalSince1970: Double ( endMicroseconds) / 1000000 ) ,
199+ endTime: Date ( timeIntervalSince1970: Double ( endMicroseconds) / microsecondsInSecond ) ,
198200 hasRemoteParent: false )
199201
200202 XCTAssertNotNil ( Adapter . toJaeger ( span: span) )
@@ -203,15 +205,15 @@ class AdapterTests: XCTestCase {
203205 func testSpanError( ) {
204206 let attributes = [ " error.type " : AttributeValue . string ( self . name) ,
205207 " error.message " : AttributeValue . string ( " server error " ) ]
206- let startMicroseconds = UInt64 ( Date ( ) . timeIntervalSince1970 * 1000000 )
208+ let startMicroseconds = UInt64 ( Date ( ) . timeIntervalSince1970 * microsecondsInSecond )
207209 let endMicroseconds = startMicroseconds + 900
208210
209211 var span = SpanData ( traceId: TraceId ( fromHexString: AdapterTests . traceId) ,
210212 spanId: SpanId ( fromHexString: AdapterTests . spanId) ,
211213 name: " GET /api/endpoint " ,
212214 kind: . server,
213- startTime: Date ( timeIntervalSince1970: Double ( startMicroseconds) / 1000000 ) ,
214- endTime: Date ( timeIntervalSince1970: Double ( endMicroseconds) / 1000000 ) )
215+ startTime: Date ( timeIntervalSince1970: Double ( startMicroseconds) / microsecondsInSecond ) ,
216+ endTime: Date ( timeIntervalSince1970: Double ( endMicroseconds) / microsecondsInSecond ) )
215217 span. settingHasEnded ( true )
216218 span. settingStatus ( . error( description: " GenericError " ) )
217219 span. settingAttributes ( attributes)
@@ -245,12 +247,12 @@ class AdapterTests: XCTestCase {
245247 instrumentationLibraryInfo: InstrumentationLibraryInfo ( ) ,
246248 name: " GET /api/endpoint " ,
247249 kind: . server,
248- startTime: Date ( timeIntervalSince1970: Double ( startMicroseconds) / 1000000 ) ,
250+ startTime: Date ( timeIntervalSince1970: Double ( startMicroseconds) / microsecondsInSecond ) ,
249251 attributes: attributes,
250252 events: [ getTimedEvent ( ) ] ,
251253 links: [ link] ,
252254 status: Status . ok,
253- endTime: Date ( timeIntervalSince1970: Double ( endMicroseconds) / 1000000 ) ,
255+ endTime: Date ( timeIntervalSince1970: Double ( endMicroseconds) / microsecondsInSecond ) ,
254256 hasRemoteParent: false )
255257 }
256258
0 commit comments