Skip to content

Commit

Permalink
Use dependency-free Baggage module (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
slashmo authored Aug 24, 2021
1 parent df632ad commit 7a89c90
Show file tree
Hide file tree
Showing 81 changed files with 527 additions and 1,757 deletions.
3 changes: 2 additions & 1 deletion .swiftformat
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# file options

--swiftversion 5.0
--swiftversion 5.2
--exclude .build
--exclude Tests/LinuxMain.swift
--exclude **/*Tests+XCTest.swift
Expand All @@ -12,6 +12,7 @@
--self insert
--stripunusedargs closure-only
--wraparguments before-first
--extensionacl on-declarations

# rules

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
##
## This source file is part of the Swift Distributed Tracing open source project
##
## Copyright (c) 2020 Apple Inc. and the Swift Distributed Tracing project authors
## Copyright (c) 2020-2021 Apple Inc. and the Swift Distributed Tracing project
## authors
## Licensed under Apache License v2.0
##
## See LICENSE.txt for license information
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
//
// This source file is part of the Swift Distributed Tracing open source project
//
// Copyright (c) 2020 Apple Inc. and the Swift Distributed Tracing project authors
// Copyright (c) 2020-2021 Apple Inc. and the Swift Distributed Tracing project
// authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
//
// This source file is part of the Swift Distributed Tracing open source project
//
// Copyright (c) 2020 Apple Inc. and the Swift Distributed Tracing project authors
// Copyright (c) 2020-2021 Apple Inc. and the Swift Distributed Tracing project
// authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
//
// This source file is part of the Swift Distributed Tracing open source project
//
// Copyright (c) 2020 Apple Inc. and the Swift Distributed Tracing project authors
// Copyright (c) 2020-2021 Apple Inc. and the Swift Distributed Tracing project
// authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
//
// This source file is part of the Swift Distributed Tracing open source project
//
// Copyright (c) 2020 Apple Inc. and the Swift Distributed Tracing project authors
// Copyright (c) 2020-2021 Apple Inc. and the Swift Distributed Tracing project
// authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
//
// This source file is part of the Swift Distributed Tracing open source project
//
// Copyright (c) 2020 Apple Inc. and the Swift Distributed Tracing project authors
// Copyright (c) 2020-2021 Apple Inc. and the Swift Distributed Tracing project
// authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
//
// This source file is part of the Swift Distributed Tracing open source project
//
// Copyright (c) 2020 Apple Inc. and the Swift Distributed Tracing project authors
// Copyright (c) 2020-2021 Apple Inc. and the Swift Distributed Tracing project
// authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
//
// This source file is part of the Swift Distributed Tracing open source project
//
// Copyright (c) 2020 Apple Inc. and the Swift Distributed Tracing project authors
// Copyright (c) 2020-2021 Apple Inc. and the Swift Distributed Tracing project
// authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
//
// This source file is part of the Swift Distributed Tracing open source project
//
// Copyright (c) 2020 Apple Inc. and the Swift Distributed Tracing project authors
// Copyright (c) 2020-2021 Apple Inc. and the Swift Distributed Tracing project
// authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
//
// This source file is part of the Swift Distributed Tracing open source project
//
// Copyright (c) 2020 Apple Inc. and the Swift Distributed Tracing project authors
// Copyright (c) 2020-2021 Apple Inc. and the Swift Distributed Tracing project
// authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
Expand Down
3 changes: 2 additions & 1 deletion IntegrationTests/plugin_echo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
##
## This source file is part of the Swift Distributed Tracing open source project
##
## Copyright (c) 2020 Apple Inc. and the Swift Distributed Tracing project authors
## Copyright (c) 2020-2021 Apple Inc. and the Swift Distributed Tracing project
## authors
## Licensed under Apache License v2.0
##
## See LICENSE.txt for license information
Expand Down
3 changes: 2 additions & 1 deletion IntegrationTests/plugin_junit_xml.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
##
## This source file is part of the Swift Distributed Tracing open source project
##
## Copyright (c) 2020 Apple Inc. and the Swift Distributed Tracing project authors
## Copyright (c) 2020-2021 Apple Inc. and the Swift Distributed Tracing project
## authors
## Licensed under Apache License v2.0
##
## See LICENSE.txt for license information
Expand Down
3 changes: 2 additions & 1 deletion IntegrationTests/run-single-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
##
## This source file is part of the Swift Distributed Tracing open source project
##
## Copyright (c) 2020 Apple Inc. and the Swift Distributed Tracing project authors
## Copyright (c) 2020-2021 Apple Inc. and the Swift Distributed Tracing project
## authors
## Licensed under Apache License v2.0
##
## See LICENSE.txt for license information
Expand Down
3 changes: 2 additions & 1 deletion IntegrationTests/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
##
## This source file is part of the Swift Distributed Tracing open source project
##
## Copyright (c) 2020 Apple Inc. and the Swift Distributed Tracing project authors
## Copyright (c) 2020-2021 Apple Inc. and the Swift Distributed Tracing project
## authors
## Licensed under Apache License v2.0
##
## See LICENSE.txt for license information
Expand Down
3 changes: 2 additions & 1 deletion IntegrationTests/test_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
##
## This source file is part of the Swift Distributed Tracing open source project
##
## Copyright (c) 2020 Apple Inc. and the Swift Distributed Tracing project authors
## Copyright (c) 2020-2021 Apple Inc. and the Swift Distributed Tracing project
## authors
## Licensed under Apache License v2.0
##
## See LICENSE.txt for license information
Expand Down
3 changes: 2 additions & 1 deletion IntegrationTests/tests_01_performance/defines.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
##
## This source file is part of the Swift Distributed Tracing open source project
##
## Copyright (c) 2020 Apple Inc. and the Swift Distributed Tracing project authors
## Copyright (c) 2020-2021 Apple Inc. and the Swift Distributed Tracing project
## authors
## Licensed under Apache License v2.0
##
## See LICENSE.txt for license information
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
##
## This source file is part of the Swift Distributed Tracing open source project
##
## Copyright (c) 2020 Apple Inc. and the Swift Distributed Tracing project authors
## Copyright (c) 2020-2021 Apple Inc. and the Swift Distributed Tracing project
## authors
## Licensed under Apache License v2.0
##
## See LICENSE.txt for license information
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
##
## This source file is part of the Swift Distributed Tracing open source project
##
## Copyright (c) 2020 Apple Inc. and the Swift Distributed Tracing project authors
## Copyright (c) 2020-2021 Apple Inc. and the Swift Distributed Tracing project
## authors
## Licensed under Apache License v2.0
##
## See LICENSE.txt for license information
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
//
// This source file is part of the Swift Distributed Tracing open source project
//
// Copyright (c) 2020 Apple Inc. and the Swift Distributed Tracing project authors
// Copyright (c) 2020-2021 Apple Inc. and the Swift Distributed Tracing project
// authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
Expand All @@ -25,8 +26,8 @@
//
//===----------------------------------------------------------------------===//

import Baggage
import Foundation
import InstrumentationBaggage

@inline(never)
func take1(context: BaggageContext) -> Int {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
//
// This source file is part of the Swift Distributed Tracing open source project
//
// Copyright (c) 2020 Apple Inc. and the Swift Distributed Tracing project authors
// Copyright (c) 2020-2021 Apple Inc. and the Swift Distributed Tracing project
// authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
Expand All @@ -25,7 +26,7 @@
//
//===----------------------------------------------------------------------===//

import Baggage
import InstrumentationBaggage

func run(identifier: String) {
measure(identifier: identifier) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
//
// This source file is part of the Swift Distributed Tracing open source project
//
// Copyright (c) 2020 Apple Inc. and the Swift Distributed Tracing project authors
// Copyright (c) 2020-2021 Apple Inc. and the Swift Distributed Tracing project
// authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
Expand All @@ -25,7 +26,7 @@
//
//===----------------------------------------------------------------------===//

import Baggage
import InstrumentationBaggage

func run(identifier: String) {
measure(identifier: identifier) {
Expand Down
36 changes: 9 additions & 27 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
// swift-tools-version:5.0
// swift-tools-version:5.2
import PackageDescription

let package = Package(
name: "swift-distributed-tracing",
products: [
.library(name: "Instrumentation", targets: ["Instrumentation"]),
.library(name: "Tracing", targets: ["Tracing"]),
.library(name: "TracingOpenTelemetrySupport", targets: ["TracingOpenTelemetrySupport"]),
],
dependencies: [
.package(url: "https://github.com/apple/swift-distributed-tracing-baggage.git", from: "0.1.1")
.package(url: "https://github.com/apple/swift-distributed-tracing-baggage.git", .upToNextMinor(from: "0.2.0")),
],
targets: [
// ==== --------------------------------------------------------------------------------------------------------
Expand All @@ -18,13 +17,13 @@ let package = Package(
.target(
name: "Instrumentation",
dependencies: [
"Baggage",
.product(name: "InstrumentationBaggage", package: "swift-distributed-tracing-baggage"),
]
),
.testTarget(
name: "InstrumentationTests",
dependencies: [
"Instrumentation",
.target(name: "Instrumentation"),
]
),

Expand All @@ -34,29 +33,13 @@ let package = Package(
.target(
name: "Tracing",
dependencies: [
"Instrumentation",
.target(name: "Instrumentation"),
]
),
.testTarget(
name: "TracingTests",
dependencies: [
"Tracing",
]
),

// ==== ----------------------------------------------------------------------------------------------------------------
// MARK: Support libraries

.target(
name: "TracingOpenTelemetrySupport",
dependencies: [
"Tracing"
]
),
.testTarget(
name: "TracingOpenTelemetrySupportTests",
dependencies: [
"TracingOpenTelemetrySupport",
.target(name: "Tracing"),
]
),

Expand All @@ -66,10 +49,9 @@ let package = Package(
.target(
name: "_TracingBenchmarks",
dependencies: [
"Baggage",
"Tracing",
"TracingOpenTelemetrySupport",
"_TracingBenchmarkTools",
.product(name: "InstrumentationBaggage", package: "swift-distributed-tracing-baggage"),
.target(name: "Tracing"),
.target(name: "_TracingBenchmarkTools"),
]
),
.target(
Expand Down
21 changes: 3 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,9 @@ While Swift Distributed Tracing allows building all kinds of _instruments_, whic

---

This project uses the context progagation types defined independently in:
This project uses the context progagation type defined independently in:

- 🧳 [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)
- 🧳 [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)

---

### Important note on Adoption

> ⚠️ ⚠️ ⚠️
>
> 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.
>
> 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).
>
> 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.
>
> ⚠️ ⚠️ ⚠️
- 🧳 [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)

---

Expand Down Expand Up @@ -579,7 +564,7 @@ When creating a tracer you need to create two types:
```swift
import Tracing

private enum TraceIDKey: Baggage.Key {
private enum TraceIDKey: BaggageKey {
typealias Value = String
}

Expand Down
5 changes: 3 additions & 2 deletions Sources/Instrumentation/Instrument.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
//
// This source file is part of the Swift Distributed Tracing open source project
//
// Copyright (c) 2020 Apple Inc. and the Swift Distributed Tracing project authors
// Copyright (c) 2020-2021 Apple Inc. and the Swift Distributed Tracing project
// authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
Expand All @@ -11,7 +12,7 @@
//
//===----------------------------------------------------------------------===//

import CoreBaggage
import InstrumentationBaggage

/// Conforming types are used to extract values from a specific `Carrier`.
public protocol Extractor {
Expand Down
Loading

0 comments on commit 7a89c90

Please sign in to comment.