Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .swiftformat
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# file options

--swiftversion 5.2
--swiftversion 5.1
--exclude .build
--exclude UseCases/.build
--exclude Tests/LinuxMain.swift
Expand Down
27 changes: 27 additions & 0 deletions [email protected]
Original file line number Diff line number Diff line change
@@ -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"),
]
),
]
)
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -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: [
Expand All @@ -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"
),
]
),
// ...
// ...
]
```

Expand Down
5 changes: 3 additions & 2 deletions Tests/InstrumentationBaggageTests/BaggageTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
}
Expand All @@ -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)
Expand Down
16 changes: 16 additions & 0 deletions docker/docker-compose.1804.51.yaml
Original file line number Diff line number Diff line change
@@ -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