Skip to content

Commit bc0d3c1

Browse files
committed
formatting
1 parent 598d900 commit bc0d3c1

File tree

7 files changed

+52
-56
lines changed

7 files changed

+52
-56
lines changed

Docs/SwiftDistributedTracing/empty.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616
// This module is left purposefully empty of any source files, as it serves
1717
// only as a "landing page" for the documentation. This is in-place until docc
1818
// gains the ability to support package-wide documentation.
19-
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //
19+
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //

Package.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ let package = Package(
1414
.library(name: "Tracing", targets: ["Tracing"]),
1515
],
1616
dependencies: [
17-
// .package(url: "https://github.com/apple/swift-service-context.git", from: "1.0.0"),
17+
// .package(url: "https://github.com/apple/swift-service-context.git", from: "1.0.0"),
1818
.package(url: "https://github.com/apple/swift-service-context.git", branch: "main"),
1919
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"),
2020
],

Samples/Dinner/Sources/Onboarding/Clock+Extensions.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@
2525
//===----------------------------------------------------------------------===//
2626

2727
func sleep(for duration: ContinuousClock.Duration) async {
28-
try? await Task.sleep(until: ContinuousClock.now + duration, clock: .continuous)
29-
}
28+
try? await Task.sleep(until: ContinuousClock.now + duration, clock: .continuous)
29+
}

Samples/Dinner/Sources/Onboarding/Dinner.swift

+42-43
Original file line numberDiff line numberDiff line change
@@ -24,67 +24,66 @@
2424
//
2525
//===----------------------------------------------------------------------===//
2626

27-
2827
import Tracing
2928

3029
func makeDinner() async throws -> Meal {
31-
try await InstrumentationSystem.tracer.withSpan("makeDinner") { _ in
32-
await sleep(for: .milliseconds(200))
30+
try await InstrumentationSystem.tracer.withSpan("makeDinner") { _ in
31+
await sleep(for: .milliseconds(200))
3332

34-
async let veggies = try chopVegetables()
35-
async let meat = marinateMeat()
36-
async let oven = preheatOven(temperature: 350)
37-
// ...
38-
return try await cook(veggies, meat, oven)
39-
}
33+
async let veggies = try chopVegetables()
34+
async let meat = marinateMeat()
35+
async let oven = preheatOven(temperature: 350)
36+
// ...
37+
return try await cook(veggies, meat, oven)
38+
}
4039
}
4140

4241
func chopVegetables() async throws -> [Vegetable] {
43-
try await otelChopping1.tracer().withSpan("chopVegetables") { _ in
44-
// Chop the vegetables...!
45-
//
46-
// However, since chopping is a very difficult operation,
47-
// one chopping task can be performed at the same time on a single service!
48-
// (Imagine that... we cannot parallelize these two tasks, and need to involve another service).
49-
async let carrot = try chop(.carrot, tracer: otelChopping1.tracer())
50-
async let potato = try chop(.potato, tracer: otelChopping2.tracer())
51-
return try await [carrot, potato]
52-
}
42+
try await otelChopping1.tracer().withSpan("chopVegetables") { _ in
43+
// Chop the vegetables...!
44+
//
45+
// However, since chopping is a very difficult operation,
46+
// one chopping task can be performed at the same time on a single service!
47+
// (Imagine that... we cannot parallelize these two tasks, and need to involve another service).
48+
async let carrot = try chop(.carrot, tracer: otelChopping1.tracer())
49+
async let potato = try chop(.potato, tracer: otelChopping2.tracer())
50+
return try await [carrot, potato]
51+
}
5352
}
5453

5554
func chop(_ vegetable: Vegetable, tracer: any Tracer) async throws -> Vegetable {
56-
await tracer.withSpan("chop-\(vegetable)") { _ in
57-
await sleep(for: .seconds(5))
58-
// ...
59-
return vegetable // "chopped"
60-
}
55+
await tracer.withSpan("chop-\(vegetable)") { _ in
56+
await sleep(for: .seconds(5))
57+
// ...
58+
return vegetable // "chopped"
59+
}
6160
}
6261

6362
func marinateMeat() async -> Meat {
64-
await sleep(for: .milliseconds(620))
63+
await sleep(for: .milliseconds(620))
6564

66-
return await InstrumentationSystem.tracer.withSpan("marinateMeat") { _ in
67-
await sleep(for: .seconds(3))
68-
// ...
69-
return Meat()
70-
}
65+
return await InstrumentationSystem.tracer.withSpan("marinateMeat") { _ in
66+
await sleep(for: .seconds(3))
67+
// ...
68+
return Meat()
69+
}
7170
}
7271

7372
func preheatOven(temperature: Int) async -> Oven {
74-
await InstrumentationSystem.tracer.withSpan("preheatOven") { _ in
75-
// ...
76-
await sleep(for: .seconds(6))
77-
return Oven()
78-
}
73+
await InstrumentationSystem.tracer.withSpan("preheatOven") { _ in
74+
// ...
75+
await sleep(for: .seconds(6))
76+
return Oven()
77+
}
7978
}
8079

8180
func cook(_: Any, _: Any, _: Any) async -> Meal {
82-
await InstrumentationSystem.tracer.withSpan("cook") { span in
83-
span.addEvent("children-asking-if-done-already")
84-
await sleep(for: .seconds(3))
85-
span.addEvent("children-asking-if-done-already-again")
86-
await sleep(for: .seconds(2))
87-
// ...
88-
return Meal()
89-
}
81+
await InstrumentationSystem.tracer.withSpan("cook") { span in
82+
span.addEvent("children-asking-if-done-already")
83+
await sleep(for: .seconds(3))
84+
span.addEvent("children-asking-if-done-already-again")
85+
await sleep(for: .seconds(2))
86+
// ...
87+
return Meal()
88+
}
9089
}

Samples/Dinner/Sources/Onboarding/Model.swift

+2-4
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,10 @@
2424
//
2525
//===----------------------------------------------------------------------===//
2626

27-
2827
struct Meal: Sendable {}
2928
struct Meat: Sendable {}
3029
struct Oven: Sendable {}
3130
enum Vegetable: Sendable {
32-
case potato
33-
case carrot
31+
case potato
32+
case carrot
3433
}
35-

Samples/Dinner/Sources/Onboarding/main.swift

+3-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
//
2525
//===----------------------------------------------------------------------===//
2626

27-
2827
import Logging
2928
import NIO
3029
import OpenTelemetry
@@ -36,9 +35,9 @@ import Tracing
3635
let group = MultiThreadedEventLoopGroup(numberOfThreads: 1)
3736

3837
LoggingSystem.bootstrap { label in
39-
var handler = StreamLogHandler.standardOutput(label: label)
40-
handler.logLevel = .trace
41-
return handler
38+
var handler = StreamLogHandler.standardOutput(label: label)
39+
handler.logLevel = .trace
40+
return handler
4241
}
4342

4443
// ==== ----------------------------------------------------------------------------------------------------------------

Tests/TracingTests/TracedLockTests.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414

1515
@testable import Instrumentation
1616
import ServiceContextModule
17+
import SwiftUI
1718
import Tracing
1819
import XCTest
19-
import SwiftUI
2020

2121
final class TracedLockTests: XCTestCase {
2222
override class func tearDown() {

0 commit comments

Comments
 (0)