Skip to content

Commit d0dafb8

Browse files
author
Ignacio Bonafonte
authored
Merge branch 'main' into SignPost-Integration
2 parents 85691f0 + 7c81077 commit d0dafb8

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

Sources/Instrumentation/SDKResourceExtension/DefaultResources.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public class DefaultResources {
3131
let mirror = Mirror(reflecting: self)
3232
for children in mirror.children {
3333
if let provider = children.value as? ResourceProvider {
34-
resource = provider.create().merging(other: resource)
34+
resource.merge(other: provider.create())
3535
}
3636
}
3737
return resource

Sources/OpenTelemetrySdk/Resources/Resource.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ public struct Resource: Equatable, Hashable {
5353
/// In case of a collision, current Resource takes precedence.
5454
/// - Parameter other: the Resource that will be merged with this
5555
public mutating func merge(other: Resource) {
56-
attributes.merge(other.attributes) { current, _ in current }
56+
attributes.merge(other.attributes) { _, other in other }
5757
}
5858

5959
/// Returns a new, merged Resource by merging the current Resource with the other Resource.
6060
/// In case of a collision, current Resource takes precedence.
6161
/// - Parameter other: the Resource that will be merged with this
6262
public func merging(other: Resource) -> Resource {
63-
let labelsCopy = attributes.merging(other.attributes) { current, _ in current }
63+
let labelsCopy = attributes.merging(other.attributes) { _, other in other }
6464
return Resource(attributes: labelsCopy)
6565
}
6666

Tests/OpenTelemetrySdkTests/Resource/ResourceTest.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class ResourceTest: XCTestCase {
4646
}
4747

4848
func testMergeResources() {
49-
let expectedLabelMap = ["a": AttributeValue.string("1"), "b": AttributeValue.string("2"), "c": AttributeValue.string("4")]
49+
let expectedLabelMap = ["a": AttributeValue.string("1"), "b": AttributeValue.string("3"), "c": AttributeValue.string("4")]
5050
let resource = defaultResource.merging(other: resource1).merging(other: resource2)
5151
XCTAssertEqual(resource.attributes, expectedLabelMap)
5252
}

0 commit comments

Comments
 (0)