@@ -28,7 +28,7 @@ export function extractTraceMeta(
2828 if ( service ) services . add ( service ) ;
2929 for ( const scopeSpan of resourceSpan . scopeSpans ?? [ ] ) {
3030 for ( const span of scopeSpan . spans ?? [ ] ) {
31- meta . traceId ??= hexFromB64OrString ( span . traceId ) || undefined ;
31+ meta . traceId ??= hexFromBase64OrHex ( span . traceId ) || undefined ;
3232 widenTimeBounds ( meta , nanoToMs ( span . startTimeUnixNano ) ) ;
3333 widenTimeBounds ( meta , nanoToMs ( span . endTimeUnixNano ) ) ;
3434 meta . sessionId ??=
@@ -43,7 +43,7 @@ export function extractTraceMeta(
4343 if ( service ) services . add ( service ) ;
4444 for ( const scopeLog of resourceLog . scopeLogs ?? [ ] ) {
4545 for ( const record of scopeLog . logRecords ?? [ ] ) {
46- meta . traceId ??= hexFromB64OrString ( record . traceId ) || undefined ;
46+ meta . traceId ??= hexFromBase64OrHex ( record . traceId ) || undefined ;
4747 widenTimeBounds (
4848 meta ,
4949 nanoToMs ( record . timeUnixNano ) || nanoToMs ( record . observedTimeUnixNano ) ,
@@ -79,7 +79,7 @@ export function partitionByTraceId(payload: OtlpPayload): Map<string, OtlpPayloa
7979
8080 for ( const resourceSpan of payload . resourceSpans ?? [ ] ) {
8181 for ( const scopeSpan of resourceSpan . scopeSpans ?? [ ] ) {
82- const byTrace = groupBy ( scopeSpan . spans ?? [ ] , ( span ) => hexFromB64OrString ( span . traceId ) ) ;
82+ const byTrace = groupBy ( scopeSpan . spans ?? [ ] , ( span ) => hexFromBase64OrHex ( span . traceId ) ) ;
8383 for ( const [ traceId , spans ] of byTrace ) {
8484 ( partition ( traceId ) . resourceSpans ??= [ ] ) . push ( {
8585 resource : resourceSpan . resource ,
@@ -92,7 +92,7 @@ export function partitionByTraceId(payload: OtlpPayload): Map<string, OtlpPayloa
9292 for ( const resourceLog of payload . resourceLogs ?? [ ] ) {
9393 for ( const scopeLog of resourceLog . scopeLogs ?? [ ] ) {
9494 const byTrace = groupBy ( scopeLog . logRecords ?? [ ] , ( record ) =>
95- hexFromB64OrString ( record . traceId ) ,
95+ hexFromBase64OrHex ( record . traceId ) ,
9696 ) ;
9797 for ( const [ traceId , logRecords ] of byTrace ) {
9898 ( partition ( traceId ) . resourceLogs ??= [ ] ) . push ( {
@@ -137,9 +137,9 @@ export function buildTraceDetail(
137137 spans : scopeSpan . spans
138138 ?. map ( ( span ) => ( {
139139 ...span ,
140- traceId : hexFromB64OrString ( span . traceId ) ,
141- spanId : hexFromB64OrString ( span . spanId ) ,
142- parentSpanId : hexFromB64OrString ( span . parentSpanId ) ,
140+ traceId : hexFromBase64OrHex ( span . traceId ) ,
141+ spanId : hexFromBase64OrHex ( span . spanId ) ,
142+ parentSpanId : hexFromBase64OrHex ( span . parentSpanId ) ,
143143 attributes : flattenAttributes ( span . attributes ) ,
144144 } ) )
145145 . filter ( ( span ) => isMeaningfulSpan ( span ) ) ,
@@ -157,8 +157,8 @@ export function buildTraceDetail(
157157 scope : scopeLog . scope ,
158158 logRecords : scopeLog . logRecords ?. map ( ( record ) => ( {
159159 ...record ,
160- traceId : hexFromB64OrString ( record . traceId ) ,
161- spanId : hexFromB64OrString ( record . spanId ) ,
160+ traceId : hexFromBase64OrHex ( record . traceId ) ,
161+ spanId : hexFromBase64OrHex ( record . spanId ) ,
162162 body : record . body === undefined ? undefined : extractAnyValue ( record . body ) ,
163163 attributes : flattenAttributes ( record . attributes ) ,
164164 } ) ) ,
@@ -224,7 +224,7 @@ export function nanoToMs(nano: string | undefined): number {
224224 * Normalize a trace/span id that may be base64 (protobuf JSON conversion) or
225225 * already hex (JSON ingest) into lowercase hex.
226226 */
227- export function hexFromB64OrString ( value : string | undefined ) : string {
227+ export function hexFromBase64OrHex ( value : string | undefined ) : string {
228228 if ( ! value ) return "" ;
229229 if ( / ^ [ 0 - 9 a - f ] + $ / i. test ( value ) && ( value . length === 32 || value . length === 16 ) )
230230 return value . toLowerCase ( ) ;
0 commit comments