-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
184 additions
and
374 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# syntax=docker/dockerfile:1 | ||
|
||
ARG PYTHON_VERSION=3.12.2 | ||
FROM python:${PYTHON_VERSION}-slim as base | ||
|
||
# Prevents Python from writing pyc files. | ||
# ENV PYTHONDONTWRITEBYTECODE=1 | ||
|
||
# Keeps Python from buffering stdout and stderr to avoid situations where | ||
# the application crashes without emitting any logs due to buffering. | ||
# ENV PYTHONUNBUFFERED=1 | ||
|
||
WORKDIR /app | ||
|
||
# Create a non-privileged user that the app will run under. | ||
# See https://docs.docker.com/go/dockerfile-user-best-practices/ | ||
ARG UID=10001 | ||
RUN adduser \ | ||
--disabled-password \ | ||
--gecos "" \ | ||
--home "/nonexistent" \ | ||
--shell "/sbin/nologin" \ | ||
--no-create-home \ | ||
--uid "${UID}" \ | ||
appuser | ||
|
||
# Download dependencies as a separate step to take advantage of Docker's caching. | ||
# Leverage a cache mount to /root/.cache/pip to speed up subsequent builds. | ||
# Leverage a bind mount to requirements.txt to avoid having to copy them into | ||
# into this layer. | ||
RUN --mount=type=cache,target=/root/.cache/pip \ | ||
--mount=type=bind,source=requirements.txt,target=requirements.txt \ | ||
python -m pip install -r requirements.txt | ||
|
||
ENV OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED=true | ||
|
||
RUN opentelemetry-bootstrap -a install | ||
|
||
COPY . . | ||
|
||
# Switch to the non-privileged user to run the application. | ||
USER appuser | ||
|
||
EXPOSE 8080 | ||
|
||
CMD opentelemetry-instrument --logs_exporter otlp python3 app.py |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
getting-started-guides/python/Instrumented/load-generator.ps1
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
getting-started-guides/python/Instrumented/load-generator.sh
This file was deleted.
Oops, something went wrong.
31 changes: 0 additions & 31 deletions
31
getting-started-guides/python/Instrumented/requirements.txt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Getting Started Guide - Python | ||
|
||
This is a simple application instrumented with [OpenTelemetry Python](https://github.com/open-telemetry/opentelemetry-python). | ||
It demonstrates how to configure OpenTelemetry Python to send data to New Relic. | ||
|
||
## Requirements | ||
|
||
* [Python](https://www.python.org/downloads/) | ||
* [A New Relic account](https://one.newrelic.com/) | ||
* [A New Relic license key](https://docs.newrelic.com/docs/apis/intro-apis/new-relic-api-keys/#license-key) | ||
|
||
## Running the application | ||
|
||
1. Set the following environment variables to configure OpenTelemetry to send | ||
data to New Relic: | ||
|
||
```shell | ||
export OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED=true | ||
export OTEL_EXPORTER_OTLP_ENDPOINT=https://otlp.nr-data.net | ||
export OTEL_EXPORTER_OTLP_HEADERS=api-key=<your_license_key> | ||
export OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT=4095 | ||
export OTEL_SERVICE_NAME=getting-started-python | ||
export OTEL_RESOURCE_ATTRIBUTES=service.instance.id=123 | ||
``` | ||
|
||
* If your account is based in the EU, set the endpoint to: [https://otlp.eu01.nr-data.net](https://otlp.eu01.nr-data.net) | ||
|
||
2. Run the following command to install dependencies: | ||
|
||
```shell | ||
python -m pip install -r requirements.txt | ||
opentelemetry-bootstrap -a install | ||
``` | ||
|
||
3. Run the application with the following command and open | ||
[http://localhost:8080/fibonacci?n=1](http://localhost:8080/fibonacci?n=1) | ||
in your web browser to ensure it is working. | ||
|
||
```shell | ||
opentelemetry-instrument --logs_exporter otlp python3 app.py | ||
``` | ||
|
||
4. Experiment with providing different values for `n` in the query string. | ||
Valid values are between 1 and 90. Values outside this range cause an error | ||
which will show up in New Relic. |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.