@@ -53,8 +53,8 @@ const NOT_SAMPLED = '0';
5353const LINEAGE_KEY = 'Lineage' ;
5454const LINEAGE_DELIMITER = ':' ;
5555const LINEAGE_HASH_LENGTH = 8 ;
56- const LINEAGE_MAX_REQUEST_COUNTER = 255 ;
57- const LINEAGE_MAX_LOOP_COUNTER = 32767 ;
56+ const LINEAGE_MAX_COUNTER_1 = 32767 ;
57+ const LINEAGE_MAX_COUNTER_2 = 255 ;
5858
5959/**
6060 * Implementation of the AWS X-Ray Trace Header propagation protocol. See <a href=
@@ -241,19 +241,19 @@ export class AWSXRayPropagator implements TextMapPropagator {
241241 return false ;
242242 }
243243
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 ] ) ;
247247
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 ;
255255
256- return isValidKey && isValidRequestCounter && isValidLoopCounter ;
256+ return isValidHash && isValidCounter1 && isValidCounter2 ;
257257 }
258258
259259 private static _parseTraceFlag ( xraySampledFlag : string ) : TraceFlags | null {
0 commit comments