Skip to content

Commit 54899bd

Browse files
author
Ignacio Bonafonte
authored
Merge branch 'main' into urlsession-configure-delegates
2 parents a86ccf5 + fac445e commit 54899bd

File tree

33 files changed

+420
-469
lines changed

33 files changed

+420
-469
lines changed

.github/workflows/BuildAndTest.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@ name: Build and Test
33
on: [push, pull_request, workflow_dispatch]
44

55
jobs:
6-
build:
7-
6+
macOS:
87
runs-on: macOS-latest
9-
108
steps:
119
- uses: actions/checkout@v2
1210
- name: Build and Test for macOS
@@ -17,9 +15,23 @@ jobs:
1715
chmod +x codecov
1816
xcrun llvm-cov export -ignore-filename-regex="pb\.swift|grpc\.swift" -format="lcov" .build/debug/opentelemetry-swiftPackageTests.xctest/Contents/MacOS/opentelemetry-swiftPackageTests -instr-profile .build/debug/codecov/default.profdata > .build/debug/codecov/coverage_report.lcov
1917
./codecov -f .build/debug/codecov/coverage_report.lcov
18+
iOS:
19+
runs-on: macOS-latest
20+
steps:
21+
- uses: actions/checkout@v2
2022
- name: Install Homebrew kegs
2123
run: make setup_brew
2224
- name: Build for iOS
2325
run: make build_for_testing_ios
2426
- name: Test for iOS
2527
run: make test_without_building_ios
28+
watchOS:
29+
runs-on: macOS-latest
30+
steps:
31+
- uses: actions/checkout@v2
32+
- name: Install Homebrew kegs
33+
run: make setup_brew
34+
- name: Build for watchOS
35+
run: make build_for_testing_watchos
36+
- name: Test for watchOS
37+
run: make test_without_building_watchos

CODEOWNERS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717
# Approvers: @bryce-b @vvydier
1818

1919

20-
* @SergeyKanzhelev @nachoBonafonte @bryce-b @vvydier
20+
* @nachoBonafonte @bryce-b @vvydier
2121

22-
CODEOWNERS @SergeyKanzhelev @nachoBonafonte
22+
CODEOWNERS @nachoBonafonte

Examples/Datadog Sample/main.swift

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6+
#if os(macOS)
7+
68
import DatadogExporter
79
import Foundation
810
import OpenTelemetryApi
911
import OpenTelemetrySdk
10-
#if !os(macOS)
11-
import UIKit
12-
#endif
1312

1413
let apikeyOrClientToken = ""
1514

@@ -25,11 +24,7 @@ let instrumentationScopeVersion = "semver:0.1.0"
2524
var tracer: Tracer
2625
tracer = OpenTelemetry.instance.tracerProvider.get(instrumentationName: instrumentationScopeName, instrumentationVersion: instrumentationScopeVersion)
2726

28-
#if os(macOS)
2927
let hostName = Host.current().localizedName
30-
#else
31-
let hostName = UIDevice.current.name
32-
#endif
3328

3429
let exporterConfiguration = ExporterConfiguration(
3530
serviceName: "Opentelemetry exporter Example",
@@ -120,3 +115,5 @@ func testMetrics() {
120115
sleep(1)
121116
}
122117
}
118+
119+
#endif

Examples/OTLP Exporter/main.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6+
#if os(macOS)
7+
68
import Foundation
79
import GRPC
810
import NIO
@@ -111,3 +113,5 @@ for _ in 1...3000 {
111113
exampleMeasure.record(value: 750, labelset: meter.getLabelSet(labels: labels1))
112114
sleep(1)
113115
}
116+
117+
#endif

Examples/Simple Exporter/main.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6+
#if os(macOS)
7+
68
import Foundation
79
import JaegerExporter
810
import OpenTelemetryApi
@@ -68,3 +70,5 @@ simpleSpan()
6870
sleep(1)
6971
childSpan()
7072
sleep(1)
73+
74+
#endif

