Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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.0
--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.0
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"),
]
),
]
)
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"),
]
),
]
)
17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
# 🧳 Distributed Tracing: Baggage

[![Swift 5.0](https://img.shields.io/badge/Swift-5.0-ED523F.svg?style=flat)](https://swift.org/download/)
[![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.6-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 +25,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 +38,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
8 changes: 4 additions & 4 deletions Sources/InstrumentationBaggage/Baggage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ extension Baggage {
/// not being sure where to obtain a baggage from, or other framework limitations -- e.g. the outer framework not being
/// baggage aware just yet.
public static var topLevel: Baggage {
Baggage()
return Baggage()
}
}

Expand Down Expand Up @@ -150,7 +150,7 @@ extension Baggage {
private enum TODOKey: BaggageKey {
typealias Value = TODOLocation
static var nameOverride: String? {
"todo"
return "todo"
}
}
}
Expand Down Expand Up @@ -207,12 +207,12 @@ extension Baggage {
extension Baggage {
/// The number of items in the baggage.
public var count: Int {
self._storage.count
return self._storage.count
}

/// A Boolean value that indicates whether the baggage is empty.
public var isEmpty: Bool {
self._storage.isEmpty
return self._storage.isEmpty
}

/// Iterate through all items in this `Baggage` by invoking the given closure for each item.
Expand Down
6 changes: 3 additions & 3 deletions Sources/InstrumentationBaggage/BaggageKey.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public protocol BaggageKey: _Baggage_Sendable {
}

extension BaggageKey {
public static var nameOverride: String? { nil }
public static var nameOverride: String? { return nil }
}

/// A type-erased ``BaggageKey`` used when iterating through the ``Baggage`` using its `forEach` method.
Expand All @@ -71,7 +71,7 @@ public struct AnyBaggageKey: _Baggage_Sendable {
/// A human-readable String representation of the underlying key.
/// If no explicit name has been set on the wrapped key the type name is used.
public var name: String {
self._nameOverride ?? String(describing: self.keyType.self)
return self._nameOverride ?? String(describing: self.keyType.self)
}

init<Key: BaggageKey>(_ keyType: Key.Type) {
Expand All @@ -82,7 +82,7 @@ public struct AnyBaggageKey: _Baggage_Sendable {

extension AnyBaggageKey: Hashable {
public static func == (lhs: AnyBaggageKey, rhs: AnyBaggageKey) -> Bool {
ObjectIdentifier(lhs.keyType) == ObjectIdentifier(rhs.keyType)
return ObjectIdentifier(lhs.keyType) == ObjectIdentifier(rhs.keyType)
}

public func hash(into hasher: inout Hasher) {
Expand Down
16 changes: 16 additions & 0 deletions docker/docker-compose.1804.50.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.0
build:
args:
ubuntu_version: "bionic"
swift_version: "5.0"

test:
image: swift-distributed-tracing-baggage:18.04-5.0

shell:
image: swift-distributed-tracing-baggage:18.04-5.0
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