@@ -19,11 +19,11 @@ class AdapterTests: XCTestCase {
1919 static let parentSpanId = " 0000000000aef789 "
2020
2121 func testProtoSpans( ) {
22- let duration = 900 // ms
23- let startMs = UInt64 ( Date ( ) . timeIntervalSince1970 * 1000 )
24- let endMs = startMs + UInt64( duration)
22+ let duration = 900 // microseconds
23+ let startMicroseconds = UInt64 ( Date ( ) . timeIntervalSince1970 * 1000000 )
24+ let endMicroseconds = startMicroseconds + UInt64( duration)
2525
26- let span = getSpanData ( startMs : startMs , endMs : endMs )
26+ let span = getSpanData ( startMicroseconds : startMicroseconds , endMicroseconds : endMicroseconds )
2727 let spans = [ span]
2828
2929 let jaegerSpans = Adapter . toJaeger ( spans: spans)
@@ -33,19 +33,19 @@ class AdapterTests: XCTestCase {
3333 }
3434
3535 func testProtoSpan( ) {
36- let duration = 900 // ms
37- let startMs = UInt64 ( Date ( ) . timeIntervalSince1970 * 1000 )
38- let endMs = startMs + UInt64( duration)
36+ let duration = 900 // microseconds
37+ let startMicroseconds = UInt64 ( Date ( ) . timeIntervalSince1970 * 1000000 )
38+ let endMicroseconds = startMicroseconds + UInt64( duration)
3939
40- let span = getSpanData ( startMs : startMs , endMs : endMs )
40+ let span = getSpanData ( startMicroseconds : startMicroseconds , endMicroseconds : endMicroseconds )
4141
4242 // test
4343 let jaegerSpan = Adapter . toJaeger ( span: span)
4444
4545 XCTAssertEqual ( span. traceId. hexString, String ( format: " %016llx " , jaegerSpan. traceIdHigh) + String( format: " %016llx " , jaegerSpan. traceIdLow) )
4646 XCTAssertEqual ( span. spanId. hexString, String ( format: " %016llx " , jaegerSpan. spanId) )
4747 XCTAssertEqual ( " GET /api/endpoint " , jaegerSpan. operationName)
48- XCTAssertEqual ( Int64 ( startMs ) , jaegerSpan. startTime)
48+ XCTAssertEqual ( Int64 ( startMicroseconds ) , jaegerSpan. startTime)
4949 XCTAssertEqual ( duration, Int ( jaegerSpan. duration) )
5050
5151 XCTAssertEqual ( jaegerSpan. tags? . count, 4 )
@@ -181,8 +181,8 @@ class AdapterTests: XCTestCase {
181181 }
182182
183183 func testStatusNotOk( ) {
184- let startMs = UInt64 ( Date ( ) . timeIntervalSince1970 * 1000 )
185- let endMs = startMs + 900
184+ let startMicroseconds = UInt64 ( Date ( ) . timeIntervalSince1970 * 1000000 )
185+ let endMicroseconds = startMicroseconds + 900
186186
187187 let span = SpanData ( traceId: TraceId ( fromHexString: AdapterTests . traceId) ,
188188 spanId: SpanId ( fromHexString: AdapterTests . spanId) ,
@@ -192,9 +192,9 @@ class AdapterTests: XCTestCase {
192192 instrumentationLibraryInfo: InstrumentationLibraryInfo ( ) ,
193193 name: " GET /api/endpoint " ,
194194 kind: . server,
195- startTime: Date ( timeIntervalSince1970: Double ( startMs ) / 1000 ) ,
195+ startTime: Date ( timeIntervalSince1970: Double ( startMicroseconds ) / 1000000 ) ,
196196 status: . error( description: " GenericError " ) ,
197- endTime: Date ( timeIntervalSince1970: Double ( endMs ) / 1000 ) ,
197+ endTime: Date ( timeIntervalSince1970: Double ( endMicroseconds ) / 1000000 ) ,
198198 hasRemoteParent: false )
199199
200200 XCTAssertNotNil ( Adapter . toJaeger ( span: span) )
@@ -203,15 +203,15 @@ class AdapterTests: XCTestCase {
203203 func testSpanError( ) {
204204 let attributes = [ " error.type " : AttributeValue . string ( self . name) ,
205205 " error.message " : AttributeValue . string ( " server error " ) ]
206- let startMs = UInt64 ( Date ( ) . timeIntervalSince1970 * 1000 )
207- let endMs = startMs + 900
206+ let startMicroseconds = UInt64 ( Date ( ) . timeIntervalSince1970 * 1000000 )
207+ let endMicroseconds = startMicroseconds + 900
208208
209209 var span = SpanData ( traceId: TraceId ( fromHexString: AdapterTests . traceId) ,
210210 spanId: SpanId ( fromHexString: AdapterTests . spanId) ,
211211 name: " GET /api/endpoint " ,
212212 kind: . server,
213- startTime: Date ( timeIntervalSince1970: Double ( startMs ) / 1000 ) ,
214- endTime: Date ( timeIntervalSince1970: Double ( endMs ) / 1000 ) )
213+ startTime: Date ( timeIntervalSince1970: Double ( startMicroseconds ) / 1000000 ) ,
214+ endTime: Date ( timeIntervalSince1970: Double ( endMicroseconds ) / 1000000 ) )
215215 span. settingHasEnded ( true )
216216 span. settingStatus ( . error( description: " GenericError " ) )
217217 span. settingAttributes ( attributes)
@@ -230,7 +230,7 @@ class AdapterTests: XCTestCase {
230230 return SpanData . Event ( name: " the log message " , timestamp: Date ( ) , attributes: attributes)
231231 }
232232
233- private func getSpanData( startMs : UInt64 , endMs : UInt64 ) -> SpanData {
233+ private func getSpanData( startMicroseconds : UInt64 , endMicroseconds : UInt64 ) -> SpanData {
234234 let valueB = AttributeValue . bool ( true )
235235 let attributes = [ " valueB " : valueB]
236236
@@ -245,12 +245,12 @@ class AdapterTests: XCTestCase {
245245 instrumentationLibraryInfo: InstrumentationLibraryInfo ( ) ,
246246 name: " GET /api/endpoint " ,
247247 kind: . server,
248- startTime: Date ( timeIntervalSince1970: Double ( startMs ) / 1000 ) ,
248+ startTime: Date ( timeIntervalSince1970: Double ( startMicroseconds ) / 1000000 ) ,
249249 attributes: attributes,
250250 events: [ getTimedEvent ( ) ] ,
251251 links: [ link] ,
252252 status: Status . ok,
253- endTime: Date ( timeIntervalSince1970: Double ( endMs ) / 1000 ) ,
253+ endTime: Date ( timeIntervalSince1970: Double ( endMicroseconds ) / 1000000 ) ,
254254 hasRemoteParent: false )
255255 }
256256
0 commit comments