File tree Expand file tree Collapse file tree 3 files changed +39
-6
lines changed
Sources/AWSLambdaRuntimeCore
Tests/AWSLambdaRuntimeCoreTests Expand file tree Collapse file tree 3 files changed +39
-6
lines changed Original file line number Diff line number Diff line change @@ -51,14 +51,10 @@ struct Invocation: Hashable {
5151 throw Lambda . RuntimeError. invocationMissingHeader ( AmazonHeaders . invokedFunctionARN)
5252 }
5353
54- guard let traceID = headers. first ( name: AmazonHeaders . traceID) else {
55- throw Lambda . RuntimeError. invocationMissingHeader ( AmazonHeaders . traceID)
56- }
57-
5854 self . requestID = requestID
5955 self . deadlineInMillisSinceEpoch = unixTimeInMilliseconds
6056 self . invokedFunctionARN = invokedFunctionARN
61- self . traceID = traceID
57+ self . traceID = headers . first ( name : AmazonHeaders . traceID) ?? " Root= \( AmazonHeaders . generateXRayTraceID ( ) ) ;Sampled=0 "
6258 self . clientContext = headers [ " Lambda-Runtime-Client-Context " ] . first
6359 self . cognitoIdentity = headers [ " Lambda-Runtime-Cognito-Identity " ] . first
6460 }
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 )"
1919
2020function replace_acceptable_years() {
2121 # 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/ '
2323}
2424
2525printf " => Checking for unacceptable language... "
You can’t perform that action at this time.
0 commit comments