1313import com .microsoft .applicationinsights .agent .internal .configuration .Configuration .ToAttributeConfig ;
1414import io .opentelemetry .api .common .AttributeKey ;
1515import io .opentelemetry .api .common .Attributes ;
16+ import io .opentelemetry .api .common .Value ;
17+ import io .opentelemetry .api .common .ValueType ;
1618import io .opentelemetry .sdk .logs .data .LogRecordData ;
1719import io .opentelemetry .sdk .logs .export .LogRecordExporter ;
1820import io .opentelemetry .sdk .testing .logs .TestLogRecordData ;
@@ -85,7 +87,10 @@ void simpleRenameLogMessageTest() {
8587 // verify that resulting logs are filtered in the way we want
8688 List <LogRecordData > result = mockExporter .getLogs ();
8789 LogRecordData resultLog = result .get (0 );
88- assertThat (resultLog .getBody ().asString ()).isEqualTo ("locationget1234" );
90+ Value <?> bodyValue = resultLog .getBodyValue ();
91+ assertThat (bodyValue ).isNotNull ();
92+ assertThat (bodyValue .getType ()).isEqualTo (ValueType .STRING );
93+ assertThat (bodyValue .asString ()).isEqualTo ("locationget1234" );
8994 }
9095
9196 @ Test
@@ -104,7 +109,10 @@ void simpleRenameLogWithSeparatorTest() {
104109 // verify that resulting logs are filtered in the way we want
105110 List <LogRecordData > result = mockExporter .getLogs ();
106111 LogRecordData resultLog = result .get (0 );
107- assertThat (resultLog .getBody ().asString ()).isEqualTo ("location::get::1234" );
112+ Value <?> bodyValue = resultLog .getBodyValue ();
113+ assertThat (bodyValue ).isNotNull ();
114+ assertThat (bodyValue .getType ()).isEqualTo (ValueType .STRING );
115+ assertThat (bodyValue .asString ()).isEqualTo ("location::get::1234" );
108116 }
109117
110118 @ Test
@@ -124,7 +132,10 @@ void simpleRenameLogWithMissingKeysTest() {
124132 // verify that resulting logs are filtered in the way we want
125133 List <LogRecordData > result = mockExporter .getLogs ();
126134 LogRecordData resultLog = result .get (0 );
127- assertThat (resultLog .getBody ().asString ()).isEqualTo ("location::get::1234" );
135+ Value <?> bodyValue = resultLog .getBodyValue ();
136+ assertThat (bodyValue ).isNotNull ();
137+ assertThat (bodyValue .getType ()).isEqualTo (ValueType .STRING );
138+ assertThat (bodyValue .asString ()).isEqualTo ("location::get::1234" );
128139 }
129140
130141 @ Test
@@ -169,7 +180,10 @@ void simpleToAttributesTest() {
169180 Objects .requireNonNull (
170181 resultLog .getAttributes ().get (AttributeKey .stringKey ("documentId" ))))
171182 .isEqualTo ("12345678" );
172- assertThat (resultLog .getBody ().asString ()).isEqualTo ("/api/v1/document/{documentId}/update" );
183+ Value <?> bodyValue = resultLog .getBodyValue ();
184+ assertThat (bodyValue ).isNotNull ();
185+ assertThat (bodyValue .getType ()).isEqualTo (ValueType .STRING );
186+ assertThat (bodyValue .asString ()).isEqualTo ("/api/v1/document/{documentId}/update" );
173187 }
174188
175189 @ Test
@@ -228,7 +242,10 @@ void multiRuleToAttributesTest() {
228242 Objects .requireNonNull (
229243 resultA .getAttributes ().get (AttributeKey .stringKey ("password2" ))))
230244 .isEqualTo ("555" ); // The first match is taken to populate the attribute
231- assertThat (resultA .getBody ().asString ())
245+ Value <?> bodyValueA = resultA .getBodyValue ();
246+ assertThat (bodyValueA ).isNotNull ();
247+ assertThat (bodyValueA .getType ()).isEqualTo (ValueType .STRING );
248+ assertThat (bodyValueA .asString ())
232249 .isEqualTo ("yyyPassword={password1} aba Pass={password2} xyx Pass={password2} zzz" );
233250 assertThat (
234251 Objects .requireNonNull (
@@ -238,7 +255,10 @@ void multiRuleToAttributesTest() {
238255 Objects .requireNonNull (
239256 resultB .getAttributes ().get (AttributeKey .stringKey ("password1" ))))
240257 .isEqualTo ("****" );
241- assertThat (resultB .getBody ().asString ()).isEqualTo ("yyyPassword={password1} aba" );
258+ Value <?> bodyValueB = resultB .getBodyValue ();
259+ assertThat (bodyValueB ).isNotNull ();
260+ assertThat (bodyValueB .getType ()).isEqualTo (ValueType .STRING );
261+ assertThat (bodyValueB .asString ()).isEqualTo ("yyyPassword={password1} aba" );
242262 }
243263
244264 @ Test
@@ -264,7 +284,10 @@ void multiMatch() {
264284 List <LogRecordData > result = mockExporter .getLogs ();
265285 LogRecordData resultA = result .get (0 );
266286
267- assertThat (resultA .getBody ().asString ()).isEqualTo ("yyyPassword={x} aba Password={x} xyx" );
287+ Value <?> bodyValueA = resultA .getBodyValue ();
288+ assertThat (bodyValueA ).isNotNull ();
289+ assertThat (bodyValueA .getType ()).isEqualTo (ValueType .STRING );
290+ assertThat (bodyValueA .asString ()).isEqualTo ("yyyPassword={x} aba Password={x} xyx" );
268291 }
269292
270293 @ Test
@@ -292,6 +315,9 @@ void simpleRenameLogTestWithLogProcessor() {
292315 // verify that resulting logs are not modified
293316 List <LogRecordData > result = mockExporter .getLogs ();
294317 LogRecordData resultLog = result .get (0 );
295- assertThat (resultLog .getBody ().asString ()).isEqualTo ("locationget1234" );
318+ Value <?> bodyValue = resultLog .getBodyValue ();
319+ assertThat (bodyValue ).isNotNull ();
320+ assertThat (bodyValue .getType ()).isEqualTo (ValueType .STRING );
321+ assertThat (bodyValue .asString ()).isEqualTo ("locationget1234" );
296322 }
297323}
0 commit comments