DevLens

Connect a backend

Any backend that uses OpenTelemetry can send its traces to DevLens: Python, Go, Java, .NET, Ruby, PHP, Node and more. Keep your usual OpenTelemetry setup and point it here.

Point OpenTelemetry at DevLens

Choose your stack. Most languages need no code changes: OpenTelemetry's own tools instrument your app when it starts, and a few environment variables send its traces here. Use the project's secret key; the same picker appears in your project's settings with its keys filled in. DevLens accepts OTLP over HTTP as protobuf or JSON, optionally gzip-compressed.

Using an AI coding agent? Set up with your agent copies the steps for your stack as a prompt to paste into Claude Code, Cursor or any agent, which then makes the changes in your repository. Your secret key is never in the prompt: paste it into your environment file yourself.

What is your backend written in?

No code changes: OpenTelemetry instruments your app when it starts.

Copies these steps as a prompt for Claude Code, Cursor or any coding agent. Your secret key isn't included.

  1. 1. Install

    Install (Python)
    pip install opentelemetry-distro opentelemetry-exporter-otlp-proto-http
    opentelemetry-bootstrap -a install   # adds instrumentation for the libraries you use
  2. 2. Set the environment

    Environment (Python)
    export OTEL_SERVICE_NAME="my-api"
    export OTEL_TRACES_EXPORTER="otlp"
    export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT="https://devlenshq.dev/api/otlp/v1/traces"
    export OTEL_EXPORTER_OTLP_TRACES_HEADERS="x-devlens-key=<your sk_ secret key>"
    export OTEL_EXPORTER_OTLP_TRACES_PROTOCOL="http/protobuf"
    export OTEL_METRICS_EXPORTER="none"
    export OTEL_LOGS_EXPORTER="none"
    # Optional: file:line inside your repository, and links to GitHub (run from the repository root)
    export OTEL_RESOURCE_ATTRIBUTES="devlens.repo_root=$PWD,devlens.commit_sha=<40-character commit>"
  3. 3. Start your app

    Start (Python)
    opentelemetry-instrument python app.py
    # or: opentelemetry-instrument gunicorn app:app
    # or: opentelemetry-instrument flask --app app run
  4. 4. Record the browser (recommended)

    So the click that started a request joins its trace. Works with any frontend; add your site to the project's allowed origins.

    Install (browser)
    npm install @devlenshq/sdk-browser
    Browser setup
    import { init, track } from "@devlenshq/sdk-browser";
    
    // Once, when your frontend starts:
    init({ endpoint: "https://devlenshq.dev/api/ingest", publicKey: "pk_…" });
    
    // Wrap each user action that calls your API, and use the fetch it hands you:
    const res = await track("Submit registration", (fetch) => fetch("/api/register", { method: "POST", body }));

devlens.repo_root lets DevLens turn absolute paths in stack traces into paths inside your repository, and devlens.commit_sha turns them into links to the exact line on GitHub. Without them you still get traces; file locations that can't be made relative are left out rather than guessed. Rust, Elixir and other languages with an OpenTelemetry SDK work the same way: install its OTLP HTTP exporter and set the same variables.

Linking the browser

Add the browser SDK to your frontend as usual. Its requests carry a standard traceparent header, which OpenTelemetry continues on the server by default, so the click, the request, the server code and the database query appear as one trace. For an API on another origin, list it in traceOrigins and allow the header in its CORS settings (see Troubleshooting).

What DevLens reads from a trace

DevLens showsFrom OpenTelemetry
Database stepSpans with a database system (db.system.name). The table and operation, never the query.
Server stepSpans with an HTTP method: method, path (no query string) and status.
Function stepEvery other span, such as your own code wrapped in a span.
Failed, and the errorSpans with an error status; the message from the recorded exception, first line only.
File and linecode.file.path and code.line.number, or the first frame of your own code in the exception's stack trace.

What is never stored

OpenTelemetry records more than DevLens needs. These are dropped on arrival, before anything is saved: SQL text (db.query.text, db.statement), full URLs and query strings, request headers, user attributes (enduser.*, user.*), and every attribute not listed above. Database error messages keep only their first line, and quoted values in them are hidden: Duplicate entry 'alice@example.com' is stored as Duplicate entry '…'. See Security and privacy.

Quieting noisy instrumentation

Automatic instrumentation can record many small steps (middleware, template rendering, file reads), and every span counts toward the project's 600 spans per minute. Switch off what you don't need, for example OTEL_PYTHON_DISABLED_INSTRUMENTATIONS=jinja2,urllib3, OTEL_NODE_DISABLED_INSTRUMENTATIONS=fs,dns or, for the Java agent, OTEL_INSTRUMENTATION_<NAME>_ENABLED=false.