| Crates.io | livetrace |
| lib.rs | livetrace |
| version | 0.2.1 |
| created_at | 2025-05-10 23:35:54.335853+00 |
| updated_at | 2025-05-18 07:07:58.994066+00 |
| description | CLI tool for live tailing of OTLP traces and logs in the Serverless OTLP Forwarder architecture. |
| homepage | |
| repository | https://github.com/dev7a/serverless-otlp-forwarder/tree/main/cli/livetrace |
| max_upload_size | |
| id | 1668931 |
| size | 303,291 |
livetrace CLITail your Lambda traces. From the console.
livetrace is a command-line tool designed to enhance local development workflows when working with distributed tracing in serverless environments using the Serverless OTLP Forwarder Architecture.
In the Serverless OTLP Forwarder architecture, Lambda functions (or other compute resources) emit OpenTelemetry (OTLP) trace data to standard output. This tool enables you to correlate and visualize complete traces—especially valuable during development. Because logs from different services involved in a single request may be distributed across multiple Log Groups, livetrace can tail several log groups simultaneously and reconstruct traces spanning all participating services.
livetrace supports:
StartLiveTailor the FilterLogEvents APIs.It acts as a local observability companion, giving you immediate feedback on trace behavior without needing to navigate the AWS console, your o11y tool, or wait for logs to propagate fully to a backend system.
To instrument your lambda functions, you can use the OTLP stdout span exporter, available for Node, Python, and Rust:
Or, you can use the Lambda Otel Lite library, which also simplifies setting up your OpenTelemetry pipeline:
StartLiveTail.FilterLogEvents with --poll-interval.--log-group-pattern).--stack-name), including implicitly created Lambda log groups./aws/lambda/<region>.<function-name>).otlp-stdout-span-exporter format (JSON wrapping base64-encoded, gzipped OTLP protobuf).--theme, --list-themes).-e, -H, Environment Variables).--session-timeout)..livetrace.toml) for saving common settings (--config-profile, --save-profile).-v, -vv, -vvv).cargo install livetrace
If you want to build from the latest source code or contribute to development:
Clone the repository:
git clone https://github.com/dev7a/serverless-otlp-forwarder.git
cd serverless-otlp-forwarder
Build and install the livetrace binary:
cargo install --path cli/livetrace
This will compile the livetrace crate and place the binary in your Cargo bin directory (e.g., ~/.cargo/bin/livetrace). Ensure this directory is in your system's PATH.
livetrace [OPTIONS]
You must specify at least one of the following to identify the log groups. They can be used together:
--log-group-pattern <PATTERN>...: Discover log groups whose names contain any of the given patterns (case-sensitive substring search). Can be specified multiple times, or provide multiple patterns after the flag.
# Single pattern
livetrace --log-group-pattern "/aws/lambda/my-app-"
# Multiple patterns
livetrace --log-group-pattern "/aws/lambda/service-a-" "/aws/lambda/service-b-"
livetrace --log-group-pattern "pattern1" --log-group-pattern "pattern2"
--stack-name <STACK_NAME>: Discover log groups associated with resources (AWS::Logs::LogGroup, AWS::Lambda::Function) in the specified CloudFormation stack.
livetrace --stack-name my-production-stack
# Find groups in a stack AND those matching a pattern
livetrace --stack-name my-api-stack --log-group-pattern "/aws/lambda/auth-"
--poll-interval <DURATION>: Use the FilterLogEvents API instead of StartLiveTail, polling at the specified interval. Duration format requires a unit suffix (e.g., 10s, 1500ms, 1m). Decimal values are not supported. If this option is not provided, Live Tail mode is used by default.
# Poll every 15 seconds
livetrace --stack-name my-dev-stack --poll-interval 15s
--backtrace <DURATION>: (Polling mode only) Fetch logs starting from <DURATION> ago for the initial poll. Duration format requires a unit suffix (e.g., 30s, 5m, 2h). Decimal values are not supported. Subsequent polls fetch new logs.
# Poll, fetching initial logs from the last 2 minutes
livetrace --stack-name my-dev-stack --poll-interval 15s --backtrace 2m
--session-timeout <DURATION>: (Default: 30m) Automatically exit after the specified duration. Applies to both Live Tail mode and Polling mode. Duration format requires a unit suffix (e.g., 30m, 1h, 900s). Decimal values are not supported.
# Use Live Tail, but exit after 60 minutes
livetrace --pattern "my-service-" --session-timeout 60m
# Poll every 10 seconds, but exit after 5 minutes total
livetrace --stack-name my-app --poll-interval 10s --session-timeout 5m
[!NOTE] Live Tail mode is the default, but it's not free, at 1c/minute. For long sessions, it's probably better to use the
FilterLogEventsAPI with a polling interval.
Configure forwarding to send traces to another OTLP receiver:
-e, --otlp-endpoint <URL>: The base HTTP URL for the OTLP receiver (e.g., http://localhost:4318). /v1/traces will be appended automatically if no path is present.-H, --otlp-header <KEY=VALUE>: Add custom HTTP headers (e.g., for authentication). Can be specified multiple times.Environment Variables for Forwarding:
You can also configure the endpoint and headers using standard OpenTelemetry environment variables. The precedence order is:
-e, -H)OTEL_EXPORTER_OTLP_TRACES_ENDPOINT, OTEL_EXPORTER_OTLP_TRACES_HEADERS)OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_HEADERS)OTEL_EXPORTER_OTLP_ENDPOINT=<URL> / OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=<URL>: Base URL for the receiver.OTEL_EXPORTER_OTLP_HEADERS=<KEY1=VAL1,KEY2=VAL2...> / OTEL_EXPORTER_OTLP_TRACES_HEADERS=<KEY1=VAL1,KEY2=VAL2...>: Comma-separated list of key-value pairs for headers.# Forward using CLI args
livetrace --stack-name my-stack -e http://localhost:4318 -H "Authorization=Bearer mytoken"
# Forward using environment variables
export OTEL_EXPORTER_OTLP_ENDPOINT=http://collector:4318
export OTEL_EXPORTER_OTLP_HEADERS="x-api-key=secret123,x-tenant-id=abc"
livetrace --stack-name my-stack
Control the appearance of the console output:
--theme <THEME>: Select a color theme (e.g., default, tableau, monochrome). Default is default.--list-themes: List all available color themes with descriptions and exit.--attrs <GLOB_LIST>: Comma-separated list of glob patterns (e.g., "http.*,db.statement,my.custom.*") to filter which attributes are displayed. Applied to both span attributes and event attributes. If omitted, all attributes are shown.--grep <REGEX>: Filter entries in the Timeline Log. Only SpanStart and Event entries where at least one attribute value (including parent span attributes for events) matches the provided Rust-compatible regular expression will be shown. Matching text within attribute values will be highlighted (yellow background). This filter does not affect the waterfall span display.
# Show only timeline log entries where an attribute value contains "error" or "failure"
livetrace --pattern "my-app" --grep "error|failure"
--color-by <MODE>: Specify how spans are colored in the waterfall and timeline views.
service: Color by service name.span: Color by span ID. (Default: span)--event-severity-attribute <ATTRIBUTE_NAME>: (Default: event.severity) Specify the event attribute key used to determine the severity level for coloring event output.--events-only [true|false]: Controls visibility of span start entries in the timeline log. By default (true), only events are shown. Use --events-only=false to include span start information. Providing the flag without a value (e.g., --events-only) implies true.--trace-timeout <DURATION>: (Default: 5s) Maximum time to wait for spans belonging to a trace before displaying/forwarding it. Duration format requires a unit suffix (e.g., 5s, 500ms, 1m). Decimal values are not supported.--trace-stragglers-wait <DURATION>: (Default: 500ms) Time to wait for late-arriving (straggler) spans after the last observed activity on a trace (if its root span has been received) before flushing. Useful for collecting additional spans that might arrive slightly out of order. Duration format requires a unit suffix (e.g., 500ms, 1s). Decimal values are not supported.--aws-region <AWS_REGION>: Specify the AWS Region. Defaults to environment/profile configuration.--aws-profile <AWS_PROFILE>: Specify the AWS profile name.-v, -vv, -vvv: Increase logging verbosity (Info -> Debug -> Trace). Internal logs go to stderr.--forward-only: Only forward telemetry via OTLP; do not display traces/events in the console. Requires an endpoint to be configured.--config-profile <PROFILE_NAME>: Load configuration from a named profile in .livetrace.toml.--save-profile <PROFILE_NAME>: Save the current command-line arguments as a named profile in .livetrace.toml.When running in console mode (--forward-only not specified), livetrace displays:
─ Trace ID: <trace_id> ──────────── Timeline Log for Trace: <trace_id> ───── (or ─ Events for Trace: <trace_id> ───── if --events-only is used)[SPAN] or [EVENT]) - [SPAN] entries are hidden if --events-only is used--attrs if providedlivetrace supports saving and loading configuration profiles to reduce typing for frequently used commands. Profiles are stored in a .livetrace.toml file in the current directory.
To save your current command-line options as a named profile:
# Save the current settings as "dev-profile"
livetrace --pattern "my-service-" --attrs "http.*" --save-profile dev-profile
To use a saved profile:
# Load settings from the "dev-profile"
livetrace --config-profile dev-profile
You can also override specific settings from the profile by providing additional command-line arguments:
# Load from profile but override the attribute filter
livetrace --config-profile dev-profile --attrs "db.*,aws.*"
The .livetrace.toml file follows this structure:
version = 0.0
# Global settings applied to all profiles
[global]
aws-region = "us-east-1"
event-severity-attribute = "event.severity"
# Profile-specific settings
[profiles.dev-profile]
log-group-pattern = ["my-service-"]
attrs = "http.*"
theme = "solarized"
events-only = true
trace-timeout = 10
[profiles.prod-profile]
stack-name = "production-stack"
forward-only = true
otlp-endpoint = "http://localhost:4318"
This file is meant to be local to your project or environment and should typically not be committed to version control.
livetrace can generate shell completion scripts for Bash, Elvish, Fish, PowerShell, and Zsh.
This allows you to get command-line suggestions by pressing the Tab key.
To generate a script, use the generate-completions subcommand:
livetrace generate-completions <SHELL>
Replace <SHELL> with your desired shell (e.g., bash, zsh, fish).
The exact installation method varies by shell. Here are some common examples:
Bash:
bash-completion installed (often available via your system's package manager).mkdir -p ~/.local/share/bash-completion/completions
livetrace generate-completions bash > ~/.local/share/bash-completion/completions/livetrace
You may need to restart your shell or source your .bashrc for changes to take effect.Zsh:
~/.zsh/completions).
mkdir -p ~/.zsh/completions
fpath in your .zshrc file before compinit is called:
# In ~/.zshrc
fpath=(~/.zsh/completions $fpath)
# ... (ensure compinit is called after this, e.g., autoload -U compinit && compinit)
livetrace generate-completions zsh > ~/.zsh/completions/_livetrace
You may need to restart your shell or run compinit again.Fish:
mkdir -p ~/.config/fish/completions
livetrace generate-completions fish > ~/.config/fish/completions/livetrace.fish
Fish should pick up the completions automatically on next launch.Refer to your shell's documentation for the most up-to-date and specific instructions.
# Build
cargo build -p livetrace
# Run tests
cargo test -p livetrace
# Run clippy checks
cargo clippy -p livetrace -- -D warnings
This project is licensed under the MIT License. See the LICENSE file for details.