- \#<tags>
- `string`
+ `#`
+
+ _string_
|
@@ -459,7 +466,7 @@ Here are the types of metrics and how to format them:
```
counter:4|c
- counter:-2|c
+ counter:-2|c
```
At each flush, the current count is sent and reset to `0`. If the count is not updated, at the next flush it will send the value `0`. You can opt to disable this behavior by setting [`expiry-interval`](#configure) to `1ms`.
@@ -531,13 +538,13 @@ You can add tags to your data, which we save as [attributes](/docs/using-new-rel
Here's an example that would create two tags:
- ```
+ ```sh
-e TAGS="environment:production region:us"
```
Here's that environment variable used in the [startup command](#install):
- ```
+ ```sh
docker run \
-d --restart unless-stopped \
--name newrelic-statsd \
@@ -566,7 +573,7 @@ You can add tags to your data, which we save as [attributes](/docs/using-new-rel
Here's an example [NRQL](/docs/query-data/nrql-new-relic-query-language/getting-started/introduction-nrql) query that includes a custom tag:
-```
+```sql
SELECT count(*) FROM Metric WHERE environment = 'production'
```
@@ -583,13 +590,13 @@ You can alert on StatsD data using [NRQL alert conditions](/docs/alerts/new-reli
First, send this data to New Relic’s StatsD container:
- ```
+ ```sh
echo "prod.test.num:32|g" | nc -v -w 1 -u localhost 8125
```
Next, create a [NRQL alert condition](/docs/alerts/new-relic-alerts/defining-conditions/create-alert-conditions-nrql-queries) using this query:
- ```
+ ```sql
SELECT latest(prod.test.num) FROM Metric WHERE metricName = 'prod.test.num'
```
@@ -613,7 +620,7 @@ You can alert on StatsD data using [NRQL alert conditions](/docs/alerts/new-reli
If a metric with a value above 50 is sent, then an incident is created and notified. The incident is closed automatically after 24 hours. To test that the alert is working, run this command:
- ```
+ ```sh
echo "prod.test.num:60|g" | nc -v -w 1 -u localhost 8125
```
@@ -623,7 +630,7 @@ You can alert on StatsD data using [NRQL alert conditions](/docs/alerts/new-reli
To query your data, you'd use any New Relic [query option](/docs/using-new-relic/data/understand-data/query-new-relic-data). For example, you might run a [NRQL](/docs/query-data/nrql-new-relic-query-language/getting-started/introduction-nrql) query like:
-```
+```sql
SELECT count(*) FROM Metric WHERE metricName = 'myMetric' and environment = 'production'
```
diff --git a/src/install/python/python-agent-create-config-file.mdx b/src/install/python/python-agent-create-config-file.mdx
index 1b2c8319627..acc6bb6f2fe 100644
--- a/src/install/python/python-agent-create-config-file.mdx
+++ b/src/install/python/python-agent-create-config-file.mdx
@@ -17,18 +17,15 @@ The Python agent needs some basic configurations to get started. Here are two co
1. Go to a working directory where you can store the file, and run the following:
- ```
+ ```sh
newrelic-admin generate-config YOUR_LICENSE_KEY newrelic.ini
```
2. Edit your `newrelic.ini` and insert values for the following:
- ```
- ...
+ ```ini
license_key = INSERT_YOUR_LICENSE_KEY
- ...
app_name = INSERT_YOUR_APP_NAME
- ...
```
3. Remember where this file is located because you'll use it later in the setup.
@@ -40,9 +37,9 @@ The Python agent needs some basic configurations to get started. Here are two co
>
If you don't use a configuration file, you can use environment variables to set configuration values. While you can create a variety of configurations with environment variables, we recommend you start by setting your license key and app name:
- ```
+ ```sh
export NEW_RELIC_LICENSE_KEY=INSERT_YOUR_LICENSE_KEY
export NEW_RELIC_APP_NAME=INSERT_YOUR_APP_NAME
```
-
\ No newline at end of file
+
diff --git a/src/install/python/python-agent-download.mdx b/src/install/python/python-agent-download.mdx
index 72ba4d46b8d..6d568a16726 100644
--- a/src/install/python/python-agent-download.mdx
+++ b/src/install/python/python-agent-download.mdx
@@ -10,9 +10,9 @@ Download and install the agent package using one of these options:
id="pip"
title="pip install (RECOMMENDED)"
>
- Install the **newrelic** package directly from PyPi by running:
+ Install the `newrelic` package directly from PyPi by running:
- ```
+ ```sh
pip install newrelic
```
@@ -23,7 +23,7 @@ Download and install the agent package using one of these options:
>
Run:
- ```
+ ```sh
easy_install newrelic
```
@@ -43,11 +43,11 @@ Download and install the agent package using one of these options:
>
To obtain the package manually:
- 1. Download the appropriate **tar.gz** file from our [download site](https://download.newrelic.com/python_agent/release).
- 2. Unpack the **tar.gz** file.
+ 1. Download the appropriate `tar.gz` file from our [download site](https://download.newrelic.com/python_agent/release).
+ 2. Unpack the `tar.gz` file.
3. In the top directory of the unpacked package, install it by running:
- ```
+ ```sh
python setup.py install
```
diff --git a/src/install/python/python-agent-non-web-apps.mdx b/src/install/python/python-agent-non-web-apps.mdx
index 904450a6040..d8d70f32e3c 100644
--- a/src/install/python/python-agent-non-web-apps.mdx
+++ b/src/install/python/python-agent-non-web-apps.mdx
@@ -21,22 +21,22 @@ Keep the following in mind:
* If the task to be tracked is running in a background thread of an existing monitored web application process, then initialization of the agent would already be performed so you shouldn't need to repeat this step.
* If instrumenting an application that is not also handling web traffic, you won't need to wrap the WSGI application entry point.
-To get started, add the following to the beginning of the application script file or module that holds your WSGI entry point. In this example, /some/path/newrelic.ini represents the location of the copy of the config file created earlier. The config file must be readable by your web application.
+To get started, add the following to the beginning of the application script file or module that holds your WSGI entry point. In this example, `/some/path/newrelic.ini` represents the location of the copy of the config file created earlier. The config file must be readable by your web application.
-```
+```py
import newrelic.agent
-newrelic.agent.initialize('/some/path/newrelic.ini')
-... YOUR_OTHER_IMPORTS
+newrelic.agent.initialize('some/path/newrelic.ini')
+# YOUR_OTHER_IMPORTS
```
- Unlike standard Python functionality, the import order matters: the agent package must be imported first.
+ Unlike standard Python functionality, the import order matters: the agent package must be imported and [initialized](/docs/agents/python-agent/python-agent-api/initialize) first.
### Wrap the task to be monitored [#wrapping]
Instead of wrapping the WSGI application entry point, you must wrap any function that performs a background task that you wish to track. For example:
-```
+```py
import newrelic.agent
@newrelic.agent.background_task()
@@ -48,7 +48,7 @@ By default the name of the task will be the name of the function the decorator i
If you wish to override the task name, it can be supplied as a named argument to the decorator. An alternate group can also be specified in place of the default `Function`:
-```
+```py
import newrelic.agent
@newrelic.agent.background_task(name='database-update', group='Task')
@@ -58,7 +58,7 @@ def database_update():
If the name of the task needs to be set dynamically, then it will be necessary to use a context manager object instead. When using a context manager object, it is first necessary to retrieve the application object corresponding to the application data is to be reported against. Leaving out the name of the application when retrieving the application object will result in that corresponding to the default application named in the agent configuration being used.
-```
+```py
import newrelic.agent
def execute_task(task_name):
@@ -83,7 +83,7 @@ In this case, one can force registration in one of two ways. The simplest is to
If using an agent configuration file, this is done by adding the following entry to the `newrelic` section of the agent configuration file.:
-```
+```ini
startup_timeout = 10.0
```
@@ -93,7 +93,7 @@ Note that you should be careful about using this startup timeout for a web appli
If necessary, forcing registration of the agent can also be performed in code within the application code as well.
-```
+```py
import newrelic.agent
application = newrelic.agent.register_application(timeout=10.0)
@@ -125,7 +125,7 @@ In this case it may be necessary to increase the shutdown timeout to ensure that
If using an agent configuration file, this is changed by adding an entry:
-```
+```ini
shutdown_timeout = 2.5
```
@@ -141,7 +141,7 @@ One common use case is the monitoring of Django management commands. Because it
Due to the limitation on what Django management commands can be monitored, you need to add to the agent configuration file a special configuration section `[import-hook:django]`. Under this you need to then provide a space separated list under the setting `instrumentation.scripts.django_admin`:
-```
+```ini
[import-hook:django]
instrumentation.scripts.django_admin = syncdb sqlflush
```
@@ -150,15 +150,15 @@ By default, the startup timeout is automatically specified to be 10.0 seconds wh
Once the additional configuration has been specified, you can then run your Django management command wrapped by our `newrelic-admin` wrapper script:
-```
+```sh
NEW_RELIC_CONFIG_FILE=newrelic.ini newrelic-admin run-python manage.py syncdb
```
### A simple "Hello, world!" example [#hello-world]
-Here's a simple `Hello, world` example with manual initialization:
+Here's a simple **Hello, world** example with manual initialization:
-```
+```py
import newrelic.agent
newrelic.agent.initialize('newrelic.ini') #This is required!
diff --git a/src/install/python/python-agent-uvicorn-docker.mdx b/src/install/python/python-agent-uvicorn-docker.mdx
index b659a1003bf..96e672145cb 100644
--- a/src/install/python/python-agent-uvicorn-docker.mdx
+++ b/src/install/python/python-agent-uvicorn-docker.mdx
@@ -31,7 +31,7 @@ Insert this configuration file in the same directory as your Python app.
Create `requirements.txt` (the list of dependencies for Python) by running this command in the directory where your application resides:
-```
+```sh
pip freeze > requirements.txt
```
@@ -39,9 +39,9 @@ pip freeze > requirements.txt
This is the container that runs the agent.
-1. In the directory for the New Relic agent (for example, `newrelic`), create this Dockerfile for the base container (the file name is just `Dockerfile`):
+1. In the directory for the New Relic agent (for example, `newrelic`), create this `Dockerfile` for the base container (the file name is just `Dockerfile`):
- ```
+ ```dockerfile
FROM python:3.9.14-alpine3.16
RUN pip install --no-cache-dir newrelic
@@ -51,58 +51,58 @@ This is the container that runs the agent.
2. Create the container with this command:
- ```
+ ```sh
docker build -t python_newrelic:latest .
```
-3. Change to the directory where your app is located (for example, `src)
+3. Change to the directory where your app is located (for example, `src`)
### E. Create a container for your app
This is the container that will hold your application. It will work in concert with the base container. Note that it pulls in the base container in the `FROM`.
-1. Create the Dockerfile for your app in the same directory as your Python app.
+1. Create the `Dockerfile` for your app in the same directory as your Python app.
* Change `WORKDIR` to match your directory structure.
* Note that we're using `0.0.0.0` instead of something like `127.0.0.1` because you must set a container's main process to bind to the all interface addresses or it will be unreachable from outside the container.
- ```
+ ```dockerfile
FROM python_newrelic:latest
RUN apk add --no-cache bzip2-dev \
- coreutils \
- gcc \
- libc-dev \
- libffi-dev \
- libressl-dev \
- linux-headers
+ coreutils \
+ gcc \
+ libc-dev \
+ libffi-dev \
+ libressl-dev \
+ linux-headers
- WORKDIR INSERT_THE_PATH_TO_YOUR_PYTHON_APP
+ WORKDIR INSERT_THE_PATH_TO_YOUR_PYTHON_APP
- COPY requirements.txt ./
- RUN pip install --no-cache-dir -r requirements.txt
+ COPY requirements.txt ./
+ RUN pip install --no-cache-dir -r requirements.txt
- COPY . .
+ COPY . .
- EXPOSE 8000
+ EXPOSE 8000
- CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
```
2. In the directory with your Dockerfile and your app, build the container with this command:
- ```
- docker build -t my_python_api .
+ ```sh
+ docker build -t my_python_api .
```
### F. Run the containers [#run-container]
Once you have the base New Relic container and a container made for your app, you can run both with this command:
-```
+```sh
docker run \
--e NEW_RELIC_LICENSE_KEY=INSERT_YOUR_LICENSE_KEY \
--e NEW_RELIC_APP_NAME="docker-fastapi-example" \
--p 8000:8000 -it --rm --name CONTAINER_NAME DOCKER_IMAGE:IMAGE_TAG
+ -e NEW_RELIC_LICENSE_KEY=INSERT_YOUR_LICENSE_KEY \
+ -e NEW_RELIC_APP_NAME="docker-fastapi-example" \
+ -p 8000:8000 -it --rm --name CONTAINER_NAME DOCKER_IMAGE:IMAGE_TAG
```
Note the following about this command:
diff --git a/src/install/python/python-frameworks/python-agent-cherrypy.mdx b/src/install/python/python-frameworks/python-agent-cherrypy.mdx
index 9010cb80d06..33422adea52 100644
--- a/src/install/python/python-frameworks/python-agent-cherrypy.mdx
+++ b/src/install/python/python-frameworks/python-agent-cherrypy.mdx
@@ -10,7 +10,7 @@ You need to integrate the Python agent with your application so that your app's
Instead of manually integrating the call to startup the CherryPy WSGI server in your application code, you might be using PasteDeploy with a configuration file like the following:
-```
+```ini
[server:main]
use = egg:PasteScript#cherrypy
host = 127.0.0.1
@@ -19,6 +19,6 @@ port = 8080
When you start up your WSGI application, wrap the running of the `paster` command:
-```
+```sh
NEW_RELIC_CONFIG_FILE=newrelic.ini newrelic-admin run-program paster serve production.ini
-```
\ No newline at end of file
+```
diff --git a/src/install/python/python-frameworks/python-agent-paste.mdx b/src/install/python/python-frameworks/python-agent-paste.mdx
index cbd295bece4..2ef531e182d 100644
--- a/src/install/python/python-frameworks/python-agent-paste.mdx
+++ b/src/install/python/python-frameworks/python-agent-paste.mdx
@@ -10,7 +10,7 @@ You need to integrate the Python agent with your application so that your app's
Instead of manually integrating the call to startup the Paste WSGI server in your application code, you might be using PasteDeploy with a configuration file like the following:
-```
+```ini
[server:main]
use = egg:Paste#http
host = 127.0.0.1
@@ -19,6 +19,6 @@ port = 8080
When you start up your WSGI application, wrap the running of the `paster` command:
-```
+```sh
NEW_RELIC_CONFIG_FILE=newrelic.ini newrelic-admin run-program paster serve production.ini
-```
\ No newline at end of file
+```
diff --git a/src/install/python/python-frameworks/python-agent-unsupported-asgi-frameworks.mdx b/src/install/python/python-frameworks/python-agent-unsupported-asgi-frameworks.mdx
index 6a47615dfc7..e2e52e355f7 100644
--- a/src/install/python/python-frameworks/python-agent-unsupported-asgi-frameworks.mdx
+++ b/src/install/python/python-frameworks/python-agent-unsupported-asgi-frameworks.mdx
@@ -14,15 +14,15 @@ It sounds like you're using an unsupported framework, such as Quart. In cases li
Since you're not using a supported framework, you won't be able to use our admin script that automatically initializes your app; rather, you must initialize the Python agent manually in your web app code. This process involves importing a Python agent package into your app and making a call to initialize the agent. This call modifies your app's import mechanism so that when libraries are imported, the agent listens for the function classes it recognizes.
-To get started, add the following to the beginning of the application script file or module that holds your ASGI entry point. In this example, /some/path/newrelic.ini represents the location of the copy of the config file created earlier. The config file must be readable by your web application.
+To get started, add the following to the beginning of the application script file or module that holds your ASGI entry point. In this example, `/some/path/newrelic.ini` represents the location of the copy of the config file created earlier. The config file must be readable by your web application.
-```
+```py
import newrelic.agent
-newrelic.agent.initialize('/some/path/newrelic.ini')
-... YOUR_OTHER_IMPORTS
+newrelic.agent.initialize('/some/path/newrelic.ini')
+# YOUR_OTHER_IMPORTS
```
- Unlike standard Python functionality, the import order matters: the agent package must be imported and initialized first.
+ Unlike standard Python functionality, the import order matters: the agent package must be imported and [initialized](/docs/agents/python-agent/python-agent-api/initialize) first.
### (Advanced) Configuration file overrides [#overrides]
@@ -34,11 +34,11 @@ If you want to override configurations, here are some options:
id="environment-override"
title="Admin script with deployment environment overrides"
>
- To specify an override in the agent config file that corresponds to a specific deployment environment, supply the environment's name as the second argument to the [`initialize()` function](/docs/agents/python-agent/python-agent-api/initialize). If you have installed the Python package into a Python virtual environment, you must add these lines after you have activated or set up **sys.path** to find your virtual environment.
+ To specify an override in the agent config file that corresponds to a specific deployment environment, supply the environment's name as the second argument to the [`initialize()` function](/docs/agents/python-agent/python-agent-api/initialize). If you have installed the Python package into a Python virtual environment, you must add these lines after you have activated or set up `sys.path` to find your virtual environment.
- ```
+ ```py
import newrelic.agent
- newrelic.agent.initialize('/some/path/newrelic.ini', 'staging')
+ newrelic.agent.initialize('/some/path/newrelic.ini', 'staging')
```
Whenever possible, precede any imports for modules that are going to be instrumented. For some web frameworks this is mandatory. The instrumentation will not work correctly if not placed before all imports that cause code from that framework to be imported.
@@ -50,7 +50,7 @@ If you want to override configurations, here are some options:
>
If you do not use the admin script but still want to use the environment variables `NEW_RELIC_CONFIG_FILE` and `NEW_RELIC_ENVIRONMENT` to configure the agent, you can call the `initialize()` function with no arguments, and they will be read automatically.
- ```
+ ```py
import newrelic.agent
newrelic.agent.initialize()
```
@@ -65,15 +65,15 @@ If you are using an unsupported web framework or are constructing an ASGI applic
If the ASGI application entry point is a function declared in the file itself, use a decorator:
-```
+```py
@newrelic.agent.asgi_application()
def application(environ, start_response):
-...
+ ...
```
If the ASGI application entry point is a function or object imported from a different module, wrap it with a wrapper object:
-```
+```py
import myapp
application = myapp.ASGIHandler()
@@ -82,4 +82,4 @@ application = newrelic.agent.ASGIApplicationWrapper(application)
If a supported web framework is being used, you can still use the decorator or wrapper explicitly if, for example, you want to configure additional ASGI middleware around the supported web framework. This will ensure that execution of all ASGI middleware is also covered by the monitoring done by the agent.
-For more information, see the documentation for the [asgi_application()](/docs/python/python-instrumentation-api#asgi_application) and [ASGIApplicationWrapper](/docs/python/python-instrumentation-api#ASGIApplicationWrapper) wrapper.
+For more information, see the documentation for the [`asgi_application()`](/docs/python/python-instrumentation-api#asgi_application) and [`ASGIApplicationWrapper`](/docs/python/python-instrumentation-api#ASGIApplicationWrapper) wrapper.
diff --git a/src/install/python/python-frameworks/python-agent-unsupported-wsgi-frameworks.mdx b/src/install/python/python-frameworks/python-agent-unsupported-wsgi-frameworks.mdx
index 0900259823f..398312df304 100644
--- a/src/install/python/python-frameworks/python-agent-unsupported-wsgi-frameworks.mdx
+++ b/src/install/python/python-frameworks/python-agent-unsupported-wsgi-frameworks.mdx
@@ -14,15 +14,15 @@ It sounds like you're using an unsupported framework, such as mod_wsgi. In cases
Since you're not using a supported framework, you won't be able to use our admin script that automatically initializes your app; rather, you must initialize the Python agent manually in your web app code. This process involves importing a Python agent package into your app and making a call to initialize the agent. This call modifies your app's import mechanism so that when libraries are imported, the agent listens for the function classes it recognizes.
-To get started, add the following to the beginning of the application script file or module that holds your WSGI entry point. In this example, /some/path/newrelic.ini represents the location of the copy of the config file created earlier. The config file must be readable by your web application.
+To get started, add the following to the beginning of the application script file or module that holds your WSGI entry point. In this example, `/some/path/newrelic.ini` represents the location of the copy of the config file created earlier. The config file must be readable by your web application.
-```
+```py
import newrelic.agent
-newrelic.agent.initialize('/some/path/newrelic.ini')
-... YOUR_OTHER_IMPORTS
+newrelic.agent.initialize('some/path/newrelic.ini')
+# YOUR_OTHER_IMPORTS
```
- Unlike standard Python functionality, the import order matters: the agent package must be imported and initialized first.
+ Unlike standard Python functionality, the import order matters: the agent package must be imported and [initialized](/docs/agents/python-agent/python-agent-api/initialize) first.
### (Advanced) Configuration file overrides [#overrides]
@@ -34,11 +34,11 @@ If you want to override configurations, here are some options:
id="environment-override"
title="Admin script with deployment environment overrides"
>
- To specify an override in the agent config file that corresponds to a specific deployment environment, supply the environment's name as the second argument to the [`initialize()` function](/docs/agents/python-agent/python-agent-api/initialize). If you have installed the Python package into a Python virtual environment, you must add these lines after you have activated or set up **sys.path** to find your virtual environment.
+ To specify an override in the agent config file that corresponds to a specific deployment environment, supply the environment's name as the second argument to the [`initialize()` function](/docs/agents/python-agent/python-agent-api/initialize). If you have installed the Python package into a Python virtual environment, you must add these lines after you have activated or set up `sys.path` to find your virtual environment.
- ```
+ ```py
import newrelic.agent
- newrelic.agent.initialize('/some/path/newrelic.ini', 'staging')
+ newrelic.agent.initialize('/some/path/newrelic.ini', 'staging')
```
Whenever possible, precede any imports for modules that are going to be instrumented. For some web frameworks, including Flask, this is mandatory. The instrumentation will not work correctly if not placed before all imports that cause code from that framework to be imported.
@@ -50,7 +50,7 @@ If you want to override configurations, here are some options:
>
If you do not use the admin script but still want to use the environment variables `NEW_RELIC_CONFIG_FILE` and `NEW_RELIC_ENVIRONMENT` to configure the agent, you can call the `initialize()` function with no arguments, and they will be read automatically.
- ```
+ ```py
import newrelic.agent
newrelic.agent.initialize()
```
@@ -73,15 +73,15 @@ If you are using an unsupported web framework or are constructing a WSGI applica
If the WSGI application entry point is a function declared in the file itself, use a decorator:
-```
+```py
@newrelic.agent.wsgi_application()
def application(environ, start_response):
-...
+ ...
```
If the WSGI application entry point is a function or object imported from a different module, wrap it with a wrapper object:
-```
+```py
import myapp
application = myapp.WSGIHandler()
@@ -90,5 +90,5 @@ application = newrelic.agent.WSGIApplicationWrapper(application)
If a supported web framework is being used, you can still use the decorator or wrapper explicitly if, for example, you want to configure additional WSGI middleware around the supported web framework. This will ensure that execution of all WSGI middleware is also covered by the monitoring done by the agent.
-For more information, see the documentation for the [wsgi_application()](/docs/python/python-instrumentation-api#wsgi_application) and [WSGIApplicationWrapper](/docs/python/python-instrumentation-api#WSGIApplicationWrapper) wrapper.
+For more information, see the documentation for the [`wsgi_application()`](/docs/python/python-instrumentation-api#wsgi_application) and [`WSGIApplicationWrapper`](/docs/python/python-instrumentation-api#WSGIApplicationWrapper) wrapper.
diff --git a/src/install/python/python-frameworks/python-agent-web2py.mdx b/src/install/python/python-frameworks/python-agent-web2py.mdx
index e0fdb123849..3a903c4d5c4 100644
--- a/src/install/python/python-frameworks/python-agent-web2py.mdx
+++ b/src/install/python/python-frameworks/python-agent-web2py.mdx
@@ -8,10 +8,10 @@ You need to integrate the Python agent with your application so that your app's
### How to use with runweb2py [#runweb2py-tip]
-If you run your web application using the **runweb2py** command, use the following:
+If you run your web application using the `runweb2py` command, use the following:
-```
-NEW_RELIC_CONFIG_FILE=/some/path/newrelic.ini newrelic-admin run-program runweb2py
+```sh
+NEW_RELIC_CONFIG_FILE=/some/path/newrelic.ini newrelic-admin run-program runweb2py
```
-`newrelic-admin` is a script that wraps your application startup, so that the agent can monitor your application's major functions. For more on running the wrapper script, see [Running the wrapper script](/docs/agents/python-agent/installation-configuration/python-agent-installation#integration).
\ No newline at end of file
+`newrelic-admin` is a script that wraps your application startup, so that the agent can monitor your application's major functions. For more on running the wrapper script, see [Running the wrapper script](/docs/agents/python-agent/installation-configuration/python-agent-installation#integration).
diff --git a/src/install/python/python-servers/python-agent-ajp-wsgi.mdx b/src/install/python/python-servers/python-agent-ajp-wsgi.mdx
index 99061605801..1bfa9ac9ac9 100644
--- a/src/install/python/python-servers/python-agent-ajp-wsgi.mdx
+++ b/src/install/python/python-servers/python-agent-ajp-wsgi.mdx
@@ -8,10 +8,10 @@ You can use the Python agent with AJP in conjunction with [flup](https://pypi.py
To integrate the Python agent with your app, run the newrelic-admin script in front of your usual app startup command. The admin script was included when you downloaded the Python agent, and you can use a command like this:
-```
+```sh
NEW_RELIC_CONFIG_FILE=newrelic.ini newrelic-admin run-program YOUR_COMMAND_OPTIONS
```
If you have difficulty with this automatic initialization, you can also try our manual instrumentation steps. To get those instructions, go back to the framework question and select **Unsupported WSGI framework**.
-
\ No newline at end of file
+
diff --git a/src/install/python/python-servers/python-agent-daphne.mdx b/src/install/python/python-servers/python-agent-daphne.mdx
index c46f35cc96b..9c65e80b763 100644
--- a/src/install/python/python-servers/python-agent-daphne.mdx
+++ b/src/install/python/python-servers/python-agent-daphne.mdx
@@ -8,8 +8,8 @@ To integrate the Python agent with your app, you can run the newrelic-admin scri
If you start your app with `daphne path_to_app:my_app` and use our Python agent **version 8.0.0.179** or higher, you can use the recommended admin script integration method. The admin script was included when you downloaded the Python agent, and you can use a command like this:
-```
-NEW_RELIC_CONFIG_FILE=path/to/newrelic.ini newrelic-admin run-program daphne path_to_app:my_app
+```sh
+NEW_RELIC_CONFIG_FILE=path/to/newrelic.ini newrelic-admin run-program daphne path_to_app:my_app
```
diff --git a/src/install/python/python-servers/python-agent-fastcgi.mdx b/src/install/python/python-servers/python-agent-fastcgi.mdx
index 4b575129f97..ec3aa0943aa 100644
--- a/src/install/python/python-servers/python-agent-fastcgi.mdx
+++ b/src/install/python/python-servers/python-agent-fastcgi.mdx
@@ -9,7 +9,7 @@ You can use the Python agent with FastCGI in conjunction with [flup](https://pyp
Below is an example of an integrated FastCGI/WSGI adapter for flup and the corresponding newrelic-admin startup command:
-```
+```py
#!/usr/bin/env python
import sys
@@ -28,7 +28,6 @@ def application(environ, start_response):
ret = WSGIServer(application).run()
```
-
-```
+```sh
NEW_RELIC_CONFIG_FILE=newrelic.ini newrelic-admin run-program python app.py
-```
\ No newline at end of file
+```
diff --git a/src/install/python/python-servers/python-agent-gunicorn.mdx b/src/install/python/python-servers/python-agent-gunicorn.mdx
index 7254256f028..3f767041bf0 100644
--- a/src/install/python/python-servers/python-agent-gunicorn.mdx
+++ b/src/install/python/python-servers/python-agent-gunicorn.mdx
@@ -15,17 +15,16 @@ The Python agent supports Gunicorn's:
You can use the recommended admin script integration method with Gunicorn. Here's an example of wrapping your startup command using the admin script:
-```
-NEW_RELIC_CONFIG_FILE=/PATH/TO/newrelic.ini newrelic-admin run-program gunicorn YOUR_COMMAND_OPTIONS
+```sh
+NEW_RELIC_CONFIG_FILE=/PATH/TO/newrelic.ini newrelic-admin run-program gunicorn YOUR_COMMAND_OPTIONS
```
You can also export the config file location before starting Gunicorn:
-```
-NEW_RELIC_CONFIG_FILE=/PATH/TO/newrelic.ini
+```sh
+NEW_RELIC_CONFIG_FILE=/PATH/TO/newrelic.ini
export NEW_RELIC_CONFIG_FILE
-
-newrelic-admin run-program gunicorn YOUR_COMMAND_OPTIONS
+newrelic-admin run-program gunicorn YOUR_COMMAND_OPTIONS
```
### Preloading applications
@@ -44,4 +43,4 @@ For similar reasons, one should avoid executing code to perform tasks in Gunicor
If you have difficulty with this automatic initialization, you can also try our manual instrumentation steps. To get those instructions, go back to the framework question and select **Unsupported WSGI framework**.
-
\ No newline at end of file
+
diff --git a/src/install/python/python-servers/python-agent-hypercorn.mdx b/src/install/python/python-servers/python-agent-hypercorn.mdx
index 61d8bede59c..f5bb209d3bc 100644
--- a/src/install/python/python-servers/python-agent-hypercorn.mdx
+++ b/src/install/python/python-servers/python-agent-hypercorn.mdx
@@ -8,10 +8,10 @@ To integrate the Python agent with your app, you can run the newrelic-admin scri
If you start your app with `hypercorn path_to_app:my_app` and use our Python agent **version 8.0.0.179** or higher, you can use the recommended admin script integration method. The admin script was included when you downloaded the Python agent, and you can use a command like this:
-```
-NEW_RELIC_CONFIG_FILE=path/to/newrelic.ini newrelic-admin run-program hypercorn path_to_app:my_app
+```sh
+NEW_RELIC_CONFIG_FILE=path/to/newrelic.ini newrelic-admin run-program hypercorn path_to_app:my_app
```
If you have difficulty with this automatic initialization, you can also try our manual instrumentation steps. To get those instructions, go back to the framework question and select **Unsupported ASGI framework** or **Unsupported WSGI framework**.
-
\ No newline at end of file
+
diff --git a/src/install/python/python-servers/python-agent-mod-wsgi-express.mdx b/src/install/python/python-servers/python-agent-mod-wsgi-express.mdx
index 098e2e606c1..09145388b90 100644
--- a/src/install/python/python-servers/python-agent-mod-wsgi-express.mdx
+++ b/src/install/python/python-servers/python-agent-mod-wsgi-express.mdx
@@ -8,12 +8,12 @@ If you are using `mod_wsgi-express` version 4.1.0 with a WSGI application, you c
For example, using the agent with Django may require a command similar to the following:
-```
-NEW_RELIC_CONFIG_FILE=newrelic.ini mod_wsgi-express start-server mysite/wsgi.py --with-newrelic
+```sh
+NEW_RELIC_CONFIG_FILE=newrelic.ini mod_wsgi-express start-server mysite/wsgi.py --with-newrelic
```
For more details, contact the Apache/mod_wsgi author on the [mod_wsgi mailing list](http://code.google.com/p/modwsgi/wiki/WhereToGetHelp?tm=6#Asking_Your).
If you have difficulty with this automatic initialization, you can also try our manual instrumentation steps. To get those instructions, go back to the framework question and select **Unsupported ASGI framework**.
-
\ No newline at end of file
+
diff --git a/src/install/python/python-servers/python-agent-tornado.mdx b/src/install/python/python-servers/python-agent-tornado.mdx
index ade2a37dfe7..32fea13dbd4 100644
--- a/src/install/python/python-servers/python-agent-tornado.mdx
+++ b/src/install/python/python-servers/python-agent-tornado.mdx
@@ -12,10 +12,10 @@ To integrate the Python agent with your app, you can run the newrelic-admin scri
You can use the recommended admin script integration method, provided you start your app with `python app.py` and use the Tornado async interface. The admin script was included when you downloaded the Python agent, and you can use a command like this:
-```
-NEW_RELIC_CONFIG_FILE=path/to/newrelic.ini newrelic-admin run-python app.py
+```sh
+NEW_RELIC_CONFIG_FILE=path/to/newrelic.ini newrelic-admin run-python app.py
```
If you have difficulty with this automatic initialization, you can also try our manual instrumentation steps. To get those instructions, go back to the framework question and select **Unsupported WSGI framework**.
-
\ No newline at end of file
+
diff --git a/src/install/python/python-servers/python-agent-uvicorn.mdx b/src/install/python/python-servers/python-agent-uvicorn.mdx
index d5ef3fd2660..f77d80b26f9 100644
--- a/src/install/python/python-servers/python-agent-uvicorn.mdx
+++ b/src/install/python/python-servers/python-agent-uvicorn.mdx
@@ -8,10 +8,10 @@ To integrate the Python agent with your app, you can run the newrelic-admin scri
If you start your app with `python app.py` and use our Python agent **version 5.20.0.149** or higher, you can use the admin script integration method. The admin script was included when you downloaded the Python agent, and you can use a command like this:
-```
-NEW_RELIC_CONFIG_FILE=path/to/newrelic.ini newrelic-admin run-program uvicorn path_to_app
+```sh
+NEW_RELIC_CONFIG_FILE=path/to/newrelic.ini newrelic-admin run-program uvicorn path_to_app
```
If you have difficulty with this automatic initialization, you can also try our manual instrumentation steps. To get those instructions, go back to the framework question and select **Unsupported ASGI framework**.
-
\ No newline at end of file
+
diff --git a/src/install/python/python-servers/python-agent-uwsgi.mdx b/src/install/python/python-servers/python-agent-uwsgi.mdx
index 84858a7aee3..fb89e8d5973 100644
--- a/src/install/python/python-servers/python-agent-uwsgi.mdx
+++ b/src/install/python/python-servers/python-agent-uwsgi.mdx
@@ -32,7 +32,7 @@ When using uWSGI you will need to supply certain specific command line options t
|
- By default uWSGI does not enable threading support within the Python interpreter core. This means it is not possible to create background threads from Python code. As the Python agent relies on being able to create background threads, this option is required. This option will be automatically applied if uWSGI is configured for multiple threads using the --threads option.
+ By default uWSGI does not enable threading support within the Python interpreter core. This means it is not possible to create background threads from Python code. As the Python agent relies on being able to create background threads, this option is required. This option will be automatically applied if uWSGI is configured for multiple threads using the `--threads` option.
|
@@ -52,19 +52,19 @@ When using uWSGI you will need to supply certain specific command line options t
If you are starting your WSGI application under uWSGI using a command of the form:
-```
+```sh
uwsgi --socket /tmp/uwsgi.sock wsgi.py
```
Instead, run:
-```
+```sh
NEW_RELIC_CONFIG_FILE=newrelic.ini newrelic-admin run-program uwsgi --socket /tmp/uwsgi.sock --single-interpreter --enable-threads wsgi.py
```
When doing this, instead of defining the `NEW_RELIC_CONFIG_FILE` environment variable on the same line as executing the command, it can be separately exported and set in the process environment before running the command.
-```
+```sh
NEW_RELIC_CONFIG_FILE=newrelic.ini
export NEW_RELIC_CONFIG_FILE
@@ -89,7 +89,7 @@ If you are using a framework for which the Python agent is not automatically wra
For example, if you're using an INI configuration file you would have:
- ```
+ ```ini
[uwsgi]
socket = /tmp/uwsgi.sock
enable-threads = true
@@ -99,7 +99,7 @@ If you are using a framework for which the Python agent is not automatically wra
Then, you can run:
- ```
+ ```sh
NEW_RELIC_CONFIG_FILE=newrelic.ini newrelic-admin run-program uwsgi --ini uwsgi.ini
```
@@ -110,7 +110,7 @@ If you are using a framework for which the Python agent is not automatically wra
>
When specifying the WSGI application to be served up by uWSGI, you can give a path to the Python WSGI script file or a direct reference to a module and the contained application. For example, you might use the latter if using Django with the configuration:
- ```
+ ```ini
[uwsgi]
socket = /tmp/uwsgi.sock
enable-threads = true
@@ -125,7 +125,7 @@ If you are using a framework for which the Python agent is not automatically wra
Alternatively, you can use the ability of uWSGI to evaluate a small snippet of code in the configuration in order to construct the WSGI application entry point.
- ```
+ ```ini
[uwsgi]
socket = /tmp/uwsgi.sock
enable-threads = true
@@ -148,7 +148,7 @@ If you are using a framework for which the Python agent is not automatically wra
If you're using a master process, and you are seeing no data being reported for the web application running in the worker processes, you should also use lazy loading mode:
- ```
+ ```ini
[uwsgi]
socket = /tmp/uwsgi.sock
enable-threads = true
diff --git a/src/install/python/python-servers/python-agent-waitress.mdx b/src/install/python/python-servers/python-agent-waitress.mdx
index de8ff65b07f..142e83743b9 100644
--- a/src/install/python/python-servers/python-agent-waitress.mdx
+++ b/src/install/python/python-servers/python-agent-waitress.mdx
@@ -12,7 +12,7 @@ The Python agent provides support for the [Waitress](http://pypi.python.org/pypi
You can use the recommended admin script integration method with a command like this:
-```
+```sh
NEW_RELIC_CONFIG_FILE=newrelic.ini newrelic-admin run-program YOUR_COMMAND_OPTIONS
```
@@ -20,7 +20,7 @@ NEW_RELIC_CONFIG_FILE=newrelic.ini newrelic-admin run-program YOUR_COMMAND_OPTIO
Instead of manually integrating the call to startup the Waitress WSGI server in your application code, you might be using PasteDeploy with a configuration file like the following:
-```
+```ini
[server:main]
use = egg:waitress#main
host = 127.0.0.1
@@ -29,10 +29,10 @@ port = 8080
When you start up your WSGI application, wrap the running of the `paster` command:
-```
+```sh
NEW_RELIC_CONFIG_FILE=newrelic.ini newrelic-admin run-program paster serve production.ini
```