Make sure you have followed this installation guide to set up the Tusk Drift CLI and SDK before moving forward with this guide.
Record and replay your first trace
1
Set sampling to 100% temporarily
In the recording section of your
.tusk/config.yaml file, set sampling_rate to 1.0 to capture all traffic while testing.2
Start the service in record mode
Start your service in your dev or staging environment while enabling auto-recording of traces with If package.json is updated with the You should then see logs indicating Tusk Drift is active. Example logs:
TUSK DRIFT_MODE=RECORD.dev:record script, you can run:The start command used in your
.tusk/config.yaml should be the plain dev script without TUSK_DRIFT_MODE in it.3
Generate traffic
Manually hit a simple endpoint that includes some database and/or network calls. For example:This will record a trace file, which will show up in
.tusk/traces in your repo.4
Stop recording
Stop the server after a few seconds with
Ctrl+C to allow time for recorded traces to be exported.5
List and replay traces
In your project directory, you can view the list of recorded traces by running:You can select which ones to replay as tests locally. Successful replay confirms deterministic behavior with outbound calls mocked from recordings.If you’d like to replay all traces and export the traces to Tusk Drift Cloud, run:The
--cloud flag works for tusk list too.Rollout guidance
- Start recording in your dev or staging environment with
sampling_rate≤ 0.1; expand to production and increase sampling rate after you validate fidelity and coverage.- Gate production rollout of Tusk Drift behind a feature flag or environment toggle.
- Customize the Tusk config file (
.tusk/config.yaml) to suit your needs- Set
export_spans: trueto use our Cloud platform for AI-powered root cause analysis and suggested fixes. This allows you to integrate replay in CI to block regressions before merge. Read more. - Set
enable_env_var_recording: trueif your app’s business logic depends on environment variables; this reduces the occurrence of noisy deviations in actual vs. expected output.
- Set
- Enable service logs when investigating issues. Logs are written under
.tusk/logs/when enabled.
Troubleshooting
I'm not seeing any traces being recorded
I'm not seeing any traces being recorded
- Confirm that the
sampling_ratein your.tusk/config.yamlis not set to0(set it to1.0while testing). - Verify
TuskDrift.markAppAsReady()is called after the server starts. - Ensure the endpoint is not excluded by your PII redaction rules.
- Confirm that you’re setting
TUSK_DRIFT_MODE=RECORDwhen starting your service. IfTUSK_DRIFT_MODEis unset or set toDISABLED, Tusk Drift won’t record any data. - The trace you’re trying to record may be larger than 1 MB. Consider setting
enable_env_var_recording: falsein your Tusk config file if your application’s business logic does not depend on environment variables.
I'm running into errors when replaying traces
I'm running into errors when replaying traces
- Re-run the tests with service logs (logs from the SDK will also be present):
Read the log file in
.tusk/logsto investigate the error. Optionally, to get the full debug logs including the service logs, run: - Start with a simple endpoint (no auth or minimal dependencies) to validate your setup.
- Confirm your dependency versions are within supported ranges listed here.
It looks like my packages aren't supported
It looks like my packages aren't supported
If you rely on packages outside the supported technologies or version ranges, reach out to support@usetusk.ai for guidance.
FAQ
How does Drift handle PII and sensitive data?
How does Drift handle PII and sensitive data?
You can configure transforms for specific data patterns to redact, mask, replace, or drop sensitive data. All data is encrypted in transit and at rest, and we follow SOC 2 Type II compliance standards.
Will Drift impact my application's performance?
Will Drift impact my application's performance?
Expect a 1-2% throughput overhead. Transforms result in a 1.0% increase in tail latency when a small number of transforms are registered; its impact scales linearly with the number of transforms registered. For more details, see our performance benchmarks.If
TUSK_DRIFT_MODE is set to DISABLED or left unset, there is zero performance impact since no instrumentation or recording occurs.What happens if my API schema changes?
What happens if my API schema changes?
Drift detects schema changes and––with the Cloud platform––uses its understanding of your PR’s code and business context to flag breaking changes as issues while allowing intended changes to pass through.