Skip to content

Commit d9459f2

Browse files
committed
renames, cleanups, preparing for api review
1 parent 8790e93 commit d9459f2

39 files changed

+192
-83
lines changed

Package.swift

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@ let package = Package(
66
products: [
77
.library(name: "Instrumentation", targets: ["Instrumentation"]),
88
.library(name: "Tracing", targets: ["Tracing"]),
9-
.library(name: "OpenTelemetryInstrumentationSupport", targets: ["OpenTelemetryInstrumentationSupport"]),
9+
.library(name: "TracingOpenTelemetrySupport", targets: ["TracingOpenTelemetrySupport"]),
1010
],
1111
dependencies: [
1212
.package(url: "https://github.com/apple/swift-distributed-tracing-baggage.git", from: "0.0.1"),
13-
.package(url: "https://github.com/apple/swift-distributed-tracing-baggage-core.git", from: "0.0.1"),
1413
],
1514
targets: [
1615
// ==== --------------------------------------------------------------------------------------------------------
@@ -49,30 +48,32 @@ let package = Package(
4948
// MARK: Support libraries
5049

5150
.target(
52-
name: "OpenTelemetryInstrumentationSupport",
51+
name: "TracingOpenTelemetrySupport",
5352
dependencies: [
5453
"Tracing"
5554
]
5655
),
5756
.testTarget(
58-
name: "OpenTelemetryInstrumentationSupportTests",
57+
name: "TracingOpenTelemetrySupportTests",
5958
dependencies: [
60-
"OpenTelemetryInstrumentationSupport",
59+
"TracingOpenTelemetrySupport",
6160
]
6261
),
6362

6463
// ==== --------------------------------------------------------------------------------------------------------
6564
// MARK: Performance / Benchmarks
6665

6766
.target(
68-
name: "TracingBenchmarks",
67+
name: "_TracingBenchmarks",
6968
dependencies: [
7069
"Baggage",
71-
"TracingBenchmarkTools",
70+
"Tracing",
71+
"TracingOpenTelemetrySupport",
72+
"_TracingBenchmarkTools",
7273
]
7374
),
7475
.target(
75-
name: "TracingBenchmarkTools",
76+
name: "_TracingBenchmarkTools",
7677
dependencies: []
7778
),
7879
]

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ func get(url: String, context: BaggageContextCarrier) {
218218
> Make sure that error cases also set the error attribute and end the span.
219219
220220
> In the above example we used the semantic `http.method` attribute that gets exposed via the
221-
`OpenTelemetryInstrumentationSupport` library.
221+
`TracingOpenTelemetrySupport` library.
222222

223223
## Instrument developers: Creating an instrument
224224

Sources/Instrumentation/Instrument.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//
1212
//===----------------------------------------------------------------------===//
1313

14-
import Baggage
14+
import CoreBaggage
1515

1616
/// Conforming types are used to extract values from a specific `Carrier`.
1717
public protocol ExtractorProtocol {

Sources/Tracing/InstrumentationSystem+Tracing.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//
1212
//===----------------------------------------------------------------------===//
1313

14-
import Instrumentation
14+
@_exported import Instrumentation
1515

1616
extension InstrumentationSystem {
1717
/// Get a `Tracer` instance of the given type.

Sources/Tracing/NoOpTracer.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
//
1212
//===----------------------------------------------------------------------===//
1313

14-
import Baggage
15-
import Instrumentation
14+
@_exported import Baggage
15+
@_exported import Instrumentation
1616

1717
/// No operation Tracer, used when no tracing is required.
1818
public struct NoOpTracer: Tracer {
1919
public func startSpan(
20-
named operationName: String,
20+
_ operationName: String,
2121
baggage: Baggage,
2222
ofKind kind: SpanKind,
2323
at timestamp: Timestamp

Sources/Tracing/Span.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//
1212
//===----------------------------------------------------------------------===//
1313

14-
import BaggageContext
14+
@_exported import Baggage
1515

1616
/// A `Span` type that follows the OpenTracing/OpenTelemetry spec. The span itself should not be
1717
/// initializable via its public interface. `Span` creation should instead go through `tracer.startSpan`
@@ -154,7 +154,7 @@ extension SpanAttributeNamespace {
154154

155155
public subscript<Namespace>(dynamicMember dynamicMember: KeyPath<SpanAttribute, Namespace>) -> Namespace
156156
where Namespace: SpanAttributeNamespace {
157-
SpanAttribute.__namespace[keyPath: dynamicMember]
157+
SpanAttribute.int(0)[keyPath: dynamicMember]
158158
}
159159
}
160160
#endif

Sources/Tracing/Tracer.swift

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
//
1212
//===----------------------------------------------------------------------===//
1313

14-
import Baggage
15-
import Instrumentation
14+
@_exported import Baggage
15+
@_exported import Instrumentation
1616

1717
/// An `Instrument` with added functionality for distributed tracing. Is uses the span-based tracing model and is
1818
/// based on the OpenTracing/OpenTelemetry spec.
@@ -25,7 +25,7 @@ public protocol Tracer: Instrument {
2525
/// - kind: The `SpanKind` of the new `Span`.
2626
/// - timestamp: The `DispatchTime` at which to start the new `Span`.
2727
func startSpan(
28-
named operationName: String,
28+
_ operationName: String,
2929
baggage: Baggage,
3030
ofKind kind: SpanKind,
3131
at timestamp: Timestamp
@@ -45,13 +45,30 @@ extension Tracer {
4545
///
4646
/// - Parameters:
4747
/// - operationName: The name of the operation being traced. This may be a handler function, database call, ...
48-
/// - context: The carrier of a `BaggageContext` within to start the new `Span`.
48+
/// - baggage: Baggage potentially containing trace identifiers of a parent `Span`.
4949
/// - kind: The `SpanKind` of the `Span` to be created. Defaults to `.internal`.
5050
public func startSpan(
51-
named operationName: String,
51+
_ operationName: String,
5252
baggage: Baggage,
5353
ofKind kind: SpanKind = .internal
5454
) -> Span {
55-
return self.startSpan(named: operationName, baggage: baggage, ofKind: kind, at: .now())
55+
return self.startSpan(operationName, baggage: baggage, ofKind: kind, at: .now())
56+
}
57+
58+
// ==== --------------------------------------------------------------------
59+
// MARK: LoggingContext accepting
60+
61+
/// Start a new `Span` with the given `Baggage` starting at `Timestamp.now()`.
62+
///
63+
/// - Parameters:
64+
/// - operationName: The name of the operation being traced. This may be a handler function, database call, ...
65+
/// - context: Logging context containing a `Baggage` whichi may contain trace identifiers of a parent `Span`.
66+
/// - kind: The `SpanKind` of the `Span` to be created. Defaults to `.internal`.
67+
public func startSpan(
68+
_ operationName: String,
69+
context: LoggingContext,
70+
ofKind kind: SpanKind = .internal
71+
) -> Span {
72+
return self.startSpan(operationName, baggage: context.baggage, ofKind: kind, at: .now())
5673
}
5774
}

Sources/TracingBenchmarks/ExampleBenchmark.swift

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)