From d126f003e5385aa9fd51afab4896829fbca71f77 Mon Sep 17 00:00:00 2001 From: Ignacio Bonafonte Date: Tue, 10 Aug 2021 13:19:31 +0200 Subject: [PATCH] We must use a versioned dependency of Reachability, or a versioned dependency of opentelemetry-swift cannot be used. Also fix a documentation error in `Resource` merfing --- Package.resolved | 6 +++--- Package.swift | 2 +- .../NetworkStatus/NetworkMonitor.swift | 12 +++++------- Sources/OpenTelemetrySdk/Resources/Resource.swift | 4 ++-- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/Package.resolved b/Package.resolved index 8792c04f..efebb3d5 100644 --- a/Package.resolved +++ b/Package.resolved @@ -23,9 +23,9 @@ "package": "Reachability", "repositoryURL": "https://github.com/ashleymills/Reachability.swift", "state": { - "branch": "master", - "revision": "a81b7367f2c46875f29577e03a60c39cdfad0c8d", - "version": null + "branch": null, + "revision": "c01bbdf2d633cf049ae1ed1a68a2020a8bda32e2", + "version": "5.1.0" } }, { diff --git a/Package.swift b/Package.swift index 1d5c6ac9..8ca75efe 100644 --- a/Package.swift +++ b/Package.swift @@ -50,7 +50,7 @@ let package = Package( .package(name: "grpc-swift", url: "https://github.com/grpc/grpc-swift.git", from: "1.0.0"), .package(name: "swift-atomics", url: "https://github.com/apple/swift-atomics.git", from: "0.0.1"), .package(name: "swift-metrics", url: "https://github.com/apple/swift-metrics.git", from: "2.1.1"), - .package(name: "Reachability", url: "https://github.com/ashleymills/Reachability.swift", .branch("master")), + .package(name: "Reachability", url: "https://github.com/ashleymills/Reachability.swift", from: "5.1.0"), ], targets: [ diff --git a/Sources/Instrumentation/NetworkStatus/NetworkMonitor.swift b/Sources/Instrumentation/NetworkStatus/NetworkMonitor.swift index e8b6fa38..f8ccdf5e 100644 --- a/Sources/Instrumentation/NetworkStatus/NetworkMonitor.swift +++ b/Sources/Instrumentation/NetworkStatus/NetworkMonitor.swift @@ -6,9 +6,9 @@ import Foundation import Reachability -public class NetworkMonitor : NetworkMonitorProtocol { - public private(set) var reachability :Reachability - +public class NetworkMonitor: NetworkMonitorProtocol { + public private(set) var reachability: Reachability + public init() throws { reachability = try Reachability() try reachability.startNotifier() @@ -17,17 +17,15 @@ public class NetworkMonitor : NetworkMonitorProtocol { deinit { reachability.stopNotifier() } - + public func getConnection() -> Connection { switch reachability.connection { case .wifi: return .wifi case .cellular: return .cellular - case .unavailable: + case .unavailable, .none: return .unavailable } } - - } diff --git a/Sources/OpenTelemetrySdk/Resources/Resource.swift b/Sources/OpenTelemetrySdk/Resources/Resource.swift index 16bc6b61..d3f7eb2d 100644 --- a/Sources/OpenTelemetrySdk/Resources/Resource.swift +++ b/Sources/OpenTelemetrySdk/Resources/Resource.swift @@ -40,14 +40,14 @@ public struct Resource: Equatable, Hashable { } /// Modifies the current Resource by merging with the other Resource. - /// In case of a collision, current Resource takes precedence. + /// In case of a collision, new Resource takes precedence. /// - Parameter other: the Resource that will be merged with this public mutating func merge(other: Resource) { attributes.merge(other.attributes) { _, other in other } } /// Returns a new, merged Resource by merging the current Resource with the other Resource. - /// In case of a collision, current Resource takes precedence. + /// In case of a collision, new Resource takes precedence. /// - Parameter other: the Resource that will be merged with this public func merging(other: Resource) -> Resource { let labelsCopy = attributes.merging(other.attributes) { _, other in other }