🎉 GoReplay is now part of Probe Labs. 🎉

Published on 8/22/2026

Your Script for Automation: A GoReplay Workflow Guide

Photo-realistic image where ‘Script Automation’ text is centered on a solid background block in the golden ratio position, sharp and high-contrast; in the background a minimalist developer desk with a blurred laptop terminal showing shell scripts, subtle office elements faded to keep focus, clean and uncluttered.

You already know the pattern. A feature passes unit tests, integration tests, and a clean staging smoke run. Then production traffic hits a code path nobody modeled, a header arrives in a weird order, a session cookie behaves differently than the fixture did, and the bug shows up where it hurts.

That’s why a script for automation matters more than a one-off replay command. Capturing and replaying traffic by hand is useful for debugging a single incident. It’s not enough for a delivery process that needs repeatability, auditability, and a clear pass or fail signal before code moves forward.

The difference is simple. Manual replay is a tool. Scripted replay is a system. Once traffic capture, masking, replay, and validation live in scripts, the workflow stops depending on memory and Slack messages. It becomes something the team can schedule, review, version, and improve.

Why Scripting Your GoReplay Workflow Is a Game-Changer

Synthetic tests miss the messy parts of real systems. They usually hit the happy path, use predictable fixtures, and avoid the request combinations that users generate all day. Real traffic doesn’t.

A scripted replay workflow closes that gap. It gives you a repeatable way to capture representative traffic, sanitize it, replay it against staging or pre-production, and fail fast when the new build breaks expected behavior. That turns replay from a debugging trick into a quality gate.

The timing also makes sense. Over 60% of professionals report an increase in software automation roles at their companies in the past year, and 52% built automations for their IT department, according to Zapier’s automation statistics roundup. That lines up with what many DevOps teams are already doing. They’re moving repetitive operational work into scripts because reliability improves when the process is explicit.

What changes when replay becomes scripted

Three things happen quickly:

  • You remove operator drift. Nobody has to remember the exact flags, filters, and environment variables from the last incident.
  • You get consistent evidence. The same replay job can produce the same logs, the same diffs, and the same exit conditions every time.
  • You can wire it into broader workflow automation so replay isn’t a side task. It becomes part of release hygiene.

Practical rule: If a replay command is important enough to run twice, it’s important enough to turn into a script.

Why one-off commands stop working

Teams often start with a direct terminal command and stop there. That’s fine for learning. It breaks down when you need filtered captures, secret handling, safe storage, and a reliable trigger.

The bigger problem is ownership. A copy-pasted command in an internal doc usually belongs to one engineer, even if nobody says it out loud. A script in version control belongs to the team.

That’s the shift worth making. Not because scripting looks more mature, but because it gives you a stable path from “we can replay traffic” to “we can trust this replay as part of delivery.”

Scripting the Foundation Your Traffic Capture

Bad input ruins the rest of the pipeline. If your capture file is packed with health checks, static asset requests, and noisy probes, your replay job won’t tell you much about application behavior.

Start by treating capture as a production job with its own script, logs, retention rules, and filters. Keep it boring. Boring capture scripts survive handoffs.

A computer screen displays network capture code over a blurred background of a server room data center.

A shell script that captures clean traffic

This pattern works well for Linux hosts where you want a timestamped file and predictable rotation behavior.

Capture script example

#!/usr/bin/env bash
set -euo pipefail

APP_PORT="${APP_PORT:-8080}"
CAPTURE_DIR="${CAPTURE_DIR:-/var/log/gor}"
STAMP="$(date +%Y%m%d-%H%M%S)"
OUT_FILE="${CAPTURE_DIR}/capture-${STAMP}.gor"
LOG_FILE="${CAPTURE_DIR}/capture-${STAMP}.log"

mkdir -p "$CAPTURE_DIR"

exec >>"$LOG_FILE" 2>&1

echo "[INFO] starting capture at $(date -Is)"
echo "[INFO] writing to ${OUT_FILE}"

gor \
  --input-raw :"${APP_PORT}" \
  --output-file "${OUT_FILE}" \
  --http-disallow-url "/health" \
  --http-disallow-url "/metrics" \
  --http-disallow-url "\.(css|js|png|jpg|svg|ico)$"

echo "[INFO] capture stopped at $(date -Is)"

This does four useful things without getting fancy. It timestamps output, writes logs, filters obvious noise, and keeps configuration in environment variables instead of hardcoding it.

If you maintain a library of operational scripts, organize them the same way you would migration or deployment helpers. Teams that struggle with naming and discoverability sometimes use a cataloging tool like Find My Script to keep internal utilities from disappearing into random repos.

Filters that are worth adding early

