Skip to main content
GreenSlope

Python quickstart

Target: first trace in your tenant in about four minutes. Works with FastAPI, Flask, and Django on Python 3.9+. Uses OpenTelemetry's zero-code auto-instrumentation — you won't touch your app code.

1. Sign up and grab your tenant key

Create a tenant and copy your tenant ingest key. Export it:

export GREENSLOPE_INGEST_KEY="gs_ing_live_…"

2. Install the OTel packages

pip install \
  opentelemetry-api \
  opentelemetry-sdk \
  opentelemetry-exporter-otlp-proto-http \
  opentelemetry-distro \
  opentelemetry-instrumentation

Then pull in the auto-instrumentation for your framework:

pip install opentelemetry-instrumentation-fastapi

3. Configure via environment variables

Zero-code auto-instrumentation reads its config from env vars — no Python imports needed in your app.

export OTEL_SERVICE_NAME="api"
export OTEL_RESOURCE_ATTRIBUTES="service.version=0.0.0,greenslope.release.id=${GIT_SHA:-local}"
export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT="https://ingest.greenslope.io/v1/otel/v1/traces"
export OTEL_EXPORTER_OTLP_TRACES_HEADERS="x-greenslope-key=${GREENSLOPE_INGEST_KEY}"
export OTEL_TRACES_EXPORTER="otlp"

4. Run your app with opentelemetry-instrument

Prefix your existing start command with opentelemetry-instrument:

opentelemetry-instrument uvicorn app.main:app --port 3000

The wrapper discovers installed instrumentations, patches the framework, and starts the exporter. Your app code is untouched.

5. Hit a route

curl http://localhost:3000/health

Verify

Open Live traces at app.greenslope.io. You should see a span for GET /health with all three resource attributes set.

Nothing shows? Check Troubleshooting.

Related