Skip to content

Commit

Permalink
RUMM-976 GH Issue #363
Browse files Browse the repository at this point in the history
BaggageItems.get(key) searches in parent.baggageItems too
  • Loading branch information
buranmert committed Jan 12, 2021
1 parent 6ba6103 commit 034ed84
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 034ed84

Please sign in to comment.