File tree 3 files changed +39
-6
lines changed
Sources/AWSLambdaRuntimeCore
Tests/AWSLambdaRuntimeCoreTests
3 files changed +39
-6
lines changed Original file line number Diff line number Diff line change @@ -51,14 +51,10 @@ struct Invocation: Hashable {
51
51
throw Lambda . RuntimeError. invocationMissingHeader ( AmazonHeaders . invokedFunctionARN)
52
52
}
53
53
54
- guard let traceID = headers. first ( name: AmazonHeaders . traceID) else {
55
- throw Lambda . RuntimeError. invocationMissingHeader ( AmazonHeaders . traceID)
56
- }
57
-
58
54
self . requestID = requestID
59
55
self . deadlineInMillisSinceEpoch = unixTimeInMilliseconds
60
56
self . invokedFunctionARN = invokedFunctionARN
61
- self . traceID = traceID
57
+ self . traceID = headers . first ( name : AmazonHeaders . traceID) ?? " Root= \( AmazonHeaders . generateXRayTraceID ( ) ) ;Sampled=0 "
62
58
self . clientContext = headers [ " Lambda-Runtime-Client-Context " ] . first
63
59
self . cognitoIdentity = headers [ " Lambda-Runtime-Cognito-Identity " ] . first
64
60
}
Original file line number Diff line number Diff line change
1
+ //===----------------------------------------------------------------------===//
2
+ //
3
+ // This source file is part of the SwiftAWSLambdaRuntime open source project
4
+ //
5
+ // Copyright (c) 2022 Apple Inc. and the SwiftAWSLambdaRuntime project authors
6
+ // Licensed under Apache License v2.0
7
+ //
8
+ // See LICENSE.txt for license information
9
+ // See CONTRIBUTORS.txt for the list of SwiftAWSLambdaRuntime project authors
10
+ //
11
+ // SPDX-License-Identifier: Apache-2.0
12
+ //
13
+ //===----------------------------------------------------------------------===//
14
+
15
+ @testable import AWSLambdaRuntimeCore
16
+ import NIOHTTP1
17
+ import XCTest
18
+
19
+ class InvocationTest : XCTestCase {
20
+ func testInvocationTraceID( ) throws {
21
+ let headers = HTTPHeaders ( [
22
+ ( AmazonHeaders . requestID, " test " ) ,
23
+ ( AmazonHeaders . deadline, String ( Date ( timeIntervalSinceNow: 60 ) . millisSinceEpoch) ) ,
24
+ ( AmazonHeaders . invokedFunctionARN, " arn:aws:lambda:us-east-1:123456789012:function:custom-runtime " ) ,
25
+ ] )
26
+
27
+ var invocation : Invocation ?
28
+
29
+ XCTAssertNoThrow ( invocation = try Invocation ( headers: headers) )
30
+ XCTAssertNotNil ( invocation)
31
+
32
+ guard !invocation!. traceID. isEmpty else {
33
+ XCTFail ( " Invocation traceID is empty " )
34
+ return
35
+ }
36
+ }
37
+ }
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
19
19
20
20
function replace_acceptable_years() {
21
21
# this needs to replace all acceptable forms with 'YEARS'
22
- sed -e ' s/2017-2018/YEARS/' -e ' s/2017-2020/YEARS/' -e ' s/2017-2021/YEARS/' -e ' s/2020-2021/YEARS/' -e ' s/2019/YEARS/' -e ' s/2020/YEARS/' -e ' s/2021/YEARS/'
22
+ sed -e ' s/2017-2018/YEARS/' -e ' s/2017-2020/YEARS/' -e ' s/2017-2021/YEARS/' -e ' s/2020-2021/YEARS/' -e ' s/2019/YEARS/' -e ' s/2020/YEARS/' -e ' s/2021/YEARS/' -e ' s/2022/YEARS/ '
23
23
}
24
24
25
25
printf " => Checking for unacceptable language... "
You can’t perform that action at this time.
0 commit comments