This demo is meant to provide a proof of concept as well as example data for the experimental source code context for the New Relic Python Agent.
- Docker
- docker-compose (shipped with Docker desktop for Mac)
- GNU Make (Optional, for scripting shortcuts)
- New Relic license key set in environment variable (
export NEW_RELIC_LICENSE_KEY=mylicensekey
) - Port 8000 available (port can also be changed in compose file, eg.
127.0.0.1:9999:8000
for port9999
)
- Build and start the application with
make up
ordocker-compose up -d --build
. - View logs for various components in the generated
logs/
directory. - Stop the application
make down
ordocker-compose down
.
- Python
- Python virtual_env package (if on Python 2)
- New Relic license key set in environment variable (
export NEW_RELIC_LICENSE_KEY=mylicensekey
) - Port 8000 available (port can also be changed in compose file, eg.
127.0.0.1:9999:8000
for port9999
)
- Create a virtual environment with
python -m virtualenv .venv
. - Activate the new virtual environment with
source .venv/bin/activate
(for bash). - Install requirments with
pip install -r requirements.txt
. - Navigate to
src/
withcd src
. - Start the application with
newrelic-admin run-program gunicorn main:app -w 3 -t 120
. - Optionally start the traffic driver from another terminal with
cd src
andlocust --headless --users 5 --spawn-rate 1 -f locustfile.py
- View logs in the
src/logs/
directory. - Stop the application with
Ctrl-C
.
Note: In order to configure the agent to send context attributes, add source_code_context.enabled=True
to the newrelic.ini file. This setting currently defaults to False and if it is not explicitly added to the agent configuration file, no attributes will be attached to any data type.