File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed
Sources/Instrumentation/Tracing
Tests/InstrumentationTests Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -137,6 +137,12 @@ extension SpanAttribute: ExpressibleByStringLiteral {
137
137
}
138
138
}
139
139
140
+ extension SpanAttribute : ExpressibleByStringInterpolation {
141
+ public init ( stringInterpolation value: Self . StringInterpolation ) {
142
+ self = . string( " \( value) " )
143
+ }
144
+ }
145
+
140
146
extension SpanAttribute : ExpressibleByIntegerLiteral {
141
147
public init ( integerLiteral value: Int ) {
142
148
self = . int( value)
Original file line number Diff line number Diff line change @@ -48,6 +48,15 @@ final class SpanTests: XCTestCase {
48
48
XCTAssertEqual ( stringValue, " test " )
49
49
}
50
50
51
+ func testSpanAttributeIsExpressibleByStringInterpolation( ) {
52
+ let stringAttribute : SpanAttribute = " test \( true ) \( 42 ) \( 3.14 ) "
53
+ guard case . string( let stringValue) = stringAttribute else {
54
+ XCTFail ( " Expected string attribute, got \( stringAttribute) . " )
55
+ return
56
+ }
57
+ XCTAssertEqual ( stringValue, " test true 42 3.14 " )
58
+ }
59
+
51
60
func testSpanAttributeIsExpressibleByIntegerLiteral( ) {
52
61
let intAttribute : SpanAttribute = 42
53
62
guard case . int( let intValue) = intAttribute else {
You can’t perform that action at this time.
0 commit comments