-
Notifications
You must be signed in to change notification settings - Fork 113
Generate trace ID in correct format (LocalLambda Server) #139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
372b748
Generate trace ID in correct format (LocalLambda Server)
76c7e25
Move randomTraceID to Utils, rename to generateTraceID
21aede0
Create generateTraceId test
ed017c2
Merge branch 'master' into feature/random_trace_id
tomerd a59feb5
Rename generateTraceID to AmazonHeaders::generateXRayTraceID
e990029
Generate XRay trace ID in LambdaRuntimeClientTest
ee79bfd
Rename testGenerateTraceId to match tested function name
cefb7bc
Remove @inlinable from generateXRayTraceID
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,39 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This source file is part of the SwiftAWSLambdaRuntime open source project | ||
// | ||
// Copyright (c) 2017-2018 Apple Inc. and the SwiftAWSLambdaRuntime project authors | ||
// Licensed under Apache License v2.0 | ||
// | ||
// See LICENSE.txt for license information | ||
// See CONTRIBUTORS.txt for the list of SwiftAWSLambdaRuntime project authors | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
@testable import AWSLambdaRuntimeCore | ||
import XCTest | ||
|
||
class UtilsTest: XCTestCase { | ||
func testGenerateXRayTraceID() { | ||
// the time and identifier should be in hexadecimal digits | ||
let invalidCharacters = CharacterSet(charactersIn: "abcdef0123456789").inverted | ||
let numTests = 1000 | ||
var values = Set<String>() | ||
for _ in 0 ..< numTests { | ||
// check the format, see https://docs.aws.amazon.com/xray/latest/devguide/xray-api-sendingdata.html#xray-api-traceids) | ||
let traceId = AmazonHeaders.generateXRayTraceID() | ||
let segments = traceId.split(separator: "-") | ||
XCTAssertEqual(3, segments.count) | ||
XCTAssertEqual("1", segments[0]) | ||
XCTAssertEqual(8, segments[1].count) | ||
XCTAssertNil(segments[1].rangeOfCharacter(from: invalidCharacters)) | ||
XCTAssertEqual(24, segments[2].count) | ||
XCTAssertNil(segments[2].rangeOfCharacter(from: invalidCharacters)) | ||
values.insert(traceId) | ||
} | ||
// check that the generated values are different | ||
XCTAssertEqual(values.count, numTests) | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.