Don’t try to build a perfect filter set on day one. Start with the requests that always pollute replay analysis.

  • Health endpoints remove constant background traffic.
  • Metrics scrapes stop your observability stack from becoming replay noise.
  • Static assets rarely help when you’re validating API behavior or backend state changes.
  • Known admin paths should usually stay out unless you’re testing those flows intentionally.

A small denylist is better than an aggressive one. If you over-filter, you’ll remove the edge cases that make replay useful.

Keep the first version explainable. If another engineer can’t tell why a URL was excluded, the capture policy is already too complicated.

Add retention before disk becomes the incident

Capture files grow. Handle that in the script layer, not after the filesystem starts paging your team.

A simple cleanup helper is often enough:

#!/usr/bin/env bash
set -euo pipefail

CAPTURE_DIR="${CAPTURE_DIR:-/var/log/gor}"

find "$CAPTURE_DIR" -type f -name "capture-*.gor" -mtime +3 -delete
find "$CAPTURE_DIR" -type f -name "capture-*.log" -mtime +7 -delete

Run cleanup separately from capture. Combining them makes troubleshooting harder because file deletion and packet capture failures end up in the same execution path.

What a good capture script looks like

AreaGood practiceWhat to avoid
OutputTimestamped filesOne file overwritten forever
LoggingDedicated log per runSilent background processes
FilteringSmall, readable denylistGiant regex nobody trusts
RetentionSeparate cleanup scriptManual deletion during incidents

That foundation matters. If the capture step is inconsistent, every replay result is questionable.

Advanced Scripting for Data Masking and Session Handling

A replay pipeline that uses raw production traffic without sanitization usually dies in review. Security, compliance, and platform teams will block it, and they should.

That’s not a niche concern. A frequently overlooked aspect of automation is security. With 70% of automation projects failing audits in compliance-heavy environments, scripting secure data masking for replayed traffic is a requirement for teams that handle sensitive data, as noted in this discussion of automation and compliance risks.

The practical fix is to make masking and session handling first-class steps in the script for automation, not cleanup tasks that happen later.

A five-step process diagram illustrating how to securely capture, mask, and replay production traffic for automated testing.

Mask first and replay second

If you’re replaying authenticated or user-generated traffic, assume requests may contain tokens, cookies, emails, phone numbers, and internal identifiers. Build a transformation layer that rewrites them before they touch your test target.

For teams working through this design, GoReplay’s own guide to data masking best practices is a useful reference point for deciding what to redact, replace, or preserve.

Here’s a common pattern using middleware. The shell script launches the replay, and a small helper rewrites sensitive values:

#!/usr/bin/env bash
set -euo pipefail

INPUT_FILE="${INPUT_FILE:-/var/log/gor/latest.gor}"
TARGET="${TARGET:-http://staging-app}"

gor \
  --input-file "$INPUT_FILE" \
  --output-http "$TARGET" \
  --middleware "./mask-and-rewrite.py"

And the middleware can handle targeted substitutions:

#!/usr/bin/env python3
import sys
import re

for line in sys.stdin:
    line = re.sub(r'Authorization: Bearer [^\r\n]+', 'Authorization: Bearer REDACTED', line)
    line = re.sub(r'("email"\s*:\s*")[^"]+(")', r'\1masked@example.test\2', line)
    line = re.sub(r'("phone"\s*:\s*")[^"]+(")', r'\1MASKED\2', line)
    sys.stdout.write(line)

The point isn’t to build a giant regex engine. It’s to handle the fields your application processes and to keep those rewrite rules versioned beside the replay job.

Session handling needs intent

Masking alone won’t make traffic replay useful. Session state often breaks in staging because cookies, tokens, and environment-specific headers no longer match the target system.

There are usually three workable strategies:

  1. Replace sessions entirely with a staging token or known test identity.
  2. Map production identities to synthetic accounts in middleware.
  3. Drop auth headers for endpoints that can be exercised anonymously in a limited validation run.

Each strategy has trade-offs. Full replacement is simpler, but it can hide authorization bugs. Synthetic account mapping preserves more realistic behavior, but the setup is heavier.

The replay is only as realistic as its state model. If session handling is wrong, the pipeline can produce clean but meaningless results.

A safer session rewrite pattern

For many teams, a header injection approach is easier to maintain than trying to preserve original cookies:

#!/usr/bin/env bash
set -euo pipefail

export STAGING_AUTH_HEADER="Authorization: Bearer ${STAGING_TOKEN}"

gor \
  --input-file "/var/log/gor/latest.gor" \
  --output-http "http://staging-app" \
  --http-set-header "$STAGING_AUTH_HEADER"

Use this when your goal is compatibility validation, not a perfect recreation of production identity behavior.

