@@ -94,6 +94,19 @@ public class ObservabilityConfigImplTest {
9494 + " }\n "
9595 + "}" ;
9696
97+ private static final String VALID_LOG_FILTERS = "{\n "
98+ + " \" project_id\" : \" grpc-testing\" ,\n "
99+ + " \" cloud_logging\" : {\n "
100+ + " \" server_rpc_events\" : [{\n "
101+ + " \" methods\" : [\" service.Service1/*\" , \" service2.Service4/method4\" ],\n "
102+ + " \" max_metadata_bytes\" : 16,\n "
103+ + " \" max_message_bytes\" : 64\n "
104+ + " }"
105+ + " ]\n "
106+ + " }\n "
107+ + "}" ;
108+
109+
97110 private static final String PROJECT_ID = "{\n "
98111 + " \" project_id\" : \" grpc-testing\" ,\n "
99112 + " \" cloud_logging\" : {},\n "
@@ -460,4 +473,20 @@ public void logFilterInvalidMethod() throws IOException {
460473 "invalid service or method filter" );
461474 }
462475 }
476+
477+ @ Test
478+ public void validLogFilter () throws Exception {
479+ observabilityConfig .parse (VALID_LOG_FILTERS );
480+ assertTrue (observabilityConfig .isEnableCloudLogging ());
481+ assertThat (observabilityConfig .getProjectId ()).isEqualTo ("grpc-testing" );
482+ List <LogFilter > logFilterList = observabilityConfig .getServerLogFilters ();
483+ assertThat (logFilterList ).hasSize (1 );
484+ assertThat (logFilterList .get (0 ).headerBytes ).isEqualTo (16 );
485+ assertThat (logFilterList .get (0 ).messageBytes ).isEqualTo (64 );
486+ assertThat (logFilterList .get (0 ).excludePattern ).isFalse ();
487+ assertThat (logFilterList .get (0 ).matchAll ).isFalse ();
488+ assertThat (logFilterList .get (0 ).services ).isEqualTo (Collections .singleton ("service.Service1" ));
489+ assertThat (logFilterList .get (0 ).methods )
490+ .isEqualTo (Collections .singleton ("service2.Service4/method4" ));
491+ }
463492}
0 commit comments