Skip to content

Commit

Permalink
We must use a versioned dependency of Reachability, or a versioned de…
Browse files Browse the repository at this point in the history
…pendency of opentelemetry-swift cannot be used.

Also fix a documentation error in `Resource` merfing
  • Loading branch information
Ignacio Bonafonte committed Aug 10, 2021
1 parent adfe129 commit d126f00
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
6 changes: 3 additions & 3 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down
12 changes: 5 additions & 7 deletions Sources/Instrumentation/NetworkStatus/NetworkMonitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
}
}


}
4 changes: 2 additions & 2 deletions Sources/OpenTelemetrySdk/Resources/Resource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down

0 comments on commit d126f00

Please sign in to comment.