File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed
test/unit/segments/attributes Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -56,6 +56,8 @@ class TraceID {
5656 if ( timestamp === 'NaN' ) {
5757 logger . getLogger ( ) . error ( 'Trace ID timestamp must be a hex-encoded value' ) ;
5858 return traceID ;
59+ } else {
60+ timestamp = timestamp . padStart ( 8 , '0' ) ;
5961 }
6062
6163 traceID . version = version ;
Original file line number Diff line number Diff line change @@ -44,4 +44,12 @@ describe('TraceID', function() {
4444 var traceId = TraceID . FromString ( traceStr ) ;
4545 assert . equal ( traceId . toString ( ) , traceStr ) ;
4646 } ) ;
47+
48+ it ( 'should keep leading 0\'s for trace ID from given string' , function ( ) {
49+ const traceStr = '1-00fbe041-2c7ad569f5d6ff149137be86' ;
50+ var traceId = TraceID . FromString ( traceStr ) ;
51+ assert . equal ( traceId . version , 1 ) ;
52+ assert . equal ( traceId . timestamp , '00fbe041' ) ;
53+ assert . equal ( traceId . id , '2c7ad569f5d6ff149137be86' ) ;
54+ } ) ;
4755} ) ;
You can’t perform that action at this time.
0 commit comments