@@ -47,14 +47,12 @@ describe('getModifiedData', () => {
4747 const sampleUint8Arr = new Uint8Array ( Buffer . from ( sampleText ) ) ;
4848 const expectedExecutionContext = {
4949 executionId : 'testExecutionId' ,
50- traceId : 'testTraceId' ,
5150 spanId : 'testSpanId' ,
5251 } ;
5352 const expectedMetadata = {
5453 'logging.googleapis.com/labels' : {
5554 execution_id : 'testExecutionId' ,
5655 } ,
57- 'logging.googleapis.com/trace' : 'testTraceId' ,
5856 'logging.googleapis.com/spanId' : 'testSpanId' ,
5957 } ;
6058 const expectedTextOutput =
@@ -102,13 +100,31 @@ describe('getModifiedData', () => {
102100 user_label_1 : 'value_1' ,
103101 execution_id : 'testExecutionId' ,
104102 } ,
105- 'logging.googleapis.com/trace' : 'testTraceId' ,
106103 'logging.googleapis.com/spanId' : 'testSpanId' ,
107104 } ) + '\n' ;
108105 const modifiedData = getModifiedData ( data ) ;
109106 assert . equal ( modifiedData , expectedOutput ) ;
110107 } ) ;
111108
109+ it ( 'json with user span id' , ( ) => {
110+ const data = JSON . stringify ( {
111+ text : 'default text.' ,
112+ component : 'arbitrary-property' ,
113+ 'logging.googleapis.com/spanId' : 'mySpanId' ,
114+ } ) ;
115+ const expectedOutput =
116+ JSON . stringify ( {
117+ text : 'default text.' ,
118+ component : 'arbitrary-property' ,
119+ 'logging.googleapis.com/spanId' : 'mySpanId' ,
120+ 'logging.googleapis.com/labels' : {
121+ execution_id : 'testExecutionId' ,
122+ } ,
123+ } ) + '\n' ;
124+ const modifiedData = getModifiedData ( data ) ;
125+ assert . equal ( modifiedData , expectedOutput ) ;
126+ } ) ;
127+
112128 it ( 'uint8array' , ( ) => {
113129 const modifiedData = getModifiedData ( sampleUint8Arr ) ;
114130 assert . equal ( modifiedData , expectedTextOutput ) ;
0 commit comments