Skip to content

Commit

Permalink
Fix the filter order in starter (#766)
Browse files Browse the repository at this point in the history
* fixing the filter order in starter

* add smoke test for 500 capturing

* add autoconfigure before for Azure metrics springboot starter and revert the version number update for core sdk

* Polish
  • Loading branch information
dhaval24 authored Nov 2, 2018
1 parent 754c76f commit f01a266
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
spring.boot.starter.version-number=1.1.0-BETA
spring.boot.starter.version-number=1.1.1-BETA
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@
ApplicationInsightsWebModuleConfiguration.class
})
@AutoConfigureBefore(name = {
"io.micrometer.spring.autoconfigure.export.azuremonitor.AzureMonitorMetricsExportAutoConfiguration"
"io.micrometer.spring.autoconfigure.export.azuremonitor.AzureMonitorMetricsExportAutoConfiguration",
"com.microsoft.azure.spring.autoconfigure.metrics.AzureMonitorMetricsExportAutoConfiguration"
})
public class ApplicationInsightsTelemetryAutoConfiguration {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public FilterRegistrationBean webRequestTrackingFilterRegistrationBean(WebReques
FilterRegistrationBean registration = new FilterRegistrationBean();
registration.setFilter(webRequestTrackingFilter);
registration.addUrlPatterns("/*");
registration.setOrder(Ordered.HIGHEST_PRECEDENCE + 10);
registration.setOrder(Ordered.HIGHEST_PRECEDENCE);
return registration;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,9 @@ public String trackEventSpringBoot() {
client.trackEvent("EventDataPropertyTest", properties, metrics);
return "hello";
}

@GetMapping("/throwsException")
public void resultCodeTest() throws Exception {
throw new Exception("This is an exception");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ azure.application-insights.channel.in-process.endpoint-address=http://fakeingest
azure.application-insights.instrumentation-key=00000000-0000-0000-0000-cba987654321
azure.application-insights.logger.level=TRACE
azure.application-insights.default-modules.ProcessPerformanceCountersModule.enabled=false
azure.application-insights.heart-beat.enabled=false
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
import static org.junit.Assert.assertEquals;

import com.microsoft.applicationinsights.internal.schemav2.EventData;
import com.microsoft.applicationinsights.internal.schemav2.RequestData;
import com.microsoft.applicationinsights.smoketest.AiSmokeTest;
import com.microsoft.applicationinsights.smoketest.TargetUri;
import com.microsoft.applicationinsights.telemetry.Duration;
import com.microsoft.localforwarder.library.inputs.contracts.Request;
import org.junit.Test;

public class SpringbootSmokeTest extends AiSmokeTest{
Expand Down Expand Up @@ -34,4 +37,14 @@ public void trackEvent() throws Exception {
assertEquals(expectedProperties, d2.getProperties().get("key"));
assertEquals(expectedMetric, d2.getMeasurements().get("key"));
}

@Test
@TargetUri("/throwsException")
public void testResultCodeWhenRestControllerThrows() throws Exception {
assertEquals(1, mockedIngestion.getCountForType("RequestData"));
RequestData d = getTelemetryDataForType(0, "RequestData");
final String expectedResponseCode = "500";
assertEquals(expectedResponseCode, d.getResponseCode());
assertEquals(false, d.getSuccess());
}
}

0 comments on commit f01a266

Please sign in to comment.