-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use BaggageContext to get and propagate context (#31)
* feat: use BaggageContext to get and propagate context Closes #23 Affects #19 * docs: update documentation
- Loading branch information
Showing
22 changed files
with
235 additions
and
240 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
**EXTENSION** | ||
|
||
# `BaggageContext` | ||
```swift | ||
public extension BaggageContext | ||
``` | ||
|
||
## Properties | ||
### `xRayContext` | ||
|
||
```swift | ||
var xRayContext: XRayRecorder.TraceContext? | ||
``` | ||
|
||
XRay Trace Context.. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This source file is part of the aws-xray-sdk-swift open source project | ||
// | ||
// Copyright (c) 2020 pokryfka and the aws-xray-sdk-swift project authors | ||
// Licensed under Apache License v2.0 | ||
// | ||
// See LICENSE.txt for license information | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
import Baggage | ||
|
||
private enum XRayContextKey: BaggageContextKey { | ||
typealias Value = XRayRecorder.TraceContext | ||
var name: String { "XRayTraceContext" } | ||
} | ||
|
||
public extension BaggageContext { | ||
/// XRay Trace Context.. | ||
var xRayContext: XRayRecorder.TraceContext? { | ||
get { | ||
self[XRayContextKey.self] | ||
} | ||
set { | ||
self[XRayContextKey.self] = newValue | ||
} | ||
} | ||
} | ||
|
||
internal extension BaggageContext { | ||
func withParent(_ parentId: XRayRecorder.Segment.ID) throws -> BaggageContext { | ||
guard var context = xRayContext else { throw XRayRecorder.TraceError.missingContext } | ||
context.parentId = parentId | ||
var updated = self | ||
updated.xRayContext = context | ||
return updated | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.