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

Commit 85820c9

Browse files
committed
Add docker-compose.yml and tester.sh to generate traffic
1 parent d28c679 commit 85820c9

File tree

6 files changed

+65
-11
lines changed

6 files changed

+65
-11
lines changed

Diff for: .gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,5 @@ publish/
3636
newrelic/
3737
!newrelic/placeholder.txt
3838
# Visual Studio 2015
39-
.vs/
39+
.vs/
40+
logs/

Diff for: AspNetCoreMvc/Dockerfile

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
22

33
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
4+
RUN apt-get update; apt-get install -y curl
45
WORKDIR /app
56
EXPOSE 80
67

@@ -19,13 +20,15 @@ FROM base AS final
1920
WORKDIR /app
2021
COPY --from=publish /app/publish .
2122
COPY ["newrelic/", "/usr/local/newrelic-netcore20-agent/"]
23+
24+
COPY --chmod=0755 entrypoint.sh /
25+
COPY --chmod=0755 tester.sh /app
26+
2227
ENV CORECLR_ENABLE_PROFILING=1 \
2328
CORECLR_PROFILER={36032161-FFC0-4B61-B559-F6C5D41BAE5A} \
2429
CORECLR_NEWRELIC_HOME=/usr/local/newrelic-netcore20-agent \
2530
CORECLR_PROFILER_PATH=/usr/local/newrelic-netcore20-agent/libNewRelicProfiler.so \
2631
NEW_RELIC_CODE_LEVEL_METRICS_ENABLED=true \
27-
NEW_RELIC_LICENSE_KEY=YOUR_LICENSE_KEY \
28-
NEW_RELIC_APP_NAME=YOUR_APP_NAME
29-
32+
NEW_RELIC_APP_NAME="CSharp Agent CLM Demo"
3033

31-
ENTRYPOINT ["dotnet", "AspNetCoreMvc.dll"]
34+
ENTRYPOINT ["/entrypoint.sh"]

Diff for: README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ There is a .NET Core 3.1 ASP.NET Core MVC based web application contained in the
77
directory. This application is designed to create web transactions with custom instrumented segments.
88

99
By running the demo, the application will be launched and
10-
daemonized and a `tester` shell script will perform [curl](https://curl.se/)
10+
daemonized and a `tester.sh` shell script will perform [curl](https://curl.se/)
1111
commands that generate web traffic to exercise all traced Ruby methods.
1212

1313
## Important Source Files
@@ -74,18 +74,18 @@ This demo can be run in a few different ways:
7474
### Software Prerequisites
7575

7676
- [Docker](https://www.docker.com/get-started/)
77-
- [.NET Core 3.1 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/3.1)
77+
- [.NET Core 6.0 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/6.0)
7878
- Visual Studio
7979
-
8080

8181
### Instructions for Docker (should work on Linux or Windows)
8282

8383
1. Clone this repository
8484
2. Place an extracted copy of the `.NET Core Linux version` of Agent's files in the `newrelic` directory.
85-
3. From `CodeLevelMetricsDemo` directory the Run `docker build -f AspNetCoreMvc\Dockerfile -t clm-aspnetcoremvc:latest .\`
86-
4a. If running in PROD: After the build run `docker run -d --env NEW_RELIC_LICENSE_KEY=<YOUR_LICENSE_KEY> --env NEW_RELIC_APP_NAME=<YOUR_APP_NAME> -p <PORT_YOU_WANT>:80 clm-aspnetcoremvc:latest`
87-
4b. If running in STAGING: After the build run `docker run -d --env NEW_RELIC_LICENSE_KEY=<YOUR_LICENSE_KEY> --env NEW_RELIC_APP_NAME=<YOUR_APP_NAME> --env NEW_RELIC_HOST=staging-collector.newrelic.com -p <PORT_YOU_WANT>:80 clm-aspnetcoremvc:latest`
88-
5. You can exercise the app by going to `https:/localhost:<PORT_YOU_WANT>` and browsing around the UI.
85+
3a. If running in PROD: `export NEW_RELIC_LICENSE_KEY=<YOUR_LICENSE_KEY>; export NEW_RELIC_HOST=collector.newrelic.com`
86+
3b. If running in STAGING: After the build run `export NEW_RELIC_LICENSE_KEY=<YOUR_LICENSE_KEY>; export NEW_RELIC_HOST=staging-collector.newrelic.com`
87+
4. From `CodeLevelMetricsDemo` directory the Run `docker-compose up -d --build`
88+
5. You can exercise the app by going to `https:/localhost:8888` and browsing around the UI.
8989

9090
### Instructions for Visual Studio (Windows)
9191

Diff for: docker-compose.yml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
version: '3.9'
2+
3+
services:
4+
app:
5+
image: clm-aspnetcoremvc:latest
6+
build:
7+
context: .
8+
dockerfile: AspNetCoreMvc/Dockerfile
9+
environment:
10+
# required
11+
NEW_RELIC_LICENSE_KEY: $NEW_RELIC_LICENSE_KEY
12+
# optional
13+
NEW_RELIC_HOST: ${NEW_RELIC_HOST:-}
14+
ports:
15+
- 127.0.0.1:8888:80
16+
stdin_open: true
17+
tty: true
18+
volumes:
19+
- "./logs:/usr/local/newrelic-netcore20-agent/logs"

Diff for: entrypoint.sh

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
3+
cd app
4+
5+
# start app
6+
nohup dotnet AspNetCoreMvc.dll > /usr/local/newrelic-netcore20-agent/logs/app.log 2>&1 &
7+
8+
# generate load
9+
./tester.sh

Diff for: tester.sh

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
logfile="/usr/local/newrelic-netcore20-agent/logs/tester.log"
4+
5+
sleep 5
6+
7+
echo "Running automated tests..." >> $logfile
8+
9+
while true; do
10+
# agents/show
11+
curl -s -o /dev/null http://localhost:80/
12+
13+
# agents/create
14+
curl -s -o /dev/null ttp://localhost:80/Agents/Create
15+
16+
# agents/destroy
17+
curl -s -o /dev/null ttp://localhost:80/Agents/Destroy
18+
echo "Completed a full set of operations." >> $logfile
19+
20+
# go too fast and the agent starts sampling
21+
sleep 3
22+
done

0 commit comments

Comments
 (0)