Inspecting Your Application¶
As your application grows — more subscribers, more routers, more topics — it becomes hard to remember how everything is wired together. The inspect command gives you a quick overview of your application's subscribers without starting the server or connecting to Google Cloud.
How It Works¶
When you run fastpubsub inspect subscribers, the CLI:
- Imports your application using the
module:attributepath you provide - Reads the subscriber registry from your broker's router hierarchy
- Formats the output as a table (default) or JSON
- Exits — no server starts, no lifecycle hooks fire, no Pub/Sub connections open
Basic Usage¶
Consider an e-commerce application that processes orders, charges payments, and sends notifications:
@broker.subscriber(
alias="process-orders",
topic_name="order-events",
subscription_name="orders-sub",
ack_deadline_seconds=120,
dead_letter_topic="order-events-dlq",
max_delivery_attempts=5,
)
async def process_order(message: Message):
"""Validate and fulfill incoming orders."""
...
@broker.subscriber(
alias="charge-payments",
topic_name="payment-events",
subscription_name="payments-sub",
enable_exactly_once_delivery=True,
)
async def charge_payment(message: Message):
"""Process payment charges with exactly-once guarantees."""
...
@broker.subscriber(
alias="send-notifications",
topic_name="notification-events",
subscription_name="notifications-sub",
filter_expression='attributes.channel = "email"',
)
async def send_notification(message: Message):
"""Send email notifications filtered by channel attribute."""
...
Run the inspect command to see what your application registers:
Output:
FastPubSub (v0.9.5): my_project.main:app — 3 subscribers
┌─────────────────────┬─────────────────┬──────────────────────┬─────────────────────┬───────────────────┐
│ Alias │ Project │ Topic │ Subscription │ Handler │
├─────────────────────┼─────────────────┼──────────────────────┼─────────────────────┼───────────────────┤
│ charge-payments │ ecommerce-prod │ payment-events │ payments-sub │ charge_payment │
│ process-orders │ ecommerce-prod │ order-events │ orders-sub │ process_order │
│ send-notifications │ ecommerce-prod │ notification-events │ notifications-sub │ send_notification │
└─────────────────────┴─────────────────┴──────────────────────┴─────────────────────┴───────────────────┘
Subscribers are sorted alphabetically by alias.
Selecting Columns¶
By default, the table shows five columns: alias, project, topic, subscription, and handler. Use --columns (or -c) to choose exactly which columns appear.
Core Columns¶
These are shown by default when no --columns flag is provided:
| Column | Description |
|---|---|
alias |
The subscriber's unique identifier, including router prefixes |
project |
The Google Cloud project ID |
topic |
The Pub/Sub topic name |
subscription |
The Pub/Sub subscription name |
handler |
The Python function name that processes messages |
Policy Columns¶
These are available when you need deeper visibility into subscriber configuration:
| Column | Description |
|---|---|
ack_deadline |
Acknowledgement deadline in seconds |
filter |
Pub/Sub filter expression |
ordering |
Whether message ordering is enabled |
exactly_once |
Whether exactly-once delivery is enabled |
max_messages |
Maximum concurrent messages in flight |
retry_min |
Minimum retry backoff delay in seconds |
retry_max |
Maximum retry backoff delay in seconds |
dead_letter_topic |
Dead letter topic name (empty if none) |
dead_letter_max_attempts |
Max delivery attempts before dead-lettering |
autocreate |
Whether topics/subscriptions are auto-created on startup |
autoupdate |
Whether subscriptions are auto-updated on startup |
Examples¶
Show only alias and topic:
Show all columns including policy fields:
Show specific policy columns alongside the alias:
Note
Column names are case-insensitive and extra whitespace is ignored. --columns " Alias , Topic " works the same as --columns alias,topic.
JSON Output¶
Use --format json (or -f json) for machine-readable output. This is useful for scripting, CI pipelines, or feeding into other tools.
{
"app": "my_project.main:app",
"version": "0.9.5",
"subscribers": [
{
"alias": "charge-payments",
"project": "ecommerce-prod",
"topic": "payment-events",
"subscription": "payments-sub",
"handler": "charge_payment"
}
]
}
The --columns flag works with JSON too — it controls which fields appear in each subscriber object:
# Extract just aliases with jq
fastpubsub inspect subscribers my_project.main:app -f json | jq '.subscribers[].alias'
# Get a compact alias-to-topic mapping
fastpubsub inspect subscribers my_project.main:app -f json -c alias,topic \
| jq '.subscribers[] | "\(.alias) → \(.topic)"'
Filtering Subscribers¶
Use --filter to show only subscribers whose alias matches a glob pattern. This is useful when your application has many subscribers and you want to focus on a specific group.
# Show only order-related subscribers
fastpubsub inspect subscribers my_project.main:app --filter 'process-*'
# Multiple patterns (union)
fastpubsub inspect subscribers my_project.main:app --filter 'process-*' --filter 'send-*'
The --filter flag supports the same glob patterns as run --subscribers:
| Wildcard | Meaning |
|---|---|
* |
Matches any characters within a single segment (between dots) |
? |
Matches exactly one character |
** |
Matches zero or more dot-separated segments |
Dry-run your subscriber selection
Use inspect subscribers --filter to preview which subscribers a pattern matches before passing the same pattern to run --subscribers. This way you can verify your pattern selects exactly the right subscribers — without starting the server.
Inspecting Apps with Routers¶
When your application uses routers with prefixes, subscriber aliases are prefixed automatically. The inspect command reveals the full resolved alias, making it easy to understand the hierarchy.
Consider a SaaS platform with nested routers:
orders_router = PubSubRouter(prefix="orders")
analytics_router = PubSubRouter(prefix="analytics")
platform_router = PubSubRouter(
prefix="platform",
routers=[orders_router, analytics_router],
)
@orders_router.subscriber(
alias="fulfill",
topic_name="order-events",
subscription_name="fulfill-sub",
)
async def fulfill_order(message: Message):
"""Pick, pack, and ship the order."""
...
@orders_router.subscriber(
alias="invoice",
topic_name="order-events",
subscription_name="invoice-sub",
)
async def create_invoice(message: Message):
"""Generate and store the invoice."""
...
@analytics_router.subscriber(
alias="track",
topic_name="analytics-events",
subscription_name="track-sub",
project_id="analytics-warehouse",
)
async def track_event(message: Message):
"""Forward events to the analytics data warehouse."""
...
broker.include_router(platform_router)
FastPubSub (v0.9.5): saas.main:app — 3 subscribers
┌──────────────────────────────┬──────────────────────┬──────────────────┬──────────────────┬────────────────┐
│ Alias │ Project │ Topic │ Subscription │ Handler │
├──────────────────────────────┼──────────────────────┼──────────────────┼──────────────────┼────────────────┤
│ platform.analytics.track │ analytics-warehouse │ analytics-events │ ...track-sub │ track_event │
│ platform.orders.fulfill │ saas-platform │ order-events │ ...fulfill-sub │ fulfill_order │
│ platform.orders.invoice │ saas-platform │ order-events │ ...invoice-sub │ create_invoice │
└──────────────────────────────┴──────────────────────┴──────────────────┴──────────────────┴────────────────┘
Notice how:
- The
platformprefix from the top-level router appears first in every alias - The
ordersandanalyticsprefixes from the child routers follow - The
tracksubscriber shows a different project (analytics-warehouse) — the inspect command makes cross-project subscriptions visible at a glance
Tip
The aliases shown by inspect are the same strings you pass to --subscribers when running the app. Use inspect to find the exact alias, then copy it into your run command.
Recap¶
- Command:
fastpubsub inspect subscribers module:applists all subscribers - Default columns: alias, project, topic, subscription, handler
- Custom columns:
--columns alias,topicreplaces the default set;--columns allshows everything - Filtering:
--filter 'pattern'shows only matching subscribers — use it as a dry-run forrun --subscribers - JSON output:
--format jsonfor scripting and CI pipelines - No side effects: the command imports your app but does not start the server or connect to Pub/Sub
- Router prefixes: aliases reflect the full router prefix hierarchy
- Sorted output: subscribers are always sorted alphabetically by alias