@@ -181,15 +181,48 @@ final class SpanTests: XCTestCase {
181
181
182
182
XCTAssertEqual ( child. links. count, 1 )
183
183
XCTAssertEqual ( child. links [ 0 ] . baggage [ TestBaggageContextKey . self] , " test " )
184
- #if swift(>=5.2)
185
184
XCTAssertEqual ( child. links [ 0 ] . attributes. sampleHttp. statusCode, 418 )
186
- #endif
187
185
guard case . some( . int64( let statusCode) ) = child. links [ 0 ] . attributes [ " http.status_code " ] ? . toSpanAttribute ( ) else {
188
186
XCTFail ( " Expected int value for http.status_code " )
189
187
return
190
188
}
191
189
XCTAssertEqual ( statusCode, 418 )
192
190
}
191
+
192
+ func testSpanAttributeSetterGetter( ) {
193
+ var parentBaggage = Baggage . topLevel
194
+ parentBaggage [ TestBaggageContextKey . self] = " test "
195
+
196
+ let parent = TestSpan (
197
+ operationName: " client " ,
198
+ startTime: . now( ) ,
199
+ baggage: parentBaggage,
200
+ kind: . client,
201
+ onEnd: { _ in }
202
+ )
203
+ let childBaggage = Baggage . topLevel
204
+ let child = TestSpan (
205
+ operationName: " server " ,
206
+ startTime: . now( ) ,
207
+ baggage: childBaggage,
208
+ kind: . server,
209
+ onEnd: { _ in }
210
+ )
211
+
212
+ var attributes = SpanAttributes ( )
213
+ attributes. set ( " http.status_code " , value: . int32( 418 ) )
214
+ child. addLink ( parent, attributes: attributes)
215
+
216
+ XCTAssertEqual ( child. links. count, 1 )
217
+ XCTAssertEqual ( child. links [ 0 ] . baggage [ TestBaggageContextKey . self] , " test " )
218
+ XCTAssertEqual ( child. links [ 0 ] . attributes. sampleHttp. statusCode, 418 )
219
+ guard case . some( . int32( let statusCode) ) = child. links [ 0 ] . attributes [ " http.status_code " ] ? . toSpanAttribute ( ) else {
220
+ XCTFail ( " Expected int value for http.status_code " )
221
+ return
222
+ }
223
+ XCTAssertEqual ( statusCode, 418 )
224
+ XCTAssertEqual ( attributes. get ( " http.status_code " ) , SpanAttribute . int32 ( 418 ) )
225
+ }
193
226
}
194
227
195
228
// ==== ----------------------------------------------------------------------------------------------------------------
0 commit comments