Makefile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ XCODEBUILD_OPTIONS_IOS=\
66
-scheme $(PROJECT_NAME) \
77
-workspace .
88

9+
XCODEBUILD_OPTIONS_WATCHOS=\
10+
-configuration Debug \
11+
-destination platform='watchOS Simulator,name=Apple Watch Series 8 (45mm),OS=latest' \
12+
-scheme $(PROJECT_NAME) \
13+
-workspace .
14+
915
.PHONY: setup_brew
1016
setup_brew:
1117
brew update && brew install xcbeautify
@@ -18,10 +24,18 @@ build_ios:
1824
build_for_testing_ios:
1925
set -o pipefail && xcodebuild $(XCODEBUILD_OPTIONS_IOS) build-for-testing | xcbeautify
2026

27+
.PHONY: build_for_testing_watchos
28+
build_for_testing_watchos:
29+
set -o pipefail && xcodebuild $(XCODEBUILD_OPTIONS_WATCHOS) build-for-testing | xcbeautify
30+
2131
.PHONY: test_ios
2232
test_ios:
2333
set -o pipefail && xcodebuild $(XCODEBUILD_OPTIONS_IOS) test | xcbeautify
2434

2535
.PHONY: test_without_building_ios
2636
test_without_building_ios:
2737
set -o pipefail && xcodebuild $(XCODEBUILD_OPTIONS_IOS) test-without-building | xcbeautify
38+
39+
.PHONY: test_without_building_watchos
40+
test_without_building_watchos:
41+
set -o pipefail && xcodebuild $(XCODEBUILD_OPTIONS_WATCHOS) test-without-building | xcbeautify

Package.swift

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ import PackageDescription
55

