Outside Kubernetes
Run the LogDrop Python agent on a host, with systemd or in a container.
Outside Kubernetes you install the agent from PyPI next to your service's dependencies, start the service with logdrop-run, and configure the agent with LOGDROP_* environment variables. Your code does not change.
You need a traces ingest key and the other items in Before you start, and the Python requirements.
1. Install the agent and store the key
The agent is the PyPI package logdrop-agent. It sends traces to LogDrop with your traces ingest key, which you keep in a file.
Install the agent in the same environment (virtualenv) as your service:
pip install logdrop-agent==0.1.0a1Store the key in a file that only the service user can read:
sudo mkdir -p /etc/logdrop
printf 'Traces key (paste it once, then press Enter): ' && read -rs LOGDROP_TRACE_KEY && echo
if [[ $LOGDROP_TRACE_KEY == ldtk_* && ${#LOGDROP_TRACE_KEY} -eq 71 ]]; then
printf '%s' "$LOGDROP_TRACE_KEY" | sudo tee /etc/logdrop/trace-ingest-key >/dev/null
else
echo 'That is not one traces key (it starts with ldtk_ and has 71 characters). Paste it once.'
fi
unset LOGDROP_TRACE_KEY
sudo chown <service user> /etc/logdrop/trace-ingest-key && sudo chmod 600 /etc/logdrop/trace-ingest-key2. Start your service with logdrop-run
logdrop-run comes with logdrop-agent and starts your service with the agent loaded. The agent takes its settings from LOGDROP_* environment variables.
Put logdrop-run in front of the command that starts your service:
export LOGDROP_ENDPOINT=https://otel.logdrop.io
export LOGDROP_INGEST_KEY_FILE=/etc/logdrop/trace-ingest-key
export LOGDROP_SERVICE=orders
export LOGDROP_ENVIRONMENT=production
export LOGDROP_RELEASE=1.4.2
logdrop-run gunicorn app:app # or: logdrop-run python app.py, logdrop-run uvicorn main:appThe process then writes one line to standard error:
[logdrop-agent] INFO LogDrop Python agent 0.1.0a1 is tracing service "orders" (environment "production") to otel.logdrop.io.logdrop-run puts the agent's start-up directory first on PYTHONPATH, keeps the entries you already have there, and replaces itself with your command, so signals, the exit code and the process ID stay your command's. A pre-fork server such as gunicorn prints the line once; its worker processes are traced too.
As a systemd service
When systemd starts your service, set the LOGDROP_* variables with Environment= lines and put logdrop-run in front of the command in ExecStart:
[Service]
WorkingDirectory=/opt/orders
Environment=LOGDROP_ENDPOINT=https://otel.logdrop.io
Environment=LOGDROP_INGEST_KEY_FILE=/etc/logdrop/trace-ingest-key
Environment=LOGDROP_SERVICE=orders
Environment=LOGDROP_ENVIRONMENT=production
ExecStart=/opt/orders/.venv/bin/logdrop-run /opt/orders/.venv/bin/gunicorn app:appIn a container without Kubernetes
Install logdrop-agent in the image with your other dependencies, put logdrop-run in front of the command, mount the key file read-only and set the same variables:
RUN pip install --no-cache-dir -r requirements.txt logdrop-agent==0.1.0a1
CMD ["logdrop-run", "gunicorn", "app:app"]docker run -v /etc/logdrop/trace-ingest-key:/run/secrets/logdrop-trace-ingest-key:ro \
-e LOGDROP_ENDPOINT=https://otel.logdrop.io -e LOGDROP_INGEST_KEY_FILE=/run/secrets/logdrop-trace-ingest-key \
-e LOGDROP_SERVICE=orders -e LOGDROP_ENVIRONMENT=production <your image>The key in a file or in a variable
LOGDROP_INGEST_KEY (the key itself in a variable) works too, but prefer the file:
- the agent re-reads the file every 10 seconds, so you can rotate the key without a restart;
- a variable is visible to anyone who can read the process environment.
Set one of the two, not both.
Things to know
These points describe how the agent fits into your service's environment and processes. Check them before you run traced services in production.
- pip installs the agent's OpenTelemetry packages in exact versions. If your service already pins other versions of them, pip reports the conflict when you install; see Your packages and the agent's.
- Package managers and tools (
pip,poetry,uv,pipenvand others) that inheritPYTHONPATHare never traced. - Outside containers, the agent adds the host ID and host name to every trace.
- Each process gets a new instance ID in APM. Set
LOGDROP_SERVICE_INSTANCE_IDto a stable value if restarts should count as the same instance. - The agent keeps the spans waiting to be sent in memory (at most 2,048 by default), not on disk. When the process exits normally, the agent sends what is left for up to 10 seconds first. A process killed by a signal it does not handle does not wait: call
LogDrop.flushbefore a batch job exits. - Overhead, measured with a FastAPI service on Python 3.13: about 0.05 s more start-up and about 15 MiB more memory per process.
All settings are listed in Agent settings.
.png)