diff --git a/.swiftformat b/.swiftformat index 31c526c..0547446 100644 --- a/.swiftformat +++ b/.swiftformat @@ -1,6 +1,6 @@ # file options ---swiftversion 5.2 +--swiftversion 5.1 --exclude .build --exclude UseCases/.build --exclude Tests/LinuxMain.swift diff --git a/Package@swift-5.1.swift b/Package@swift-5.1.swift new file mode 100644 index 0000000..1fb07c3 --- /dev/null +++ b/Package@swift-5.1.swift @@ -0,0 +1,27 @@ +// swift-tools-version:5.1 +import PackageDescription + +let package = Package( + name: "swift-distributed-tracing-baggage", + products: [ + .library( + name: "InstrumentationBaggage", + targets: [ + "InstrumentationBaggage", + ] + ), + ], + targets: [ + .target(name: "InstrumentationBaggage"), + + // ==== -------------------------------------------------------------------------------------------------------- + // MARK: Tests + + .testTarget( + name: "InstrumentationBaggageTests", + dependencies: [ + .target(name: "InstrumentationBaggage"), + ] + ), + ] +) diff --git a/README.md b/README.md index 4cdafca..78cddcb 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,20 @@ # 🧳 Distributed Tracing: Baggage +[![Swift 5.1](https://img.shields.io/badge/Swift-5.1-ED523F.svg?style=flat)](https://swift.org/download/) [![Swift 5.2](https://img.shields.io/badge/Swift-5.2-ED523F.svg?style=flat)](https://swift.org/download/) [![Swift 5.3](https://img.shields.io/badge/Swift-5.3-ED523F.svg?style=flat)](https://swift.org/download/) [![Swift 5.4](https://img.shields.io/badge/Swift-5.4-ED523F.svg?style=flat)](https://swift.org/download/) [![Swift 5.5](https://img.shields.io/badge/Swift-5.5-ED523F.svg?style=flat)](https://swift.org/download/) +[![Swift 5.6](https://img.shields.io/badge/Swift-5.6-ED523F.svg?style=flat)](https://swift.org/download/) +[![Swift 5.7](https://img.shields.io/badge/Swift-5.7-ED523F.svg?style=flat)](https://swift.org/download/) -> ⚠️ Automatic propagation through task-locals only supported in Swift >= 5.5 +> **Warning** +> Automatic propagation through task-locals only supported in Swift >= 5.5 `Baggage` is a minimal (zero-dependency) context propagation container, intended to "carry" baggage items for purposes of cross-cutting tools to be built on top of it. -It is modeled after the concepts explained in [W3C Baggage](https://w3c.github.io/baggage/) and the +It is modeled after the concepts explained in [W3C Baggage](https://w3c.github.io/baggage/) and the in the spirit of [Tracing Plane](https://cs.brown.edu/~jcmace/papers/mace18universal.pdf) 's "Baggage Context" type, although by itself it does not define a specific serialization format. @@ -20,7 +24,7 @@ deploy various cross-cutting instruments all reusing the same baggage type. More ## Dependency - In order to depend on this library you can use the Swift Package Manager, and add the following dependency to your `Package.swift`: +In order to depend on this library you can use the Swift Package Manager, and add the following dependency to your `Package.swift`: ```swift dependencies: [ @@ -33,18 +37,18 @@ dependencies: [ and depend on the module in your target: -```swift +```swift targets: [ .target( name: "MyAwesomeApp", dependencies: [ .product( - name: "InstrumentationBaggage", + name: "InstrumentationBaggage", package: "swift-distributed-tracing-baggage" ), ] ), - // ... + // ... ] ``` diff --git a/Tests/InstrumentationBaggageTests/BaggageTests.swift b/Tests/InstrumentationBaggageTests/BaggageTests.swift index 835bfa3..0848bba 100644 --- a/Tests/InstrumentationBaggageTests/BaggageTests.swift +++ b/Tests/InstrumentationBaggageTests/BaggageTests.swift @@ -63,7 +63,7 @@ final class BaggageTests: XCTestCase { } func test_automaticPropagationThroughTaskLocal() throws { - #if swift(>=5.5) && canImport(_Concurrency) + #if compiler(>=5.5) guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip("Task locals are not supported on this platform.") } @@ -78,7 +78,8 @@ final class BaggageTests: XCTestCase { propagatedBaggage = Baggage.current } - Baggage.$current.withValue(baggage, operation: exampleFunction) + let c = Baggage.$current + c.withValue(baggage, operation: exampleFunction) XCTAssertEqual(propagatedBaggage?.count, 1) XCTAssertEqual(propagatedBaggage?[FirstTestKey.self], 42) diff --git a/docker/docker-compose.1804.51.yaml b/docker/docker-compose.1804.51.yaml new file mode 100644 index 0000000..9f9aded --- /dev/null +++ b/docker/docker-compose.1804.51.yaml @@ -0,0 +1,16 @@ +version: "3" + +services: + + runtime-setup: + image: swift-distributed-tracing-baggage:18.04-5.1 + build: + args: + ubuntu_version: "bionic" + swift_version: "5.1" + + test: + image: swift-distributed-tracing-baggage:18.04-5.1 + + shell: + image: swift-distributed-tracing-baggage:18.04-5.1