-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Microsoft/master
pull lastest from Microsoft master
- Loading branch information
Showing
31 changed files
with
791 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
apply plugin: 'war' | ||
|
||
dependencies { | ||
compile aiCoreJar | ||
compile aiWebJar | ||
compile 'com.google.guava:guava:20.0' | ||
|
||
providedCompile 'javax.servlet:javax.servlet-api:3.0.1' | ||
|
||
providedRuntime 'mysql:mysql-connector-java:5.1.44' | ||
|
||
smokeTestCompile 'com.google.guava:guava:23.0' | ||
|
||
testCompile 'com.google.guava:guava:23.0' // VSCODE intellisense bug workaround | ||
} | ||
|
||
compileJava.sourceCompatibility = 1.7 | ||
compileJava.targetCompatibility = 1.7 | ||
compileSmokeTestJava.sourceCompatibility = 1.8 | ||
compileSmokeTestJava.targetCompatibility = 1.8 | ||
|
||
ext.testAppArtifactDir = war.destinationDir | ||
ext.testAppArtifactFilename = war.archiveName |
16 changes: 16 additions & 0 deletions
16
...Apps/FixedRateSampling/src/main/java/com/microsoft/ajl/simplecalc/HealthCheckServlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.microsoft.ajl.simplecalc; | ||
|
||
import javax.servlet.ServletException; | ||
import javax.servlet.annotation.WebServlet; | ||
import javax.servlet.http.HttpServlet; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
import java.io.IOException; | ||
|
||
@WebServlet(description = "smoke test health check", urlPatterns = { "/" }) | ||
public class HealthCheckServlet extends HttpServlet { | ||
@Override | ||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { | ||
resp.getWriter().println("OK"); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...e/testApps/FixedRateSampling/src/main/java/com/microsoft/ajl/simplecalc/ServletFuncs.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.microsoft.ajl.simplecalc; | ||
|
||
import java.io.IOException; | ||
import java.io.PrintWriter; | ||
|
||
import javax.servlet.ServletException; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
public class ServletFuncs { | ||
|
||
protected static void getRenderedHtml(HttpServletRequest request, HttpServletResponse response) | ||
throws ServletException, IOException { | ||
response.setContentType("text/html;charset=UTF-8"); | ||
renderHtml(request, response.getWriter()); | ||
} | ||
|
||
private static void renderHtml(HttpServletRequest req, PrintWriter writer) { | ||
writer.println("<html>"); | ||
writer.println("<head><title>Calculation Result</title></head>"); | ||
writer.println("<body>"); | ||
writer.printf("<h1>%s</h1>", req.getRequestURI()); | ||
writer.println("<h2>OK!</h2>"); | ||
writer.println("</body></html>"); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
...teSampling/src/main/java/com/microsoft/ajl/simplecalc/SimpleFixedRateSamplingServlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.microsoft.ajl.simplecalc; | ||
|
||
import java.io.IOException; | ||
|
||
import javax.servlet.ServletException; | ||
import javax.servlet.annotation.WebServlet; | ||
import javax.servlet.http.HttpServlet; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
import com.microsoft.applicationinsights.TelemetryClient; | ||
import com.microsoft.applicationinsights.telemetry.EventTelemetry; | ||
|
||
/** | ||
* Servlet implementation class SimpleFixedRateSamplingServlet | ||
*/ | ||
@WebServlet(description = "sends 100 event telemetry items with different op ids", urlPatterns = { "/fixedRateSampling" }) | ||
public class SimpleFixedRateSamplingServlet extends HttpServlet { | ||
private static final long serialVersionUID = -5889330779672565409L; | ||
private TelemetryClient client = new TelemetryClient(); | ||
|
||
/** | ||
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse | ||
* response) | ||
*/ | ||
protected void doGet(HttpServletRequest request, HttpServletResponse response) | ||
throws ServletException, IOException { | ||
ServletFuncs.getRenderedHtml(request, response); | ||
client.trackTrace("Trace Test."); | ||
for (int i = 0; i < 100; i++) { | ||
String str = String.format("Event Test %s", i); | ||
EventTelemetry et = new EventTelemetry(str); | ||
et.getContext().getOperation().setId(String.valueOf(i)); | ||
client.trackEvent(et); | ||
} | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
test/smoke/testApps/FixedRateSampling/src/main/resources/ApplicationInsights.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<ApplicationInsights xmlns="http://schemas.microsoft.com/ApplicationInsights/2013/Settings" schemaVersion="2014-05-30"> | ||
|
||
|
||
<!-- The key from the portal: --> | ||
|
||
<InstrumentationKey>00000000-0000-0000-0000-0FEEDDADBEEF</InstrumentationKey> | ||
|
||
<SDKLogger type="CONSOLE"> | ||
<enabled>true</enabled> | ||
<UniquePrefix>JavaSDKLog</UniquePrefix> | ||
</SDKLogger> | ||
|
||
<!-- HTTP request component (not required for bare API) --> | ||
|
||
<TelemetryModules> | ||
<Add type="com.microsoft.applicationinsights.web.extensibility.modules.WebRequestTrackingTelemetryModule" /> | ||
<Add type="com.microsoft.applicationinsights.web.extensibility.modules.WebSessionTrackingTelemetryModule" /> | ||
<Add type="com.microsoft.applicationinsights.web.extensibility.modules.WebUserTrackingTelemetryModule" /> | ||
</TelemetryModules> | ||
|
||
<!-- Events correlation (not required for bare API) --> | ||
<!-- These initializers add context data to each event --> | ||
|
||
<TelemetryInitializers> | ||
<Add type="com.microsoft.applicationinsights.web.extensibility.initializers.WebOperationIdTelemetryInitializer" /> | ||
<Add type="com.microsoft.applicationinsights.web.extensibility.initializers.WebOperationNameTelemetryInitializer" /> | ||
<Add type="com.microsoft.applicationinsights.web.extensibility.initializers.WebSessionTelemetryInitializer" /> | ||
<Add type="com.microsoft.applicationinsights.web.extensibility.initializers.WebUserTelemetryInitializer" /> | ||
<Add type="com.microsoft.applicationinsights.web.extensibility.initializers.WebUserAgentTelemetryInitializer" /> | ||
</TelemetryInitializers> | ||
|
||
<Channel> | ||
<!-- <EndpointAddress>http://localhost:60606/v2/track</EndpointAddress> --> | ||
<EndpointAddress>http://fakeingestion:60606/v2/track</EndpointAddress> | ||
</Channel> | ||
|
||
<PerformanceCounters> | ||
<UseBuiltIn>False</UseBuiltIn> | ||
</PerformanceCounters> | ||
|
||
<TelemetryProcessors> | ||
<BuiltInProcessors> | ||
<Processor type="FixedRateSamplingTelemetryProcessor"> | ||
<Add name="SamplingPercentage" value="50" /> | ||
<ExcludedTypes> | ||
<ExcludedType>Request</ExcludedType> | ||
</ExcludedTypes> | ||
<IncludedTypes> | ||
<IncludedType>Event</IncludedType> | ||
</IncludedTypes> | ||
</Processor> | ||
</BuiltInProcessors> | ||
</TelemetryProcessors> | ||
</ApplicationInsights> |
12 changes: 12 additions & 0 deletions
12
test/smoke/testApps/FixedRateSampling/src/main/webapp/WEB-INF/web.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="SimpleCalculator_1" version="3.0"> | ||
<display-name>SimpleTelemetry</display-name> | ||
<filter> | ||
<filter-name>ApplicationInsightsWebFilter</filter-name> | ||
<filter-class>com.microsoft.applicationinsights.web.internal.WebRequestTrackingFilter</filter-class> | ||
</filter> | ||
<filter-mapping> | ||
<filter-name>ApplicationInsightsWebFilter</filter-name> | ||
<url-pattern>/*</url-pattern> | ||
</filter-mapping> | ||
</web-app> |
37 changes: 37 additions & 0 deletions
37
...src/smokeTest/java/com/microsoft/applicationinsights/smoketest/FixedRateSamplingTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.microsoft.applicationinsights.smoketest; | ||
|
||
import com.microsoft.applicationinsights.internal.schemav2.Envelope; | ||
import org.junit.*; | ||
|
||
import static org.hamcrest.Matchers.*; | ||
import static org.junit.Assert.*; | ||
|
||
public class FixedRateSamplingTest extends AiSmokeTest { | ||
@Test | ||
@TargetUri("/fixedRateSampling") | ||
public void testFixedRateSamplingInExcludedTypes() { | ||
assertEquals(1, mockedIngestion.getCountForType("RequestData")); | ||
assertEquals(100.0, getSampleRate("RequestData", 0), Math.ulp(50.0)); | ||
} | ||
|
||
@Test | ||
@TargetUri(value = "/fixedRateSampling", delay = 10000) | ||
public void testFixedRateSamplingInIncludedTypes() { | ||
int count = mockedIngestion.getCountForType("EventData"); | ||
assertThat(count, both(greaterThanOrEqualTo(40)).and(lessThanOrEqualTo(60))); | ||
assertEquals(50.0, getSampleRate("EventData", 0), Math.ulp(50.0)); | ||
} | ||
|
||
@Test | ||
@TargetUri("/fixedRateSampling") | ||
public void testFixedRateSamplingNotInExcludedTypes() { | ||
assertEquals(1, mockedIngestion.getCountForType("MessageData")); | ||
assertEquals(100.0, getSampleRate("MessageData", 0), Math.ulp(50.0)); | ||
} | ||
|
||
protected double getSampleRate(String type, int index) { | ||
Envelope envelope = mockedIngestion.getItemsByType(type).get(index); | ||
return envelope.getSampleRate(); | ||
} | ||
|
||
} |
6 changes: 6 additions & 0 deletions
6
test/smoke/testApps/FixedRateSampling/src/smokeTest/resources/appServers.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
jbosseap6 | ||
jbosseap7 | ||
tomcat7 | ||
tomcat8 | ||
tomcat85 | ||
jetty9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
buildscript { | ||
repositories { | ||
mavenCentral() | ||
} | ||
dependencies { | ||
classpath 'org.springframework.boot:spring-boot-gradle-plugin:1.5.19.RELEASE' | ||
} | ||
} | ||
|
||
apply plugin: 'java' | ||
apply plugin: 'eclipse' | ||
apply plugin: 'war' | ||
apply plugin: 'org.springframework.boot' | ||
|
||
compileJava.sourceCompatibility = 1.7 | ||
compileJava.targetCompatibility = 1.7 | ||
compileSmokeTestJava.sourceCompatibility = 1.8 | ||
compileSmokeTestJava.targetCompatibility = 1.8 | ||
|
||
dependencies { | ||
compile springBootStarterJar | ||
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web' | ||
compile group: 'org.springframework.boot', name: 'spring-boot-starter-tomcat' | ||
compile 'com.google.guava:guava:20.0' | ||
compile 'org.apache.httpcomponents:httpclient:4.5.3' | ||
|
||
compileOnly 'org.apache.tomcat.embed:tomcat-embed-jasper' | ||
compile 'javax.servlet:jstl' | ||
|
||
compile project(':test:smoke:framework:testCases') | ||
|
||
providedCompile 'javax.servlet:javax.servlet-api:3.0.1' | ||
|
||
providedRuntime 'mysql:mysql-connector-java:5.1.44' | ||
|
||
smokeTestCompile 'com.google.guava:guava:23.0' | ||
testCompile 'com.google.guava:guava:23.0' // VSCODE intellisense bug workaround | ||
|
||
testCompile group: 'junit', name: 'junit', version: '4.12' | ||
} | ||
|
||
configurations { | ||
smokeTestCompile.exclude group:'org.springframework.boot' | ||
smokeTestRuntime.exclude group:'org.springframework.boot' | ||
} | ||
|
||
ext.testAppArtifactDir = war.destinationDir | ||
ext.testAppArtifactFilename = war.archiveName |
Oops, something went wrong.