Skip to content

Commit

Permalink
make passing changes
Browse files Browse the repository at this point in the history
  • Loading branch information
khanayan123 committed Feb 11, 2025
1 parent 231795b commit de59f68
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions packages/dd-trace/src/opentracing/propagation/text_map.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ class TextMapPropagator {

if (this._config.tracePropagationExtractFirst) return spanContext


Check failure on line 365 in packages/dd-trace/src/opentracing/propagation/text_map.js

View workflow job for this annotation

GitHub Actions / lint

More than 1 blank line not allowed
const tc = this._extractTraceparentContext(carrier)

if (tc && spanContext._traceId.equals(tc._traceId)) {
Expand Down Expand Up @@ -482,10 +483,29 @@ class TextMapPropagator {
}
break
}
case 't.tid': {
// we only accept 16 hex digits as a valid tid

const isHex16 = /^[0-9A-Fa-f]{16}$/.test(value)
console.log('bluhh', spanContext._trace.tags['_dd.p.tid'], value, traceparent, isHex16)

Check failure on line 490 in packages/dd-trace/src/opentracing/propagation/text_map.js

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement
if (isHex16 ) {

Check failure on line 491 in packages/dd-trace/src/opentracing/propagation/text_map.js

View workflow job for this annotation

GitHub Actions / lint

There should be no space before this paren
const transformedValue = value.replace(/[\x7e]/gm, '=');

Check failure on line 492 in packages/dd-trace/src/opentracing/propagation/text_map.js

View workflow job for this annotation

GitHub Actions / lint

Extra semicolon

// Only overwrite if it matches the originally stored _dd.p.tid
if (spanContext._trace.tags['_dd.p.tid'] === transformedValue) {
spanContext._trace.tags['_dd.p.tid'] = transformedValue;

Check failure on line 496 in packages/dd-trace/src/opentracing/propagation/text_map.js

View workflow job for this annotation

GitHub Actions / lint

Extra semicolon
}
}
console.log('yupppp', spanContext._trace.tags['_dd.p.tid'])

Check failure on line 499 in packages/dd-trace/src/opentracing/propagation/text_map.js

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement
// If not valid, do nothing — so we preserve the TID from `traceparent`.
break
}
default:
console.log(123123123, spanContext._trace.tags['_dd.p.tid'])

Check failure on line 504 in packages/dd-trace/src/opentracing/propagation/text_map.js

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement
if (!key.startsWith('t.')) continue
spanContext._trace.tags[`_dd.p.${key.slice(2)}`] = value
.replace(/[\x7e]/gm, '=')
console.log(123123123, spanContext._trace.tags['_dd.p.tid'])

Check failure on line 508 in packages/dd-trace/src/opentracing/propagation/text_map.js

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement
}
}
})
Expand Down Expand Up @@ -645,7 +665,10 @@ class TextMapPropagator {
log.error('Trace tags from carrier are invalid, skipping extraction.')
return
}

// Check if value is a valid 16 character lower-case hexadecimal encoded number as per spec
if (key === '_dd.p.tid' && !(/^[a-f0-9]{16}$/.test(value))) {
continue
}
tags[key] = value
}

Expand All @@ -663,8 +686,8 @@ class TextMapPropagator {
const tid = traceId.substring(0, 16)

// don't set upper 64 bits if they are all zeros or 128 bit trace id generation is disabled
console.log(123123123, this._config.traceId128BitGenerationEnabled)
if (tid === zeroTraceId || this._config.traceId128BitGenerationEnabled === false) return

if (tid === zeroTraceId) return

spanContext._trace.tags['_dd.p.tid'] = tid
}
Expand Down

0 comments on commit de59f68

Please sign in to comment.