Skip to content

Optimization Instrumentation#264

Merged
GTC6244 merged 9 commits intonextfrom
feature/cpl-204-suggest-optimization-for-relay
Apr 4, 2026
Merged

Optimization Instrumentation#264
GTC6244 merged 9 commits intonextfrom
feature/cpl-204-suggest-optimization-for-relay

Conversation

@GTC6244
Copy link
Copy Markdown
Contributor

@GTC6244 GTC6244 commented Apr 3, 2026

Summary

  • Adds debug-level tracing spans and events across the full POST /core/v1/lit_action request lifecycle (CPL-204)
  • Instruments billing guard (wallet resolution, customer lookup, balance check), on-chain can_execute_action authorization, client config build, gRPC connection pool (with reuse tracking), per-op handling (with op type + count), wallet permission cache (hit/miss), Stripe charge calls, and billing flush
  • All instrumentation is at debug level with zero overhead when not enabled

Test plan

  • cargo +stable check passes
  • cargo +stable test --lib passes (3 pre-existing platform-specific failures unrelated to this change)
  • cargo +stable test --no-run compiles all test targets successfully
  • Deploy to staging and verify traces appear in observability tooling with RUST_LOG=debug

🤖 Generated with Claude Code

Garandor and others added 6 commits April 1, 2026 11:18
The self-hosted runner doesn't have npm in PATH, causing
cloudflare/wrangler-action@v3 to fail when trying to install wrangler.
Add actions/setup-node@v4 with Node 20 before the deploy step, matching
the pattern used by other workflows in this repo.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ains (#261)

- api.dev.litprotocol.com → api.chipotle.litprotocol.com
- dashboard.dev.litprotocol.com → dashboard.chipotle.litprotocol.com
- docs.dev.litprotocol.com → developer.litprotocol.com
- Fix broken swagger-ui path (/swagger-ui/ → /core/v1/swagger-ui)
- Remove broken Support navbar link
- Fix broken SDK link in encryption migration doc

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* docs: migrate README URLs from dev.litprotocol.com to new domains

Same migration as the docs/ directory (PR #261):
- api.dev.litprotocol.com → api.chipotle.litprotocol.com
- dashboard.dev.litprotocol.com → dashboard.chipotle.litprotocol.com
- docs.dev.litprotocol.com → developer.litprotocol.com

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* docs: update "dev API" to "API" in README quickstart

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* docs: add usage API key step to README quickstart

Adds step 2 showing how to create a scoped usage API key before
using the API, reinforcing the best practice of not embedding
the account key in apps. Renumbers subsequent steps.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* docs: reorder quickstart — add funds before usage API key

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace localhost:8000 and api.dev.litprotocol.com references in curl
examples across MDX docs with https://api.chipotle.litprotocol.com.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
…-204)

Add debug-level tracing spans and events across the full lit_action
request lifecycle to measure actual latency before optimizing. Covers
billing guard, Stripe API calls, on-chain authorization, gRPC connection
pool, per-op handling with op type visibility, and wallet permission
cache hit/miss tracking.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@GTC6244 GTC6244 requested review from a team and Copilot April 3, 2026 14:10
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds debug-level tracing spans/events across the POST /core/v1/lit_action request lifecycle to improve observability of billing, authorization, client setup, gRPC connectivity, and per-op execution behavior.

Changes:

  • Instrumented billing/Stripe flow (wallet resolution, customer lookup, balance check, charges) with debug logs/spans.
  • Added debug spans around can_execute_action, client config build, and execute_js execution.
  • Instrumented gRPC connection pool reuse/wait behavior and added per-op handling + wallet permission cache hit/miss telemetry.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
lit-api-server/src/stripe.rs Adds debug logs around wallet/customer/balance resolution and Lit Action time charging.
lit-api-server/src/core/v1/guards/billing.rs Wraps Lit Action credit check in a debug span and simplifies error flow.
lit-api-server/src/core/core_features.rs Adds debug spans for authorization, client config build, and JS execution steps.
lit-api-server/src/actions/grpc.rs Adds a debug span for connection creation/reuse and extra debug logs while waiting for permits.
lit-api-server/src/actions/client/op_code_helpers/mod.rs Adds debug instrumentation + cache hit/miss field recording for wallet permission checks.
lit-api-server/src/actions/client/handle_ops.rs Adds per-op debug event with op type and running op count (without logging secrets).
lit-api-server/src/actions/client/execution.rs Adds debug logs around Stripe flush charging and gRPC channel/stream setup.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +42 to +46
let span = tracing::debug_span!(
"grpc_pool::create_or_get_connection",
addr,
reused = tracing::field::Empty
);
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

create_or_get_connection logs at debug on every loop iteration ("Connecting…") and also logs every 50ms while waiting for permits. Under load with debug enabled this can generate very high log volume and make traces noisy. Consider lowering these to trace, or only logging on state transitions (first attempt / first NoPermits) with a counter/backoff so it remains usable in production debugging.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

@GTC6244 GTC6244 self-assigned this Apr 3, 2026
Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 3, 2026

@GTC6244 I'm unable to start working on this because of repository rules that prevent me from pushing to the branch:

  • Changes must be made through a pull request due to repository rules

See the documentation for more details.

GTC6244 and others added 2 commits April 3, 2026 14:32
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Move per-loop-iteration log to trace, only log permit wait on first
occurrence, and log connection creation at debug instead of every lookup.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@GTC6244 GTC6244 changed the base branch from main to next April 3, 2026 20:51
@GTC6244 GTC6244 merged commit 4796744 into next Apr 4, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants