diff --git a/sdk/monitor/monitor-opentelemetry-exporter/samples-dev/httpSample.ts b/sdk/monitor/monitor-opentelemetry-exporter/samples-dev/httpSample.ts index 291af26400df..fb4ca78c8835 100644 --- a/sdk/monitor/monitor-opentelemetry-exporter/samples-dev/httpSample.ts +++ b/sdk/monitor/monitor-opentelemetry-exporter/samples-dev/httpSample.ts @@ -43,9 +43,10 @@ import http from "http"; * HTTP SERVER SETUP **********************************************************************/ /** Starts a HTTP server that receives requests on sample server port. */ +let server: http.Server; function startServer(port: number) { // Creates a server - const server = http.createServer(handleRequest); + server = http.createServer(handleRequest); // Starts the server server.listen(port, () => { console.log(`Node HTTP listening on ${port}`); @@ -74,6 +75,8 @@ function handleRequest(request: any, response: any) { setTimeout(() => { span.end(); response.end("Hello World!"); + // terminate the process to stop CI pipeline from running forever + server.close(); }, 2000); }); } diff --git a/sdk/monitor/monitor-opentelemetry-exporter/samples/v1/javascript/httpSample.js b/sdk/monitor/monitor-opentelemetry-exporter/samples/v1/javascript/httpSample.js index 496419e7a79a..3859f6d7bbe7 100644 --- a/sdk/monitor/monitor-opentelemetry-exporter/samples/v1/javascript/httpSample.js +++ b/sdk/monitor/monitor-opentelemetry-exporter/samples/v1/javascript/httpSample.js @@ -43,9 +43,10 @@ const http = require("http"); * HTTP SERVER SETUP **********************************************************************/ /** Starts a HTTP server that receives requests on sample server port. */ +let server; function startServer(port) { // Creates a server - const server = http.createServer(handleRequest); + server = http.createServer(handleRequest); // Starts the server server.listen(port, () => { console.log(`Node HTTP listening on ${port}`); @@ -74,6 +75,8 @@ function handleRequest(request, response) { setTimeout(() => { span.end(); response.end("Hello World!"); + // terminate the process to stop CI pipeline from running forever + server.close(); }, 2000); }); } diff --git a/sdk/monitor/monitor-opentelemetry-exporter/samples/v1/typescript/src/httpSample.ts b/sdk/monitor/monitor-opentelemetry-exporter/samples/v1/typescript/src/httpSample.ts index 291af26400df..fb4ca78c8835 100644 --- a/sdk/monitor/monitor-opentelemetry-exporter/samples/v1/typescript/src/httpSample.ts +++ b/sdk/monitor/monitor-opentelemetry-exporter/samples/v1/typescript/src/httpSample.ts @@ -43,9 +43,10 @@ import http from "http"; * HTTP SERVER SETUP **********************************************************************/ /** Starts a HTTP server that receives requests on sample server port. */ +let server: http.Server; function startServer(port: number) { // Creates a server - const server = http.createServer(handleRequest); + server = http.createServer(handleRequest); // Starts the server server.listen(port, () => { console.log(`Node HTTP listening on ${port}`); @@ -74,6 +75,8 @@ function handleRequest(request: any, response: any) { setTimeout(() => { span.end(); response.end("Hello World!"); + // terminate the process to stop CI pipeline from running forever + server.close(); }, 2000); }); } diff --git a/sdk/monitor/test-resources.json b/sdk/monitor/test-resources.json index 56e3c77bb1d7..8457dc138db3 100644 --- a/sdk/monitor/test-resources.json +++ b/sdk/monitor/test-resources.json @@ -27,7 +27,8 @@ "logReaderRoleId": "73c42c96-874c-492b-b04d-ab87d138a893", "metricPublisherRoleId": "3913510d-42f4-4e42-8a64-420c390055eb", "workspaceName": "[concat(parameters('baseName'), '-logs')]", - "secondaryWorkspaceName": "[concat(parameters('baseName'), '-logs2')]" + "secondaryWorkspaceName": "[concat(parameters('baseName'), '-logs2')]", + "appInsightsName": "[concat(parameters('baseName'), '-ai')]" }, "resources": [ { @@ -92,6 +93,16 @@ "principalId": "[parameters('testApplicationOid')]", "scope": "[resourceGroup().id]" } + }, + { + "type": "Microsoft.Insights/components", + "apiVersion": "2015-05-01", + "location": "[parameters('location')]", + "name": "[variables('appInsightsName')]", + "properties": { + "Application_Type": "web", + "applicationId": "[variables('appInsightsName')]" + } } ], "outputs": { @@ -114,6 +125,10 @@ "METRICS_RESOURCE_NAMESPACE": { "value": "Microsoft.OperationalInsights/workspaces", "type": "string" + }, + "APPLICATIONINSIGHTS_CONNECTION_STRING": { + "value": "[reference(resourceId('Microsoft.Insights/components', variables('appInsightsName')), '2015-05-01').ConnectionString]", + "type": "string" } } }