66
let package = Package(
77
name: "opentelemetry-swift",
8-
platforms: [.macOS(.v10_13),
9-
.iOS(.v11),
10-
.tvOS(.v11),
11-
.watchOS(.v3)],
8+
platforms: [
9+
.macOS(.v10_13),
10+
.iOS(.v11),
11+
.tvOS(.v11)
12+
],
1213
products: [
1314
.library(name: "OpenTelemetryApi", type: .static, targets: ["OpenTelemetryApi"]),
1415
.library(name: "OpenTelemetrySdk", type: .static, targets: ["OpenTelemetrySdk"]),
@@ -52,7 +53,10 @@ let package = Package(
5253
path: "Sources/Instrumentation/URLSession",
5354
exclude: ["README.md"]),
5455
.target(name: "NetworkStatus",
55-
dependencies: ["OpenTelemetryApi"],
56+
dependencies: [
57+
"OpenTelemetryApi",
58+
.product(name: "Reachability", package: "Reachability.swift")
59+
],
5660
path: "Sources/Instrumentation/NetworkStatus",
5761
linkerSettings: [.linkedFramework("CoreTelephony", .when(platforms: [.iOS], configuration: nil))]),
5862
.target(name: "SignPostIntegration",

[email protected]

Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
// swift-tools-version:5.6
2+
// The swift-tools-version declares the minimum version of Swift required to build this package.
3+
4+
import PackageDescription
5+
6+
let package = Package(
7+
name: "opentelemetry-swift",
8+
platforms: [
9+
.macOS(.v10_13),
10+
.iOS(.v11),
11+
.tvOS(.v11),
12+
.watchOS(.v3)
13+
],
14+
products: [
15+
.library(name: "OpenTelemetryApi", type: .static, targets: ["OpenTelemetryApi"]),
16+
.library(name: "OpenTelemetrySdk", type: .static, targets: ["OpenTelemetrySdk"]),
17+
.library(name: "ResourceExtension", type: .static, targets: ["ResourceExtension"]),
18+
.library(name: "URLSessionInstrumentation", type: .static, targets: ["URLSessionInstrumentation"]),
19+
.library(name: "SignPostIntegration", type: .static, targets: ["SignPostIntegration"]),
20+
.library(name: "OpenTracingShim-experimental", type: .static, targets: ["OpenTracingShim"]),
21+
.library(name: "SwiftMetricsShim", type: .static, targets: ["SwiftMetricsShim"]),
22+
.library(name: "JaegerExporter", type: .static, targets: ["JaegerExporter"]),
23+
.library(name: "ZipkinExporter", type: .static, targets: ["ZipkinExporter"]),
24+
.library(name: "StdoutExporter", type: .static, targets: ["StdoutExporter"]),
25+
.library(name: "PrometheusExporter", type: .static, targets: ["PrometheusExporter"]),
26+
.library(name: "OpenTelemetryProtocolExporter", type: .static, targets: ["OpenTelemetryProtocolExporter"]),
27+
.library(name: "PersistenceExporter", type: .static, targets: ["PersistenceExporter"]),
28+
.library(name: "InMemoryExporter", type: .static, targets: ["InMemoryExporter"]),
29+
.library(name: "DatadogExporter", type: .static, targets: ["DatadogExporter"]),
30+
.library(name: "NetworkStatus", type: .static, targets: ["NetworkStatus"]),
31+
.executable(name: "simpleExporter", targets: ["SimpleExporter"]),
32+
.executable(name: "OTLPExporter", targets: ["OTLPExporter"]),
33+
.executable(name: "loggingTracer", targets: ["LoggingTracer"]),
34+
],
35+
dependencies: [
36+
.package(url: "https://github.com/undefinedlabs/opentracing-objc", from: "0.5.2"),
37+
.package(url: "https://github.com/undefinedlabs/Thrift-Swift", from: "1.1.1"),
38+
.package(url: "https://github.com/apple/swift-nio.git", from: "2.0.0"),
39+
.package(url: "https://github.com/grpc/grpc-swift.git", from: "1.0.0"),
40+
.package(url: "https://github.com/apple/swift-metrics.git", from: "2.1.1"),
41+
.package(url: "https://github.com/ashleymills/Reachability.swift", from: "5.1.0")
42+
],
43+
targets: [
44+
.target(name: "OpenTelemetryApi",
45+
dependencies: []),
46+
.target(name: "OpenTelemetrySdk",
47+
dependencies: ["OpenTelemetryApi"]),
48+
.target(name: "ResourceExtension",
49+
dependencies: ["OpenTelemetrySdk"],
50+
path: "Sources/Instrumentation/SDKResourceExtension",
51+
exclude: ["README.md"]),
52+
.target(name: "URLSessionInstrumentation",
53+
dependencies: ["OpenTelemetrySdk", "NetworkStatus"],
54+
path: "Sources/Instrumentation/URLSession",
55+
exclude: ["README.md"]),
56+
.target(name: "NetworkStatus",
57+
dependencies: [
58+
"OpenTelemetryApi",
59+
.product(name: "Reachability", package: "Reachability.swift", condition: .when(platforms: [.iOS, .macOS, .macCatalyst, .linux]))
60+
],
61+
path: "Sources/Instrumentation/NetworkStatus",
62+
linkerSettings: [.linkedFramework("CoreTelephony", .when(platforms: [.iOS], configuration: nil))]),
63+
.target(name: "SignPostIntegration",
64+
dependencies: ["OpenTelemetrySdk"],
65+
path: "Sources/Instrumentation/SignPostIntegration",
66+
exclude: ["README.md"]),
67+
.target(name: "OpenTracingShim",
68+
dependencies: [
69+
"OpenTelemetrySdk",
70+
.product(name: "Opentracing", package: "opentracing-objc")
71+
],
72+
path: "Sources/Importers/OpenTracingShim",
73+
exclude: ["README.md"]),
74+
.target(name: "SwiftMetricsShim",
75+
dependencies: ["OpenTelemetrySdk",
76+
.product(name: "CoreMetrics", package: "swift-metrics")],
77+
path: "Sources/Importers/SwiftMetricsShim",
78+
exclude: ["README.md"]),
79+
.target(name: "JaegerExporter",
80+
dependencies: [
81+
"OpenTelemetrySdk",
82+
.product(name: "Thrift", package: "Thrift-Swift", condition: .when(platforms: [.iOS, .macOS, .macCatalyst, .linux]))
83+
],
84+
path: "Sources/Exporters/Jaeger"),
85+
.target(name: "ZipkinExporter",
86+
dependencies: ["OpenTelemetrySdk"],
87+
path: "Sources/Exporters/Zipkin"),
88+
.target(name: "PrometheusExporter",
89+
dependencies: ["OpenTelemetrySdk",
90+
.product(name: "NIO", package: "swift-nio"),
91+
.product(name: "NIOHTTP1", package: "swift-nio")],
92+
path: "Sources/Exporters/Prometheus"),
93+
.target(name: "OpenTelemetryProtocolExporter",
94+
dependencies: ["OpenTelemetrySdk",
95+
.product(name: "GRPC", package: "grpc-swift")],
96+
path: "Sources/Exporters/OpenTelemetryProtocol"),
97+
.target(name: "StdoutExporter",
98+
dependencies: ["OpenTelemetrySdk"],
99+
path: "Sources/Exporters/Stdout"),
100+
.target(name: "InMemoryExporter",
101+
dependencies: ["OpenTelemetrySdk"],
102+
path: "Sources/Exporters/InMemory"),
103+
.target(name: "DatadogExporter",
104+
dependencies: ["OpenTelemetrySdk"],
105+
path: "Sources/Exporters/DatadogExporter",
106+
exclude: ["NOTICE", "README.md"]),
107+
.target(name: "PersistenceExporter",
108+
dependencies: ["OpenTelemetrySdk"],
109+
path: "Sources/Exporters/Persistence"),
110+
.testTarget(name: "NetworkStatusTests",
111+
dependencies: [
112+
"NetworkStatus",
113+
.product(name: "Reachability", package: "Reachability.swift", condition: .when(platforms: [.iOS, .macOS, .macCatalyst, .linux]))
114+
],
115+
path: "Tests/InstrumentationTests/NetworkStatusTests"),
116+
.testTarget(name: "OpenTelemetryApiTests",
117+
dependencies: ["OpenTelemetryApi"],
118+
path: "Tests/OpenTelemetryApiTests"),
119+
.testTarget(name: "OpenTelemetrySdkTests",
120+
dependencies: ["OpenTelemetryApi",
121+
"OpenTelemetrySdk"],
122+
path: "Tests/OpenTelemetrySdkTests"),
123+
.testTarget(name: "ResourceExtensionTests",
124+
dependencies: ["ResourceExtension", "OpenTelemetrySdk"],
125+
path: "Tests/InstrumentationTests/SDKResourceExtensionTests"),
126+
.testTarget(name: "URLSessionInstrumentationTests",
127+
dependencies: ["URLSessionInstrumentation",
128+
.product(name: "NIO", package: "swift-nio"),
129+
.product(name: "NIOHTTP1", package: "swift-nio")],
130+
path: "Tests/InstrumentationTests/URLSessionTests"),
131+
.testTarget(name: "OpenTracingShimTests",
132+
dependencies: ["OpenTracingShim",
133+
"OpenTelemetrySdk"],
134+
path: "Tests/ImportersTests/OpenTracingShim"),
135+
.testTarget(name: "SwiftMetricsShimTests",
136+
dependencies: ["SwiftMetricsShim",
137+
"OpenTelemetrySdk"],
138+
path: "Tests/ImportersTests/SwiftMetricsShim"),
139+
.testTarget(name: "JaegerExporterTests",
140+
dependencies: ["JaegerExporter"],
141+
path: "Tests/ExportersTests/Jaeger"),
142+
.testTarget(name: "ZipkinExporterTests",
143+
dependencies: ["ZipkinExporter"],
144+
path: "Tests/ExportersTests/Zipkin"),
145+
.testTarget(name: "PrometheusExporterTests",
146+
dependencies: ["PrometheusExporter"],
147+
path: "Tests/ExportersTests/Prometheus"),
148+
.testTarget(name: "OpenTelemetryProtocolExporterTests",
149+
dependencies: ["OpenTelemetryProtocolExporter"],
150+
path: "Tests/ExportersTests/OpenTelemetryProtocol"),
151+
.testTarget(name: "InMemoryExporterTests",
152+
dependencies: ["InMemoryExporter"],
153+
path: "Tests/ExportersTests/InMemory"),
154+
.testTarget(name: "DatadogExporterTests",
155+
dependencies: ["DatadogExporter",
156+
.product(name: "NIO", package: "swift-nio"),
157+
.product(name: "NIOHTTP1", package: "swift-nio")],
158+
path: "Tests/ExportersTests/DatadogExporter"),
159+
.testTarget(name: "PersistenceExporterTests",
160+
dependencies: ["PersistenceExporter"],
161+
path: "Tests/ExportersTests/PersistenceExporter"),
162+
.executableTarget(
163+
name: "LoggingTracer",
164+
dependencies: ["OpenTelemetryApi"],
165+
path: "Examples/Logging Tracer"
166+
),
167+
.executableTarget(
168+
name: "SimpleExporter",
169+
dependencies: ["OpenTelemetrySdk", "JaegerExporter", "StdoutExporter", "ZipkinExporter", "ResourceExtension", "SignPostIntegration"],
170+
path: "Examples/Simple Exporter",
171+
exclude: ["README.md"]
172+
),
173+
.executableTarget(
174+
name: "OTLPExporter",
175+
dependencies: ["OpenTelemetrySdk", "OpenTelemetryProtocolExporter", "StdoutExporter", "ZipkinExporter", "ResourceExtension", "SignPostIntegration"],
176+
path: "Examples/OTLP Exporter",
177+
exclude: ["README.md"]
178+
),
179+
.executableTarget(
180+
name: "PrometheusSample",
181+
dependencies: ["OpenTelemetrySdk", "PrometheusExporter"],
182+
path: "Examples/Prometheus Sample",
183+
exclude: ["README.md"]
184+
),
185+
.executableTarget(
186+
name: "DatadogSample",
187+
dependencies: ["DatadogExporter"],
188+
path: "Examples/Datadog Sample",
189+
exclude: ["README.md"]
190+
),
191+
.executableTarget(
192+
name: "NetworkSample",
193+
dependencies: ["URLSessionInstrumentation", "StdoutExporter"],
194+
path: "Examples/Network Sample",
195+
exclude: ["README.md"]
196+
),
197+
]
198+
)

Sources/Exporters/DatadogExporter/Files/File.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ internal struct File: WritableFile, ReadableFile {
6161
```
6262
This is fixed in iOS 14/Xcode 12
6363
*/
64-
if #available(OSX 10.15.4, iOS 13.4, watchOS 6.0, tvOS 13.4, *) {
64+
if #available(OSX 10.15.4, iOS 13.4, watchOS 6.2, tvOS 13.4, *) {
6565
defer {
6666
if synchronized {
6767
try? fileHandle.synchronize()
@@ -106,7 +106,7 @@ internal struct File: WritableFile, ReadableFile {
106106
```
107107
This is fixed in iOS 14/Xcode 12
108108
*/
109-
if #available(OSX 10.15.4, iOS 13.4, watchOS 6.0, tvOS 13.4, *) {
109+
if #available(OSX 10.15.4, iOS 13.4, watchOS 6.2, tvOS 13.4, *) {
110110
defer { try? fileHandle.close() }
111111
return try fileHandle.readToEnd() ?? Data()
112112
} else {

0 commit comments

Comments
 (0)