Skip to content

Commit 7a89c90

Browse files
authored
Use dependency-free Baggage module (#52)
1 parent df632ad commit 7a89c90

File tree

81 files changed

+527
-1757
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+527
-1757
lines changed

.swiftformat

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# file options
22

3-
--swiftversion 5.0
3+
--swiftversion 5.2
44
--exclude .build
55
--exclude Tests/LinuxMain.swift
66
--exclude **/*Tests+XCTest.swift
@@ -12,6 +12,7 @@
1212
--self insert
1313
--stripunusedargs closure-only
1414
--wraparguments before-first
15+
--extensionacl on-declarations
1516

1617
# rules
1718

IntegrationTests/allocation-counter-tests-framework/run-allocation-counter.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
##
44
## This source file is part of the Swift Distributed Tracing open source project
55
##
6-
## Copyright (c) 2020 Apple Inc. and the Swift Distributed Tracing project authors
6+
## Copyright (c) 2020-2021 Apple Inc. and the Swift Distributed Tracing project
7+
## authors
78
## Licensed under Apache License v2.0
89
##
910
## See LICENSE.txt for license information

IntegrationTests/allocation-counter-tests-framework/template/AtomicCounter/Sources/AtomicCounter/include/atomic-counter.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
//
33
// This source file is part of the Swift Distributed Tracing open source project
44
//
5-
// Copyright (c) 2020 Apple Inc. and the Swift Distributed Tracing project authors
5+
// Copyright (c) 2020-2021 Apple Inc. and the Swift Distributed Tracing project
6+
// authors
67
// Licensed under Apache License v2.0
78
//
89
// See LICENSE.txt for license information

IntegrationTests/allocation-counter-tests-framework/template/AtomicCounter/Sources/AtomicCounter/src/atomic-counter.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
//
33
// This source file is part of the Swift Distributed Tracing open source project
44
//
5-
// Copyright (c) 2020 Apple Inc. and the Swift Distributed Tracing project authors
5+
// Copyright (c) 2020-2021 Apple Inc. and the Swift Distributed Tracing project
6+
// authors
67
// Licensed under Apache License v2.0
78
//
89
// See LICENSE.txt for license information

IntegrationTests/allocation-counter-tests-framework/template/HookedFunctionsDoHook/Sources/HookedFunctions/include/hooked-functions.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
//
33
// This source file is part of the Swift Distributed Tracing open source project
44
//
5-
// Copyright (c) 2020 Apple Inc. and the Swift Distributed Tracing project authors
5+
// Copyright (c) 2020-2021 Apple Inc. and the Swift Distributed Tracing project
6+
// authors
67
// Licensed under Apache License v2.0
78
//
89
// See LICENSE.txt for license information

IntegrationTests/allocation-counter-tests-framework/template/HookedFunctionsDoHook/Sources/HookedFunctions/src/hooked-functions.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
//
33
// This source file is part of the Swift Distributed Tracing open source project
44
//
5-
// Copyright (c) 2020 Apple Inc. and the Swift Distributed Tracing project authors
5+
// Copyright (c) 2020-2021 Apple Inc. and the Swift Distributed Tracing project
6+
// authors
67
// Licensed under Apache License v2.0
78
//
89
// See LICENSE.txt for license information

IntegrationTests/allocation-counter-tests-framework/template/HookedFunctionsDoNotHook/Sources/HookedFunctions/include/hooked-functions.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
//
33
// This source file is part of the Swift Distributed Tracing open source project
44
//
5-
// Copyright (c) 2020 Apple Inc. and the Swift Distributed Tracing project authors
5+
// Copyright (c) 2020-2021 Apple Inc. and the Swift Distributed Tracing project
6+
// authors
67
// Licensed under Apache License v2.0
78
//
89
// See LICENSE.txt for license information

IntegrationTests/allocation-counter-tests-framework/template/HookedFunctionsDoNotHook/Sources/HookedFunctions/src/hooked-functions.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
//
33
// This source file is part of the Swift Distributed Tracing open source project
44
//
5-
// Copyright (c) 2020 Apple Inc. and the Swift Distributed Tracing project authors
5+
// Copyright (c) 2020-2021 Apple Inc. and the Swift Distributed Tracing project
6+
// authors
67
// Licensed under Apache License v2.0
78
//
89
// See LICENSE.txt for license information

IntegrationTests/allocation-counter-tests-framework/template/Sources/bootstrapDoHook/main.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
//
33
// This source file is part of the Swift Distributed Tracing open source project
44
//
5-
// Copyright (c) 2020 Apple Inc. and the Swift Distributed Tracing project authors
5+
// Copyright (c) 2020-2021 Apple Inc. and the Swift Distributed Tracing project
6+
// authors
67
// Licensed under Apache License v2.0
78
//
89
// See LICENSE.txt for license information

IntegrationTests/allocation-counter-tests-framework/template/Sources/bootstrapDoNotHook/main.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
//
33
// This source file is part of the Swift Distributed Tracing open source project
44
//
5-
// Copyright (c) 2020 Apple Inc. and the Swift Distributed Tracing project authors
5+
// Copyright (c) 2020-2021 Apple Inc. and the Swift Distributed Tracing project
6+
// authors
67
// Licensed under Apache License v2.0
78
//
89
// See LICENSE.txt for license information

IntegrationTests/allocation-counter-tests-framework/template/scaffolding.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
//
33
// This source file is part of the Swift Distributed Tracing open source project
44
//
5-
// Copyright (c) 2020 Apple Inc. and the Swift Distributed Tracing project authors
5+
// Copyright (c) 2020-2021 Apple Inc. and the Swift Distributed Tracing project
6+
// authors
67
// Licensed under Apache License v2.0
78
//
89
// See LICENSE.txt for license information

IntegrationTests/plugin_echo.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
##
44
## This source file is part of the Swift Distributed Tracing open source project
55
##
6-
## Copyright (c) 2020 Apple Inc. and the Swift Distributed Tracing project authors
6+
## Copyright (c) 2020-2021 Apple Inc. and the Swift Distributed Tracing project
7+
## authors
78
## Licensed under Apache License v2.0
89
##
910
## See LICENSE.txt for license information

IntegrationTests/plugin_junit_xml.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
##
44
## This source file is part of the Swift Distributed Tracing open source project
55
##
6-
## Copyright (c) 2020 Apple Inc. and the Swift Distributed Tracing project authors
6+
## Copyright (c) 2020-2021 Apple Inc. and the Swift Distributed Tracing project
7+
## authors
78
## Licensed under Apache License v2.0
89
##
910
## See LICENSE.txt for license information

IntegrationTests/run-single-test.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
##
44
## This source file is part of the Swift Distributed Tracing open source project
55
##
6-
## Copyright (c) 2020 Apple Inc. and the Swift Distributed Tracing project authors
6+
## Copyright (c) 2020-2021 Apple Inc. and the Swift Distributed Tracing project
7+
## authors
78
## Licensed under Apache License v2.0
89
##
910
## See LICENSE.txt for license information

IntegrationTests/run-tests.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
##
44
## This source file is part of the Swift Distributed Tracing open source project
55
##
6-
## Copyright (c) 2020 Apple Inc. and the Swift Distributed Tracing project authors
6+
## Copyright (c) 2020-2021 Apple Inc. and the Swift Distributed Tracing project
7+
## authors
78
## Licensed under Apache License v2.0
89
##
910
## See LICENSE.txt for license information

IntegrationTests/test_functions.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
##
44
## This source file is part of the Swift Distributed Tracing open source project
55
##
6-
## Copyright (c) 2020 Apple Inc. and the Swift Distributed Tracing project authors
6+
## Copyright (c) 2020-2021 Apple Inc. and the Swift Distributed Tracing project
7+
## authors
78
## Licensed under Apache License v2.0
89
##
910
## See LICENSE.txt for license information

IntegrationTests/tests_01_performance/defines.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
##
44
## This source file is part of the Swift Distributed Tracing open source project
55
##
6-
## Copyright (c) 2020 Apple Inc. and the Swift Distributed Tracing project authors
6+
## Copyright (c) 2020-2021 Apple Inc. and the Swift Distributed Tracing project
7+
## authors
78
## Licensed under Apache License v2.0
89
##
910
## See LICENSE.txt for license information

IntegrationTests/tests_01_performance/test_01_allocation_counts.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
##
44
## This source file is part of the Swift Distributed Tracing open source project
55
##
6-
## Copyright (c) 2020 Apple Inc. and the Swift Distributed Tracing project authors
6+
## Copyright (c) 2020-2021 Apple Inc. and the Swift Distributed Tracing project
7+
## authors
78
## Licensed under Apache License v2.0
89
##
910
## See LICENSE.txt for license information

IntegrationTests/tests_01_performance/test_01_resources/run-nio-alloc-counter-tests.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
##
44
## This source file is part of the Swift Distributed Tracing open source project
55
##
6-
## Copyright (c) 2020 Apple Inc. and the Swift Distributed Tracing project authors
6+
## Copyright (c) 2020-2021 Apple Inc. and the Swift Distributed Tracing project
7+
## authors
78
## Licensed under Apache License v2.0
89
##
910
## See LICENSE.txt for license information

IntegrationTests/tests_01_performance/test_01_resources/shared.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
//
33
// This source file is part of the Swift Distributed Tracing open source project
44
//
5-
// Copyright (c) 2020 Apple Inc. and the Swift Distributed Tracing project authors
5+
// Copyright (c) 2020-2021 Apple Inc. and the Swift Distributed Tracing project
6+
// authors
67
// Licensed under Apache License v2.0
78
//
89
// See LICENSE.txt for license information
@@ -25,8 +26,8 @@
2526
//
2627
//===----------------------------------------------------------------------===//
2728

28-
import Baggage
2929
import Foundation
30+
import InstrumentationBaggage
3031

3132
@inline(never)
3233
func take1(context: BaggageContext) -> Int {

IntegrationTests/tests_01_performance/test_01_resources/test_001_pass_around_static_strings_small.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
//
33
// This source file is part of the Swift Distributed Tracing open source project
44
//
5-
// Copyright (c) 2020 Apple Inc. and the Swift Distributed Tracing project authors
5+
// Copyright (c) 2020-2021 Apple Inc. and the Swift Distributed Tracing project
6+
// authors
67
// Licensed under Apache License v2.0
78
//
89
// See LICENSE.txt for license information
@@ -25,7 +26,7 @@
2526
//
2627
//===----------------------------------------------------------------------===//
2728

28-
import Baggage
29+
import InstrumentationBaggage
2930

3031
func run(identifier: String) {
3132
measure(identifier: identifier) {

IntegrationTests/tests_01_performance/test_01_resources/test_002_pass_around_static_strings_large.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
//
33
// This source file is part of the Swift Distributed Tracing open source project
44
//
5-
// Copyright (c) 2020 Apple Inc. and the Swift Distributed Tracing project authors
5+
// Copyright (c) 2020-2021 Apple Inc. and the Swift Distributed Tracing project
6+
// authors
67
// Licensed under Apache License v2.0
78
//
89
// See LICENSE.txt for license information
@@ -25,7 +26,7 @@
2526
//
2627
//===----------------------------------------------------------------------===//
2728

28-
import Baggage
29+
import InstrumentationBaggage
2930

3031
func run(identifier: String) {
3132
measure(identifier: identifier) {

Package.swift

+9-27
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
// swift-tools-version:5.0
1+
// swift-tools-version:5.2
22
import PackageDescription
33

44
let package = Package(
55
name: "swift-distributed-tracing",
66
products: [
77
.library(name: "Instrumentation", targets: ["Instrumentation"]),
88
.library(name: "Tracing", targets: ["Tracing"]),
9-
.library(name: "TracingOpenTelemetrySupport", targets: ["TracingOpenTelemetrySupport"]),
109
],
1110
dependencies: [
12-
.package(url: "https://github.com/apple/swift-distributed-tracing-baggage.git", from: "0.1.1")
11+
.package(url: "https://github.com/apple/swift-distributed-tracing-baggage.git", .upToNextMinor(from: "0.2.0")),
1312
],
1413
targets: [
1514
// ==== --------------------------------------------------------------------------------------------------------
@@ -18,13 +17,13 @@ let package = Package(
1817
.target(
1918
name: "Instrumentation",
2019
dependencies: [
21-
"Baggage",
20+
.product(name: "InstrumentationBaggage", package: "swift-distributed-tracing-baggage"),
2221
]
2322
),
2423
.testTarget(
2524
name: "InstrumentationTests",
2625
dependencies: [
27-
"Instrumentation",
26+
.target(name: "Instrumentation"),
2827
]
2928
),
3029

@@ -34,29 +33,13 @@ let package = Package(
3433
.target(
3534
name: "Tracing",
3635
dependencies: [
37-
"Instrumentation",
36+
.target(name: "Instrumentation"),
3837
]
3938
),
4039
.testTarget(
4140
name: "TracingTests",
4241
dependencies: [
43-
"Tracing",
44-
]
45-
),
46-
47-
// ==== ----------------------------------------------------------------------------------------------------------------
48-
// MARK: Support libraries
49-
50-
.target(
51-
name: "TracingOpenTelemetrySupport",
52-
dependencies: [
53-
"Tracing"
54-
]
55-
),
56-
.testTarget(
57-
name: "TracingOpenTelemetrySupportTests",
58-
dependencies: [
59-
"TracingOpenTelemetrySupport",
42+
.target(name: "Tracing"),
6043
]
6144
),
6245

@@ -66,10 +49,9 @@ let package = Package(
6649
.target(
6750
name: "_TracingBenchmarks",
6851
dependencies: [
69-
"Baggage",
70-
"Tracing",
71-
"TracingOpenTelemetrySupport",
72-
"_TracingBenchmarkTools",
52+
.product(name: "InstrumentationBaggage", package: "swift-distributed-tracing-baggage"),
53+
.target(name: "Tracing"),
54+
.target(name: "_TracingBenchmarkTools"),
7355
]
7456
),
7557
.target(

README.md

+3-18
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,9 @@ While Swift Distributed Tracing allows building all kinds of _instruments_, whic
99

1010
---
1111

12-
This project uses the context progagation types defined independently in:
12+
This project uses the context progagation type defined independently in:
1313

14-
- 🧳 [swift-distributed-tracing-baggage](https://github.com/apple/swift-distributed-tracing-baggage) -- [`LoggingContext`](https://apple.github.io/swift-distributed-tracing-baggage/docs/current/Baggage/Protocols/LoggingContext.html) (Swift Log dependency)
15-
- 🧳 [swift-distributed-tracing-baggage-core](https://github.com/apple/swift-distributed-tracing-baggage-core) -- defining [`Baggage`](https://apple.github.io/swift-distributed-tracing-baggage-core/docs/current/CoreBaggage/Structs/Baggage.html) (zero dependencies)
16-
17-
---
18-
19-
### Important note on Adoption
20-
21-
> ⚠️ ⚠️ ⚠️
22-
>
23-
> We anticipate the upcoming [Swift Concurrency](https://forums.swift.org/t/swift-concurrency-roadmap/41611) features to have significant impact on the usage of these APIs, if task-local values **(proposal coming soon)** are accepted into the language.
24-
>
25-
> As such, we advice to adopt these APIs carefully, and offer them _optionally_, i.e. provide defaulted values for context parameters such that users do not necessarily have to use them – because the upcoming Swift Concurrency story should enable APIs to gain automatic context propagation using task locals (if the proposal were to be accepted).
26-
>
27-
> At this point in time we would like to focus on Tracer implementations, final API polish and adoption in "glue" libraries between services, such as AsyncHTTPClient, gRPC and similar APIs.
28-
>
29-
> ⚠️ ⚠️ ⚠️
14+
- 🧳 [swift-distributed-tracing-baggage](https://github.com/apple/swift-distributed-tracing-baggage) -- [`Baggage`](https://apple.github.io/swift-distributed-tracing-baggage/docs/current/InstrumentationBaggage/Structs/Baggage.html) (zero dependencies)
3015

3116
---
3217

@@ -579,7 +564,7 @@ When creating a tracer you need to create two types:
579564
```swift
580565
import Tracing
581566

582-
private enum TraceIDKey: Baggage.Key {
567+
private enum TraceIDKey: BaggageKey {
583568
typealias Value = String
584569
}
585570

Sources/Instrumentation/Instrument.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
//
33
// This source file is part of the Swift Distributed Tracing open source project
44
//
5-
// Copyright (c) 2020 Apple Inc. and the Swift Distributed Tracing project authors
5+
// Copyright (c) 2020-2021 Apple Inc. and the Swift Distributed Tracing project
6+
// authors
67
// Licensed under Apache License v2.0
78
//
89
// See LICENSE.txt for license information
@@ -11,7 +12,7 @@
1112
//
1213
//===----------------------------------------------------------------------===//
1314

14-
import CoreBaggage
15+
import InstrumentationBaggage
1516

1617
/// Conforming types are used to extract values from a specific `Carrier`.
1718
public protocol Extractor {

0 commit comments

Comments
 (0)