Skip to content
This repository was archived by the owner on Aug 6, 2024. It is now read-only.

Commit 7392564

Browse files
committed
Adding a "Slow" endpoint
1 parent 0bd8ec9 commit 7392564

File tree

7 files changed

+45
-24
lines changed

7 files changed

+45
-24
lines changed

AspNetCoreMvc/AspNetCoreMvc.csproj

+7
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,11 @@
1010
<PackageReference Include="NewRelic.Agent.Api" Version="9.8.0" />
1111
</ItemGroup>
1212

13+
<ItemGroup>
14+
<Content Update="Views\Agents\SlowResponse.cshtml">
15+
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
16+
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
17+
</Content>
18+
</ItemGroup>
19+
1320
</Project>

AspNetCoreMvc/AspNetCoreMvc.csproj.user

-9
This file was deleted.

AspNetCoreMvc/Controllers/AgentsController.cs

+19-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
using AspNetCoreMvc.Models;
1+
using System;
2+
using AspNetCoreMvc.Models;
23
using Microsoft.AspNetCore.Mvc;
34
using Microsoft.Extensions.Logging;
45
using System.Diagnostics;
56
using System.Runtime.CompilerServices;
7+
using System.Threading;
68

79
namespace AspNetCoreMvc.Controllers
810
{
@@ -33,7 +35,22 @@ public IActionResult Create()
3335
return View();
3436
}
3537

36-
[MethodImpl(MethodImplOptions.NoInlining)]
38+
[MethodImpl(MethodImplOptions.NoInlining)]
39+
public IActionResult SlowResponse()
40+
{
41+
var helpers = new Helpers();
42+
43+
var randomWait = new Random();
44+
var waitTime = randomWait.Next(150, 250);
45+
Thread.Sleep(waitTime);
46+
47+
ViewData["InstanceMethod"] = helpers.CustomMethodOne("Waiting...");
48+
ViewData["StaticMethod"] = Helpers.CustomStaticMethodOne($"We waited an extra {waitTime} milliseconds on this one!");
49+
50+
return View();
51+
}
52+
53+
[MethodImpl(MethodImplOptions.NoInlining)]
3754
public IActionResult Destroy()
3855
{
3956
var helpers = new Helpers();

AspNetCoreMvc/Properties/PublishProfiles/FolderProfile.pubxml.user

-10
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@{
2+
ViewData["Title"] = "Slow Response";
3+
}
4+
5+
<div class="text-center">
6+
<p>Slow Response</p>
7+
<p>@ViewData["InstanceMethod"]</p>
8+
<p>@ViewData["StaticMethod"]</p>
9+
</div>

CodeLevelMetricsDemo.sln

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 16
4-
VisualStudioVersion = 16.0.32228.343
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.5.33424.131
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AspNetCoreMvc", "AspNetCoreMvc\AspNetCoreMvc.csproj", "{9CF5225C-2224-48D5-B9A6-F34C6BF20294}"
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNetCoreMvc", "AspNetCoreMvc\AspNetCoreMvc.csproj", "{9CF5225C-2224-48D5-B9A6-F34C6BF20294}"
77
EndProject
88
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{E7CB6756-501B-477F-9FB2-F3FEA533F459}"
99
ProjectSection(SolutionItems) = preProject
1010
.gitignore = .gitignore
11+
docker-compose.yml = docker-compose.yml
12+
entrypoint.sh = entrypoint.sh
1113
README.md = README.md
14+
tester.sh = tester.sh
1215
EndProjectSection
1316
EndProject
1417
Global

tester.sh

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ while true; do
1515

1616
# agents/destroy
1717
curl -s -o /dev/null http://localhost:80/Agents/Destroy
18+
19+
# agents/slowresponse
20+
curl -s -o /dev/null http://localhost:80/Agents/SlowResponse
21+
1822
echo "Completed a full set of operations." >> $logfile
1923

2024
# go too fast and the agent starts sampling

0 commit comments

Comments
 (0)