@@ -53,8 +53,8 @@ const NOT_SAMPLED = '0';
53
53
const LINEAGE_KEY = 'Lineage' ;
54
54
const LINEAGE_DELIMITER = ':' ;
55
55
const LINEAGE_HASH_LENGTH = 8 ;
56
- const LINEAGE_MAX_REQUEST_COUNTER = 255 ;
57
- const LINEAGE_MAX_LOOP_COUNTER = 32767 ;
56
+ const LINEAGE_MAX_COUNTER_1 = 255 ;
57
+ const LINEAGE_MAX_COUNTER_2 = 32767 ;
58
58
59
59
/**
60
60
* Implementation of the AWS X-Ray Trace Header propagation protocol. See <a href=
@@ -241,19 +241,19 @@ export class AWSXRayPropagator implements TextMapPropagator {
241
241
return false ;
242
242
}
243
243
244
- const requestCounter = parseInt ( lineageSubstrings [ 0 ] ) ;
245
- const hashedResourceId = lineageSubstrings [ 1 ] ;
246
- const loopCounter = parseInt ( lineageSubstrings [ 2 ] ) ;
244
+ const lineageCounter1 = parseInt ( lineageSubstrings [ 0 ] ) ;
245
+ const hashedString = lineageSubstrings [ 1 ] ;
246
+ const lineageCounter2 = parseInt ( lineageSubstrings [ 2 ] ) ;
247
247
248
- const isValidKey =
249
- hashedResourceId . length === LINEAGE_HASH_LENGTH &&
250
- ! ! hashedResourceId . match ( / ^ [ 0 - 9 a - f A - F ] + $ / ) ;
251
- const isValidRequestCounter =
252
- requestCounter >= 0 && requestCounter <= LINEAGE_MAX_REQUEST_COUNTER ;
253
- const isValidLoopCounter =
254
- loopCounter >= 0 && loopCounter <= LINEAGE_MAX_LOOP_COUNTER ;
248
+ const isValidHash =
249
+ hashedString . length === LINEAGE_HASH_LENGTH &&
250
+ ! ! hashedString . match ( / ^ [ 0 - 9 a - f A - F ] + $ / ) ;
251
+ const isValidCounter1 =
252
+ lineageCounter1 >= 0 && lineageCounter1 <= LINEAGE_MAX_COUNTER_1 ;
253
+ const isValidCounter2 =
254
+ lineageCounter2 >= 0 && lineageCounter2 <= LINEAGE_MAX_COUNTER_2 ;
255
255
256
- return isValidKey && isValidRequestCounter && isValidLoopCounter ;
256
+ return isValidHash && isValidCounter1 && isValidCounter2 ;
257
257
}
258
258
259
259
private static _parseTraceFlag ( xraySampledFlag : string ) : TraceFlags | null {
0 commit comments