@@ -50,8 +50,8 @@ const SAMPLED_FLAG_KEY = 'Sampled';
5050const IS_SAMPLED = '1' ;
5151const NOT_SAMPLED = '0' ;
5252
53- const LINEAGE_KEY = " Lineage" ;
54- const LINEAGE_DELIMITER = ":" ;
53+ const LINEAGE_KEY = ' Lineage' ;
54+ const LINEAGE_DELIMITER = ':' ;
5555const LINEAGE_HASH_LENGTH = 8 ;
5656const LINEAGE_MAX_REQUEST_COUNTER = 255 ;
5757const LINEAGE_MAX_LOOP_COUNTER = 32767 ;
@@ -82,24 +82,24 @@ export class AWSXRayPropagator implements TextMapPropagator {
8282 : NOT_SAMPLED ;
8383 // TODO: Add OT trace state to the X-Ray trace header
8484
85- let traceHeader =
86- `${ TRACE_ID_KEY } ` +
87- `${ KV_DELIMITER } ` +
88- `${ xrayTraceId } ` +
89- `${ TRACE_HEADER_DELIMITER } ` +
90- `${ PARENT_ID_KEY } ` +
91- `${ KV_DELIMITER } ` +
92- `${ parentId } ` +
93- `${ TRACE_HEADER_DELIMITER } ` +
94- `${ SAMPLED_FLAG_KEY } ` +
95- `${ KV_DELIMITER } ` +
96- `${ samplingFlag } ` ;
85+ let traceHeader =
86+ `${ TRACE_ID_KEY } ` +
87+ `${ KV_DELIMITER } ` +
88+ `${ xrayTraceId } ` +
89+ `${ TRACE_HEADER_DELIMITER } ` +
90+ `${ PARENT_ID_KEY } ` +
91+ `${ KV_DELIMITER } ` +
92+ `${ parentId } ` +
93+ `${ TRACE_HEADER_DELIMITER } ` +
94+ `${ SAMPLED_FLAG_KEY } ` +
95+ `${ KV_DELIMITER } ` +
96+ `${ samplingFlag } ` ;
9797
9898 const baggage = propagation . getBaggage ( context ) ;
9999 const lineageV2Header = baggage ?. getEntry ( LINEAGE_KEY ) ?. value ;
100100
101101 if ( lineageV2Header ) {
102- traceHeader +=
102+ traceHeader +=
103103 `${ TRACE_HEADER_DELIMITER } ` +
104104 `${ LINEAGE_KEY } ` +
105105 `${ KV_DELIMITER } ` +
@@ -138,7 +138,8 @@ export class AWSXRayPropagator implements TextMapPropagator {
138138 return context ;
139139 }
140140
141- let baggage : Baggage = propagation . getBaggage ( context ) || propagation . createBaggage ( ) ;
141+ let baggage : Baggage =
142+ propagation . getBaggage ( context ) || propagation . createBaggage ( ) ;
142143
143144 let pos = 0 ;
144145 let trimmedPart : string ;
@@ -167,7 +168,7 @@ export class AWSXRayPropagator implements TextMapPropagator {
167168 parsedTraceFlags = AWSXRayPropagator . _parseTraceFlag ( value ) ;
168169 } else if ( trimmedPart . startsWith ( LINEAGE_KEY ) ) {
169170 if ( AWSXRayPropagator . _isValidLineageV2Header ( value ) ) {
170- baggage = baggage . setEntry ( LINEAGE_KEY , { value} ) ;
171+ baggage = baggage . setEntry ( LINEAGE_KEY , { value } ) ;
171172 }
172173 }
173174 }
@@ -181,7 +182,10 @@ export class AWSXRayPropagator implements TextMapPropagator {
181182 isRemote : true ,
182183 } ;
183184 if ( isSpanContextValid ( resultSpanContext ) ) {
184- context = trace . setSpan ( context , trace . wrapSpanContext ( resultSpanContext ) ) ;
185+ context = trace . setSpan (
186+ context ,
187+ trace . wrapSpanContext ( resultSpanContext )
188+ ) ;
185189 }
186190 if ( baggage . getAllEntries ( ) . length > 0 ) {
187191 context = propagation . setBaggage ( context , baggage ) ;
@@ -233,17 +237,21 @@ export class AWSXRayPropagator implements TextMapPropagator {
233237
234238 private static _isValidLineageV2Header ( xrayLineageHeader : string ) : boolean {
235239 const lineageSubstrings = xrayLineageHeader . split ( LINEAGE_DELIMITER ) ;
236- if ( lineageSubstrings . length != 3 ) {
240+ if ( lineageSubstrings . length !== 3 ) {
237241 return false ;
238242 }
239243
240244 const requestCounter = parseInt ( lineageSubstrings [ 0 ] ) ;
241245 const hashedResourceId = lineageSubstrings [ 1 ] ;
242246 const loopCounter = parseInt ( lineageSubstrings [ 2 ] ) ;
243-
244- const isValidKey = hashedResourceId . length == LINEAGE_HASH_LENGTH && ! ! hashedResourceId . match ( / ^ [ 0 - 9 a - f A - F ] + $ / ) ;
245- const isValidRequestCounter = requestCounter >= 0 && requestCounter <= LINEAGE_MAX_REQUEST_COUNTER ;
246- const isValidLoopCounter = loopCounter >= 0 && loopCounter <= LINEAGE_MAX_LOOP_COUNTER ;
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 ;
247255
248256 return isValidKey && isValidRequestCounter && isValidLoopCounter ;
249257 }
0 commit comments