The Simplest Way to Make Lightstep and dbt Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Teams use lightstep and dbt together to track data pipeline runs and trace slow models. Dbt builds SQL tables in your warehouse, while Lightstep collects traces and timing metrics from those jobs. This setup lets data engineers see why a daily run took too long. It links code changes in your data project to real warehouse load and latency spikes. How lightstep and dbt share data and permissions Dbt runs SQL models inside your cloud data warehouse on a set schedule. Each run creates logs, run

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

Teams use lightstep and dbt together to track data pipeline runs and trace slow models. Dbt builds SQL tables in your warehouse, while Lightstep collects traces and timing metrics from those jobs.

This setup lets data engineers see why a daily run took too long. It links code changes in your data project to real warehouse load and latency spikes.

How lightstep and dbt share data and permissions

Dbt runs SQL models inside your cloud data warehouse on a set schedule. Each run creates logs, run results, and timing details for every model and test.

A small collector or webhook reads this metadata when a job starts and ends. The collector turns each model step into a trace span and sends it to Lightstep.

This flow needs two distinct sets of keys and roles to work well. First, dbt needs a warehouse role that can read source tables and write target schemas.

Second, the trace collector needs an ingest token to send span data to Lightstep. The warehouse role should never share keys with your trace ingest service.

Data flows one way during this process. Dbt writes rows to the warehouse, and the wrapper sends run times to Lightstep. Raw table rows stay inside the warehouse.

Still, model logs can sometimes hold raw query text or filter values. If a query filters by emails or phone numbers, that text might enter a log. Masking rewrites matched fields in results before logs leave the runner.

Common failure modes and how to scope roles

Many teams start by using one shared admin account for all dbt jobs. That same job runner often holds a broad Lightstep API key with full project rights.

This shortcut creates big risks when a runner host fails or leaks its state. Anyone with that runner key can alter warehouse tables or delete trace dashboards.

Unlogged manual runs cause another common failure mode for data teams. Engineers often run dbt from laptops using production keys to fix a broken table fast.

End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

When they do this, the warehouse runs the SQL without sending traces to Lightstep. You get sudden warehouse lag, no trace data, and no clear audit trail.

To fix this, split your roles by job type and runtime stage. Give the scheduled dbt runner a narrow warehouse role that only writes to staging schemas.

Give the trace exporter a write-only Lightstep ingest token that cannot read or change settings. Store both keys in a secret store and load them only when a job runs.

Keeping pipeline runs fast and traceable

Once roles are scoped, teams can tie every warehouse query back to a single trace. You can add the trace ID as a query tag on each dbt model run.

When a model slows down, you look up that tag in your warehouse query history. You see the exact SQL step alongside the full pipeline trace in Lightstep.

This helps both app engineers and data engineers share the same view during an outage. If a slow warehouse lock delays an API, both teams see the root cause fast.

Keep your trace payloads small so the collector does not slow down your job runner. Send only model names, run status, row counts, and step duration to Lightstep.

Drop full SQL bodies and sample data rows from your trace tags. If query tags hold card numbers or national IDs, masking rewrites matched fields in results.

Review your job runner keys and warehouse roles every quarter. Rotate ingest tokens and drop old user keys that no longer need production warehouse permissions.

Add runtime guardrails and masking beside your databases and APIs

Login rules, role grants, and CI checks govern who connects to your stack. Yet any allowed script, engineer, or AI agent still runs commands with the full scope of its role. For workloads on Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes, SSH, or internal HTTP services, hoop.dev sits beside the service as an open-source proxy, a sidecar for your database or API.

Before a query runs, hoop.dev guardrails check the statement against your rules. An AI Analyzer you configure can score intent or hold risky calls for human review. Next, hoop.dev data masking rewrites sensitive fields in responses, and each verdict is logged per listener. Explore the MIT-licensed project on GitHub.

Frequently asked questions

Does Lightstep read raw table data from dbt models?

No, Lightstep only receives timing spans, job status, and model metadata from your job runner. Raw table rows stay inside your cloud data warehouse during and after the run.

Have your job runner inject the current trace ID into the SQL query comment. You can then match the slow span in Lightstep to the exact warehouse query log.

Should developers use the production Lightstep token for local dbt runs?

No, local runs should use a separate test project token or skip trace export. This keeps test noise out of production alerts and protects your live ingest key.

The query runs. The emails stay hidden.