Skip to content

Commit

Permalink
Merge pull request #365 from DataDog/buranmert/RUMM-976-parent-baggag…
Browse files Browse the repository at this point in the history
…eItems-fix

RUMM-976 GH Issue #363
  • Loading branch information
buranmert authored Jan 12, 2021
2 parents 6ba6103 + 034ed84 commit a07293b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Sources/Datadog/Tracing/DDSpanContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ internal class BaggageItems {
}

func get(key: String) -> String? {
queue.sync { self.unsafeItems[key] }
queue.sync { self.unsafeAll[key] }
}

var all: [String: String] {
Expand Down
13 changes: 13 additions & 0 deletions Tests/DatadogTests/Datadog/Tracing/DDSpanContextTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,17 @@ class DDSpanContextTests: XCTestCase {
XCTAssertEqual(parentBaggageItems.all["foo"], "a")
XCTAssertEqual(childBaggageItems.all["foo"], "b")
}

func testChildItemsGetParentItems() {
let parentBaggageItems = BaggageItems(targetQueue: queue, parentSpanItems: nil)
let childBaggageItems = BaggageItems(targetQueue: queue, parentSpanItems: parentBaggageItems)

parentBaggageItems.set(key: "foo", value: "a")
childBaggageItems.set(key: "bar", value: "b")

XCTAssertEqual(childBaggageItems.get(key: "foo"), "a")

XCTAssertNil(parentBaggageItems.get(key: "bar"))
XCTAssertEqual(childBaggageItems.get(key: "bar"), "b")
}
}

0 comments on commit a07293b

Please sign in to comment.