Improve gateway and Feishu runtime observability#1180
Conversation
Gateway-run and Feishu channel sessions could appear idle even when the runtime had started and was receiving inbound traffic. This adds privacy-safe structured tracing at the startup, control-surface-ready, and inbound-event milestones so operators can distinguish between startup, ingress, deduplication, and successful dispatch without inspecting message bodies or secrets. Constraint: Observability must improve without logging message bodies, tokens, or private endpoints beyond existing configured bind/url metadata Rejected: Add a broader telemetry/event framework | too broad for this bounded runtime reliability slice Confidence: high Scope-risk: narrow Reversibility: clean Directive: Keep future Feishu/gateway logs metadata-only unless the repository adopts a reviewed redaction policy first Tested: cargo fmt --all -- --check Tested: ./scripts/check_architecture_boundaries.sh Tested: ./scripts/check_dep_graph.sh Tested: CARGO_TARGET_DIR=/Users/chum/.cache/loongclaw-runtime-reliability-target cargo test -p loongclaw-app runtime_backend_supports_local_abort_for_running_prompt --lib -- --nocapture Tested: CARGO_TARGET_DIR=/Users/chum/.cache/loongclaw-runtime-reliability-target cargo test -p loongclaw-app ensure_session_falls_back_to_sessions_new_when_ensure_has_no_identifiers --lib -- --nocapture Tested: CARGO_TARGET_DIR=/Users/chum/.cache/loongclaw-runtime-reliability-target cargo test -p loongclaw-app runtime_backend_executes_session_turn_and_controls --lib -- --nocapture Tested: CARGO_TARGET_DIR=/Users/chum/.cache/loongclaw-runtime-reliability-target cargo test -p loongclaw-app doctor_accepts_path_discovered_fake_version_command --lib -- --nocapture Tested: CARGO_TARGET_DIR=/Users/chum/.cache/loongclaw-runtime-reliability-target cargo test -p loongclaw-app browser_companion_session_start_reports_balanced_execution_tier --lib -- --nocapture Tested: CARGO_TARGET_DIR=/Users/chum/.cache/loongclaw-runtime-reliability-target cargo test -p loongclaw gateway_owner_state --test integration -- --nocapture Tested: CARGO_TARGET_DIR=/Users/chum/.cache/loongclaw-runtime-reliability-target cargo test --workspace --locked -j 1 Tested: CARGO_TARGET_DIR=/Users/chum/.cache/loongclaw-runtime-reliability-target cargo clippy --workspace --all-targets --all-features -- -D warnings Tested: CARGO_TARGET_DIR=/Users/chum/.cache/loongclaw-runtime-reliability-target cargo test --workspace --all-features --locked -j 1 -- --test-threads=1 Not-tested: End-to-end Feishu delivery against a live tenant or gateway deployment outside local verification
📝 WalkthroughWalkthroughThis PR adds structured logging throughout the Feishu channel implementation (webhook and websocket modes) and gateway service runtime to improve observability. New logs capture startup information, webhook requests, event processing outcomes, and gateway runtime status. Two accessor methods are added to FeishuWebhookState to expose internal string fields for logging purposes. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@crates/app/src/channel/feishu/websocket.rs`:
- Around line 270-277: The tracing::info call is logging the raw websocket URL
(variable url) which can contain ephemeral auth tokens; update the code so it
does not log sensitive query params or fragments — compute a redacted_url (e.g.,
using url::Url to strip query and fragment or log only the
scheme+host+path/origin) and use that variable instead of %url in the
tracing::info call (keep configured_account_id and account_id as-is). Ensure the
redaction removes any query string/ticket/token information before logging.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 381d42d7-3ad8-4d1a-a0a3-34a1ad2e9ff1
📒 Files selected for processing (4)
crates/app/src/channel/feishu/mod.rscrates/app/src/channel/feishu/webhook.rscrates/app/src/channel/feishu/websocket.rscrates/daemon/src/gateway/service.rs
| tracing::info!( | ||
| target: "loongclaw.channel.feishu", | ||
| transport = "websocket", | ||
| configured_account_id = %state.configured_account_id(), | ||
| account_id = %state.account_id(), | ||
| url = %url, | ||
| "connecting feishu websocket session" | ||
| ); |
There was a problem hiding this comment.
Avoid logging raw websocket endpoint URLs.
url may include ephemeral auth material in query params (tickets/tokens). Logging it verbatim can leak secrets to logs.
🔐 Minimal redaction fix
async fn run_feishu_websocket_session(
state: &FeishuWebhookState,
url: &str,
ws_config: &FeishuWsEndpointClientConfig,
stop: ChannelServeStopHandle,
) -> CliResult<()> {
+ let redacted_url = url.split('?').next().unwrap_or(url);
tracing::info!(
target: "loongclaw.channel.feishu",
transport = "websocket",
configured_account_id = %state.configured_account_id(),
account_id = %state.account_id(),
- url = %url,
+ url = %redacted_url,
"connecting feishu websocket session"
);📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| tracing::info!( | |
| target: "loongclaw.channel.feishu", | |
| transport = "websocket", | |
| configured_account_id = %state.configured_account_id(), | |
| account_id = %state.account_id(), | |
| url = %url, | |
| "connecting feishu websocket session" | |
| ); | |
| let redacted_url = url.split('?').next().unwrap_or(url); | |
| tracing::info!( | |
| target: "loongclaw.channel.feishu", | |
| transport = "websocket", | |
| configured_account_id = %state.configured_account_id(), | |
| account_id = %state.account_id(), | |
| url = %redacted_url, | |
| "connecting feishu websocket session" | |
| ); |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@crates/app/src/channel/feishu/websocket.rs` around lines 270 - 277, The
tracing::info call is logging the raw websocket URL (variable url) which can
contain ephemeral auth tokens; update the code so it does not log sensitive
query params or fragments — compute a redacted_url (e.g., using url::Url to
strip query and fragment or log only the scheme+host+path/origin) and use that
variable instead of %url in the tracing::info call (keep configured_account_id
and account_id as-is). Ensure the redaction removes any query
string/ticket/token information before logging.
Summary
loong gateway runand Feishu channel runtime startup could look idle even when the runtime had started or inbound events were arriving, which left operators without enough evidence to tell whether the bot was listening, deduplicating, or dispatching work.Linked Issues
Change Type
Touched Areas
Risk Track
Validation
cargo fmt --all -- --checkcargo clippy --workspace --all-targets --all-features -- -D warningscargo test --workspace --lockedcargo test --workspace --all-features --lockedCommands and evidence:
Notes:
User-visible / Operator-visible Changes
Failure Recovery
e25d497eeto restore prior logging behavior.Reviewer Focus
crates/daemon/src/gateway/service.rs: startup vs control-surface-ready log boundaries and field selection.crates/app/src/channel/feishu/webhook.rs: metadata-only logging and dedupe/process-success points.crates/app/src/channel/feishu/websocket.rs: websocket session ingress logging without altering dispatch semantics.Summary by CodeRabbit