What belongs in the masking script

  • Secrets and credentials should be replaced or dropped.
  • PII fields should be masked with deterministic or synthetic values.
  • Environment-specific headers should be rewritten to match the test target.
  • Session artifacts should follow a documented rule, not ad hoc edits during incidents.

The scripts that last are narrow and explicit. If you can’t explain why a field is preserved, mask it until there’s a reason not to.

Scheduling Automated Replays for Continuous Testing

A replay script that only runs when somebody remembers it is still manual work. The next step is to put execution on a schedule with logging, locking, and clear failure behavior.

A shell script earns its keep, becoming the wrapper that checks prerequisites, runs the replay, records the outcome, and exits with a meaningful status. Then cron or systemd can do the boring part reliably.

A computer monitor displaying a coding task notification stands on a wooden desk next to a bottle and mug.

A lot of teams are already moving in this direction. A UiPath survey found that 52% of automation professionals built automations for their IT departments in the last year, often with Python or shell scripts to reduce manual effort, according to the automation figures referenced earlier from Zapier.

Build a wrapper that handles the ugly parts

This is the version I’d rather maintain than a direct cron entry with a long inline command:

#!/usr/bin/env bash
set -euo pipefail

LOCK_FILE="/tmp/gor-nightly.lock"
LOG_DIR="/var/log/gor-replay"
STAMP="$(date +%Y%m%d-%H%M%S)"
LOG_FILE="${LOG_DIR}/replay-${STAMP}.log"
INPUT_FILE="/var/log/gor/latest.gor"
TARGET="http://staging-app"

mkdir -p "$LOG_DIR"

exec 9>"$LOCK_FILE"
flock -n 9 || { echo "[WARN] replay already running"; exit 1; }

{
  echo "[INFO] replay started at $(date -Is)"

  test -f "$INPUT_FILE"

  gor \
    --input-file "$INPUT_FILE" \
    --output-http "$TARGET"

  echo "[INFO] replay finished at $(date -Is)"
} >>"$LOG_FILE" 2>&1

The lock matters more than is generally assumed. Without it, one delayed run can overlap the next and create misleading failures.

Two scheduling patterns that work

Use cron when you want something simple and stable:

30 2 * * * /opt/replay/run-nightly-replay.sh

Use systemd when you want better service supervision, restart behavior, and centralized logs. That’s usually the stronger choice for long-lived infrastructure.

  • Cron is quick for nightly staging checks or low-friction jobs.
  • Systemd is cleaner when the replay needs environment files, dependency ordering, or richer status inspection.

Field note: If a replay job matters to release confidence, give it the same operational hygiene as a deployment job. Locking, logs, and explicit exit codes aren’t optional.

Decide what the scheduled job should validate

Nightly replay shouldn’t try to answer every quality question. Pick a narrow purpose.

Replay job typeBest useTypical signal
Compatibility replayValidate routes, headers, and auth assumptionsUnexpected response mismatches
Regression replayCompare behavior after recent changesNew failures in known request classes
Capacity checkExercise realistic request mixSlower responses or target instability

A schedule gives you continuity. It doesn’t give you judgment. Keep the job focused enough that a failed run tells the on-call engineer where to look first.

Integrating GoReplay Scripts into CI/CD Pipelines

Scheduled jobs are useful, but they run on the clock. CI/CD jobs run on change, which is where traffic replay starts affecting release decisions.

That move matters operationally and financially. According to McKinsey, strategic automation integrated into a larger roadmap achieves a 40% higher first-year ROI compared to piecemeal, disconnected scripts, as summarized in this discussion of automation sprawl and planning. In practice, that means your replay script for automation should sit next to build, test, and deploy stages instead of living as an isolated server cron job.

A person presenting a visual diagram of a CI/CD software development flow on a computer monitor screen.

A useful design reference for this step is GoReplay’s article on CI/CD pipeline optimization, especially if you’re deciding where replay belongs relative to deploy and verification stages.

Treat replay as a gate, not an afterthought

The pipeline pattern is straightforward:

  1. Build the application.
  2. Deploy to a disposable or staging environment.
  3. Run a replay script against that environment.
  4. Evaluate outputs and fail the pipeline if the replay crosses your rules.

The evaluation step is where teams usually cut corners. Don’t just run the replay and hope someone reads the logs. Parse the output, inspect response mismatches, and return a non-zero exit code when the job should block promotion.

A GitHub Actions example

This keeps replay logic in a dedicated script and lets the workflow stay readable:

name: replay-validation

on:
  pull_request:
  workflow_dispatch:

jobs:
  replay:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Start staging-like target
        run: ./scripts/start-test-env.sh

      - name: Run replay
        run: ./scripts/run-replay-validation.sh

      - name: Evaluate replay results
        run: ./scripts/evaluate-replay.sh

The shell scripts should do the heavy lifting. Keep YAML as orchestration, not business logic.

