@@ -66,39 +66,6 @@ void testTelemetryDataFlow() throws java.lang.Exception {
6666 assertThat (foundRequest ).isTrue ();
6767 }
6868
69- // check if the expected trace/exception documents are present.
70- // With the default filtering configuration, we should not see successful requests/dependencies,
71- // only trace and exception.
72- private void searchDocs (List <DocumentIngress > docs ) {
73- for (DocumentIngress doc : docs ) {
74- if (doc .getDocumentType ().equals (DocumentType .EXCEPTION )
75- && ((Exception ) doc ).getExceptionMessage ().equals ("Fake Exception" )) {
76- foundExceptionDoc = true ;
77- } else if (doc .getDocumentType ().equals (DocumentType .TRACE )
78- && ((Trace ) doc ).getMessage ().equals ("This message should generate a trace" )) {
79- foundTraceDoc = true ;
80- } else {
81- assertThat (doc .getDocumentType ()).isNotEqualTo (DocumentType .REMOTE_DEPENDENCY );
82- assertThat (doc .getDocumentType ()).isNotEqualTo (DocumentType .REQUEST );
83- }
84- }
85- }
86-
87- private void searchMetrics (List <MetricPoint > metrics ) {
88- for (MetricPoint metric : metrics ) {
89- String name = metric .getName ();
90- double value = metric .getValue ();
91- if (name .equals ("\\ ApplicationInsights\\ Dependency Calls/Sec" ) && value == 1 ) {
92- foundDependency = true ;
93- } else if (name .equals ("\\ ApplicationInsights\\ Requests/Sec" ) && value == 1 ) {
94- foundRequest = true ;
95- } else if (name .equals ("\\ Process\\ Physical Bytes" ) || name .equals ("\\ % Process\\ Processor Time Normalized" )) {
96- assertThat (value ).isNotEqualTo (0 );
97- }
98- }
99- }
100-
101-
10269 private void searchPostBody (String postBody ) {
10370 // Each post body is a list with a singular MonitoringDataPoint
10471 List <MonitoringDataPoint > dataPoints = new ArrayList <>();
@@ -117,8 +84,72 @@ private void searchPostBody(String postBody) {
11784 List <DocumentIngress > docs = dataPoint .getDocuments ();
11885 List <MetricPoint > metrics = dataPoint .getMetrics ();
11986
120- searchDocs (docs );
121- searchMetrics (metrics );
87+ confirmDocsAreFiltered (docs );
88+ confirmPerfCountersNonZero (metrics );
89+ foundExceptionDoc = foundExceptionDoc || hasException (docs );
90+ foundTraceDoc = foundTraceDoc || hasTrace (docs );
91+ foundDependency = foundDependency || hasDependency (metrics );
92+ foundRequest = foundRequest || hasRequest (metrics );
93+ }
94+
95+ private void confirmDocsAreFiltered (List <DocumentIngress > docs ) {
96+ for (DocumentIngress doc : docs ) {
97+ assertThat (doc .getDocumentType ()).isNotEqualTo (DocumentType .REMOTE_DEPENDENCY );
98+ assertThat (doc .getDocumentType ()).isNotEqualTo (DocumentType .REQUEST );
99+ }
100+ }
101+
102+ private boolean hasException (List <DocumentIngress > docs ) {
103+ for (DocumentIngress doc : docs ) {
104+ if (doc .getDocumentType ().equals (DocumentType .EXCEPTION )
105+ && ((Exception ) doc ).getExceptionMessage ().equals ("Fake Exception" )) {
106+ return true ;
107+ }
108+ }
109+ return false ;
110+ }
111+
112+ private boolean hasTrace (List <DocumentIngress > docs ) {
113+ for (DocumentIngress doc : docs ) {
114+ if (doc .getDocumentType ().equals (DocumentType .TRACE )
115+ && ((Trace ) doc ).getMessage ().equals ("This message should generate a trace" )) {
116+ return true ;
117+ }
118+ }
119+ return false ;
120+ }
121+
122+ private boolean hasDependency (List <MetricPoint > metrics ) {
123+ for (MetricPoint metric : metrics ) {
124+ String name = metric .getName ();
125+ double value = metric .getValue ();
126+ if (name .equals ("\\ ApplicationInsights\\ Dependency Calls/Sec" )) {
127+ return value == 1 ;
128+ }
129+ }
130+ return false ;
131+ }
132+
133+ private boolean hasRequest (List <MetricPoint > metrics ) {
134+ for (MetricPoint metric : metrics ) {
135+ String name = metric .getName ();
136+ double value = metric .getValue ();
137+ if (name .equals ("\\ ApplicationInsights\\ Requests/Sec" )) {
138+ return value == 1 ;
139+ }
140+ }
141+ return false ;
142+ }
143+
144+ private void confirmPerfCountersNonZero (List <MetricPoint > metrics ) {
145+ for (MetricPoint metric : metrics ) {
146+ String name = metric .getName ();
147+ double value = metric .getValue ();
148+ if (name .equals ("\\ Process\\ Physical Bytes" )
149+ || name .equals ("\\ % Process\\ Processor Time Normalized" )) {
150+ assertThat (value ).isNotEqualTo (0 );
151+ }
152+ }
122153 }
123154
124155 @ Environment (TOMCAT_8_JAVA_8 )
0 commit comments