A GitLab CI example

stages:
  - build
  - verify

replay_verify:
  stage: verify
  script:
    - ./scripts/start-test-env.sh
    - ./scripts/run-replay-validation.sh
    - ./scripts/evaluate-replay.sh

And for Jenkins, the same idea fits cleanly in a declarative pipeline:

pipeline {
  agent any
  stages {
    stage('Replay Verify') {
      steps {
        sh './scripts/start-test-env.sh'
        sh './scripts/run-replay-validation.sh'
        sh './scripts/evaluate-replay.sh'
      }
    }
  }
}

What the evaluation script should check

The exact checks depend on your application, but the script should stay mechanical and narrow.

  • Response mismatches against expected status classes or known-safe baselines.
  • Transport failures such as connection resets or target timeouts.
  • Application log signals written during replay validation.
  • Artifact collection so engineers can inspect the failed run without reproducing it immediately.

Here’s a minimal pattern:

#!/usr/bin/env bash
set -euo pipefail

RESULTS_FILE="./artifacts/replay-summary.txt"

grep -q "MISMATCH" "$RESULTS_FILE" && exit 1
grep -q "FATAL" "$RESULTS_FILE" && exit 1

exit 0

Keep the pipeline version maintainable

The fastest way to make replay brittle is to pile environment-specific logic into CI config. Instead:

Put in scriptsKeep in CI config
Replay flagsJob triggers
Header rewritingArtifact paths
Target readiness checksStage ordering
Output parsingEnvironment selection

That split gives you local reproducibility. Engineers can run the same replay scripts outside CI when they need to debug a failure.

This is also the one place where a dedicated replay tool belongs naturally in the workflow. GoReplay can capture and replay live HTTP traffic, and teams often use it here as one option for feeding production-like requests into a pre-production validation stage.

Troubleshooting and Scaling Your Automation Scripts

The dangerous assumption is that once the replay works twice, it’s done. That’s how automation turns into shelfware.

The numbers behind failed automation projects are a warning sign. 73% of test automation projects fail to deliver their promised ROI and 68% are abandoned within 18 months, according to Virtuoso’s analysis of test automation failures and success patterns. The common problem isn’t that teams chose automation. It’s that they stopped treating maintenance and troubleshooting as part of the system.

Failures usually come from a short list

When replay jobs become noisy or flaky, the root cause is often ordinary:

  • The capture got dirtier because new endpoints or probes were added and filters never changed.
  • The target environment drifted from production assumptions around headers, auth, or service dependencies.
  • The replay host became the bottleneck because storage, CPU, or file handling lagged behind the traffic volume.
  • The validation rules stayed vague so the job reports “failure” without telling anyone what failed.

Start by deciding which of those categories you’re in before changing flags.

Most replay failures aren’t mysterious. They’re usually a mismatch between what the script assumes and what the environment currently does.

A practical troubleshooting checklist

Use the same order every time so incidents don’t turn into random command experiments.

  1. Verify the input file Check that the capture is current, readable, and not dominated by noise.
  2. Run a narrow sample Replay a small subset first. If a tiny slice fails, scaling up won’t help.
  3. Inspect rewritten data Confirm masked fields, auth headers, and session substitutions still match the target environment.
  4. Check target readiness Make sure dependencies behind staging or pre-production are available before blaming the replay tool.
  5. Review exit conditions A bad evaluator script can create false failures just as easily as a bad replay can.

Scaling without wrecking the target

More traffic isn’t automatically better. If the listener, middleware, or storage path can’t keep up, you’ll test the replay stack instead of the application.

A safer pattern is to scale in layers:

Scaling concernSafer moveRisky move
Bigger capture setsSplit files by time window or route familyOne giant file for every check
Heavier transformationsMove logic into focused middleware scriptsOne bloated script doing everything
More environmentsParameterize target configDuplicate scripts per environment
Team usageStandardize logs and outputsLet each engineer invent their own format

What to keep simple on purpose

There’s always pressure to build a universal replay framework. Resist it.

Keep these pieces plain:

  • One script to capture
  • One script to sanitize
  • One script to replay
  • One script to evaluate

You can wrap them with Makefiles, CI jobs, or orchestration later. If each layer stays understandable, the whole automation chain survives growth.

The teams that keep this working don’t treat replay as a special event. They treat it like any other operational codebase. It gets reviewed, trimmed, and adjusted as the application changes.


If you’re ready to turn traffic replay from a manual command into a repeatable quality gate, take a look at GoReplay. It’s an open-source option for capturing and replaying live HTTP traffic, and it fits naturally into scripted capture, masking, scheduling, and CI validation workflows.

Ready to Get Started?

Join these successful companies in using GoReplay to improve your testing and deployment processes.