Status (v15.0.0): All 96 AWS services call metering.record, integrated with offstack cost snapshot, offstack cost diff --fail-over-usd / --fail-over-pct (CI gate, exit 3 on budget breach), offstack cost compare (multi-cloud CFO TCO comparison), and the /_offstack/ Cost & CostDiff Inspector tabs (plus ce Cost Explorer and budgets). See docs/ZERO_BILL_CASE_STUDIES.md and examples/ten_thousand_dollar_mistake.py. (Historical note: the per-operation audit tables below record the original 2026-11-17/19 unit-calibration baseline on the 37-service tree.)
Goal 4 of docs/STRATEGY_2026-11-17.md. A team can run its app against Offstack and get an answer of the form "1,200 S3 PUTs, 30 DynamoDB reads, 50 writes → $0.0060 at AWS us-east-1 list price", so the app can be made cheaper before it is released.
Coverage: every service the simulator serves
The first version metered 3 of 18 paid services -- DynamoDB, S3 and SQS -- and the report could not tell "this app did not use Lambda" from "we never count Lambda". Both are now fixed:
| before | now | |
|---|---|---|
Service packages that call metering.record | 3 | 21 of 21 |
| Services with a cost table | 7 | 35 of 38 (3 more are free by offer: no file exists) |
| Services that can be priced end to end | 3 | 21 paid + 17 free |
tests/test_metering.py::test_every_service_package_calls_the_meter reads the source and fails if any service package loses its hook, so a new service cannot quietly reopen the hole.
The blind spot is now stated even when it exists
A counter can only know what it counted. So start.py records every service it bound a port for, and the snapshot carries served and unmetered. The report prints:
SERVICES SERVED BUT NOT METERED (18).
Traffic to these is MISSING from the total -- this is
not the same as 'free'. Either the app did not use them,
or the total above understates the bill by their cost.
and sets partial: true while that list is non-empty. That is the difference between a confidently-wrong report and a useful one: an unpriced operation is a visible row, but an unmetered service leaves no trace at all.
The list means "the meter saw no traffic here", which is not the same as "the hook is missing", and the report deliberately does not guess between the two. A suite run that skipped the Secrets Manager tests listed Secrets Manager as unmetered; running those same tests alone recorded 43 calls across 12 operations. Both readings are correct, and a report that said "unmetered -- wiring bug" would be wrong half the time.
Free-versus-unpriced
Seven services bill nothing outside their data operations -- IAM, STS, SSM, CloudFormation, Cognito, Event Schemas, and the Logs/EventBridge control planes. For those an unlisted operation is FREE with a stated reason. For every other service an unlisted operation stays UNPRICED, because claiming it were free would hide a real cost. That split is the _FREE_BY_DEFAULT set in pricing/operations.py.
The four pieces
| Piece | Module | What it does |
|---|---|---|
| Meter | metering.py | Per-operation totals with per-dimension quantities. Off unless OFFSTACK_METERING=1. |
| Feed | pricing/feed.py | Downloads and caches the AWS Price List bulk feed. No credentials. |
| Model | pricing/operations.py | Maps each operation to its billed dimension and its price-file usage type. |
| Report | pricing/report.py, pricing/cli.py | Turns a snapshot into a priced breakdown; GET /_ui/cost serves the raw snapshot. |
Running it
# 1. Start the simulator with metering and debug endpoints on
OFFSTACK_METERING=1 OFFSTACK_DEBUG=1 python start.py
# 2. Run the application against it ...
# 3. Price what it did
python -m pricing.cli --service-port 15100
GET /_ui/cost returns the raw snapshot; GET /_ui/cost?reset=1 zeroes it. Both are debug-gated, like /_profile: a shipped build answers 404.
The endpoint serves counts only. Pricing happens in the client, because it needs the AWS price files and a simulator that reached the network on a request would be a worse simulator.
Using it on our own test suite
The first real question asked of this feature was "what would our own full test suite cost on AWS?" -- and it is answerable without touching AWS at all. Metering the suite, then pricing the snapshot, is the same two steps any app uses; the only trick is reading the meter before the simulator process dies.
OFFSTACK_METERING=1 SUITE_COST_OUT=snapshot.json pytest tests/ -p suite_cost_plugin # capture the meter at session end python -m pricing.cli --snapshot snapshot.json
The plugin's fixture takes both session simulators as parameters, which is what forces the ordering: a dependent fixture is set up after the ones it names, and therefore torn down before them -- the only window where the process is alive and `/_ui/cost answers. Asking for the fixture lazily inside the teardown does not work: an autouse fixture with no dependency is set up first and torn down *last*, after the simulator is gone, and the run then reports success while writing no snapshot. Both simulators are merged because the suite splits traffic between the debug-enabled one and simulator_without_debug`.
tools/measure_suite_cost.cmd runs both steps.
What the first run measured, and what it caught
The first number was $0.0481, from 33,702 calls across 173 operation kinds and 14 services -- and it was wrong in a way only running could reveal. The unpriced list contained 80-plus rows of the form lambda:DELETE <uuid>: Lambda's control plane routes on URL paths, and the operation name had been derived from the last path segment, which for DELETE /functions/<name> is the function's name. Every function the suite deleted became its own "operation", none could match the price table, and the report blamed the price model for a metering bug.
Two more gaps fell out of the same list: the dimension table and the usage-type table had drifted (every Logs data operation was in one, nine of eighteen in the other), and PutRecord recorded a call count instead of the 25 KB payload units AWS bills. All three are fixed; the tests in tests/test_lambda_operation_naming.py and the usage-type drift test exist because none of them is visible without a run -- the report rendered, marked itself partial, and looked like a modelling gap.
Auditing the units then found four more (DynamoDB read units on items returned rather than examined, Streams priced from DynamoDB's file, and the CloudWatch and per-chunk cases above). After both passes:
| first run | after the audit | |
|---|---|---|
| Operation kinds recorded | 173 | 97 |
| Unpriced operation kinds | 108 | 1 |
| Free operation kinds | 39 | 67 |
The kind count fell while coverage improved: 80 of those 173 were the phantom lambda:DELETE <uuid> rows, now one DeleteFunction calling the same code path 80 times.
The single remainder is Step Functions StartExecution: an execution's transition count depends on the path it takes, so a call-count meter cannot know it. It is unpriced rather than guessed, which is the whole point.
The figure
The November-19 rerun, after DynamoDB sized units landed (reads ceil(size/4KB), writes ceil(size/1KB), replacing the one-unit-per-item proxy) and with all ten new services priced:
| Nov-19 run | Rerun (this run) | |
|---|---|---|
| Calls metered | 34,846 | 11,007 |
| Operation kinds | 440 across 30 services | 440 |
| Priced | 70 kinds, $0.048555 | —, $0.018955 |
| Free | 363 kinds | 363 kinds |
| Unpriced | 7 kinds, 52 calls | 6 kinds |
| AWS cost at us-east-1 list | $0.048555 | $0.018955 |
The rerun excluded tests/reference_apps and -k "not slow", which is why the call count is lower -- the figure is a lower bound on suite traffic, not a revision of the rate. Two predictions from the previous run confirmed:
xray:PutTraceSegmentsnow prices (4 calls,Traces: 4.0recorded) --
the stale-simulator artifact is gone.
- DynamoDB quantities are sizes, not counts:
PutItem6,919 write units,
Scan 5,139 read units, Query 863, BatchWriteItem 1,377. Every suite item is under both thresholds, so the unit price is unchanged and the subtotal moved only with traffic.
Still unpriced (6 kinds, each a known shape, not a modelling gap):
| Row | Why it is unpriced |
|---|---|
timestream-query:Query (4 calls) | bytes scanned, not rows; the store returns rows and the meter cannot see bytes. Held-resource note, same class as CloudWatch metric-months |
ses:SendBounce, ses:SendCustomVerificationEmail | refused by design (real mailboxes); the report must not call them free |
kms:GenerateDataKeyPair | rate depends on KeyPairSpec ($0.03-$12/10k), which the meter does not record; naming one rate would misprice by up to 400x |
lambda:GET functions, lambda:PUT functions | unmatched-route probes aggregated by the bounded fallback; visible, one row each |
The previous figure ($0.048155, 97 kinds, 1 unpriced) is kept for the history above; the growth is traffic coverage (15 more services metered), not a rate change.
Two caveats worth stating up front, because both make the figure larger than a real deployment:
- Every test is charged. A test that creates a table and deletes it an
assertion later is billed for both calls; no real app does that at this density. The number is an upper bound on the traffic, not a forecast.
- Held resources are excluded. A suite that leaves DynamoDB tables and S3
buckets behind for the length of a run pays for GB-months of storage in reality; the report lists that separately and does not add it.
- Only the tests that ran are counted. This figure comes from a suite run
with the peer comparison off, which skips the 1,249 aws_compare tests. They are differential tests against a peer, not app traffic, so their absence does not lower the bill for Offstack's own operations -- but the suite figure is a lower bound on calls made, because those tests issue requests too.
Why the price data needs no account
The pricing:GetProducts query API needs SigV4 and an IAM action. The bulk feed does not: it is plain HTTPS behind CloudFront. Measured 2026-11-17 -- /offers/v1.0/aws/index.json returns 200 with 273 offers from an unauthenticated request. This is why goal 4 does not have to reach the real account, which matters under the standing rule that nothing may.
Offer names are not service names, and four services have no offer at all because AWS does not charge for them. Event Schemas has two names -- the meter records the package name event_schemas, botocore calls the service schemas -- and both must be mapped, because anything that prices by the boto3 name would otherwise report all 31 operations as unpriced:
| botocore service | offer |
|---|---|
sqs | AWSQueueService |
stepfunctions | AmazonStates |
cognito-idp | AmazonCognito |
secretsmanager | AWSSecretsManager |
dynamodbstreams | AmazonDynamoDB (same file) |
iam, sts, ssm, event_schemas / schemas | no offer -- free |
apigateway, apigatewayv2 | management calls free; only USE1-ApiGatewayRequest is billed |
The rules that make a figure trustworthy
Each of these exists because the opposite produces a plausible number that is wrong.
- An unpriced operation is never $0. It is listed separately and the
report marks itself partial. An omission reads as "free".
- The free tier is applied once per usage type, never per operation.
SQS gives 1,000,000 requests/month; applying it per operation would multiply the allowance. Once per usage type rather than once per service, because S3's two tiers and CloudWatch's metrics-versus-requests are different tiers with different allowances -- a single per-service number would apply one to both.
- A tiered schedule is walked, not sampled. 150M SQS requests cost
100M at the first rate plus 50M at the second. Taking one rate for all of them understates the bill.
- A failed operation is not billed. The meter records only after the
service produced a result.
- Held resources are a separate section. S3 GB-months and RDS
instance-hours are a function of state and uptime, not calls. Folding them into a per-call table yields a number that is neither the request bill nor the full bill.
- Usage types are named per operation. S3 bills PUT/COPY/POST/LIST as
Requests-Tier1 and GET/HEAD as Requests-Tier2; a single name for both would price half the traffic at the wrong rate.
- A free tier belongs to the usage type it was published for. See below.
- A free tier is published in one of two shapes, and both are handled.
Usually it is a separate Global-<stem> usage type; sometimes it is a leading zero-priced range inside the paid type. SNS's Requests-Tier1 is the second shape -- one usage type, "first 1,000,000 free, then $0.50 per million". Reading only for a Global- partner reported no allowance for those, so an SNS publish came out unit_price_usd: 0.0 and confidence: exact -- a priced call reported as FREE. Fixed 2026-11-18; the same shape affects 16 usage types across dynamodb, dynamodbstreams, events, s3 and sns.
- A single call is priced at the marginal rate, not the free range.
Walking a tiered schedule from zero puts the month's first call inside the free range. The per-call price is therefore taken from just past the allowance; the allowance itself stays a report-level fact.
- A usage type that several products share is refused, not guessed.
AWS reuses one usagetype label for distinct SKUs: S3's Requests-Tier8 is 21 Access Grants products -- CreateAGGrant at $0.03 per 1,000, DeleteAGLocation at $0.00 -- and all of them read 0 -> Inf once grouped. A tier walk takes whichever sorted first, so an Access Grants request priced at $0.00 against a real $0.03. Two open-ended ranges at different rates cannot both apply to one quantity, so that shape is reported as unpriced with a reason. Duplicates at the same rate stay priceable (Events publishes USE1-Event-64K-Chunks twice, both $1e-06). Measured 2026-11-18: 3,227 of the 4,745 usage types in the AWS files carry several products, but that count is dominated by labels AWS uses for a whole family of offerings we never bill. Of the 18 usage types this model actually prices, one has overlapping ranges (events USE1-Event-64K-Chunks), and both its products charge the same $1e-06, so it prices correctly.
Every unit, checked against the live file
The unit is the whole game: a correct rate applied to the wrong unit gives a plausible number that is wrong by a factor nobody can see. Every billed dimension was checked against the price file and against the code that produces its quantity on 2026-11-17.
| Service | Unit | Is one per... | Our count comes from |
|---|---|---|---|
| DynamoDB | ReadRequestUnits / WriteRequestUnits | item examined (read) / item written | ScannedCount; 1 per write item |
| DynamoDB Streams | USE1-Streams-Requests | GetRecords call | call, after a 2.5M free tier |
| S3 | Requests-Tier1 / Requests-Tier2 | request | call |
| SQS | Requests-RBP | request | call |
| Lambda | Request | invocation | call |
| API Gateway | USE1-ApiGatewayRequest | data-plane call | call; management is free |
| Logs | CW:Requests | data operation | call |
| CloudWatch | CW:MetricMonitorUsage | metric-month | not derivable -- held resource |
| CloudWatch | CW:GMD-Metrics | metric requested | MetricDataQueries count |
| Kinesis | PutRequestPayloadUnits | 25 KB of payload | record bytes, rounded up |
| EventBridge | USE1-Event-64K-Chunks | 64 KB of payload | entry bytes, rounded up |
| Secrets Manager | USE1-AWSSecretsManagerAPIRequest | request | call |
| RDS Data API | USE1-RDS:Data-API-Usage | request | call |
| Step Functions | USE1-StateTransition | state transition | states visited per execution, including the resumed leg; a parked leg bills at park time and the resume bills the delta, so a re-walked state is never billed twice |
| KMS | us-east-1-KMS-Requests | request | call |
| SES / SESv2 | Recipients | recipient | To + Cc + Bcc summed per send; bulk summed per destination |
| Timestream write | USE1-DataIngestion-Bytes | GB ingested | JSON payload bytes of the records |
| Timestream query | USE1-DataScanned-Bytes | GB scanned | not derivable -- rows scanned, not bytes; unpriced with a stated reason |
| X-Ray | USE1-XRay-TracesStored | trace stored | segment document count per PutTraceSegments |
| Cognito Identity | MAU (held) | monthly active user | API calls carry no request charge; the whole served surface is FREE |
Seven of these were wrong before the audit, and each one is worth stating because none showed up as an error:
- Read units counted items returned, not examined. A
Scanwith a
FilterExpression bills every item it reads, not every item it keeps, so a scan examining 1,000 and returning 3 costs 1,000 units. This was the worst of the six to have wrong, because the scans that read far more than they return are the first thing a cost-optimisation pass looks for.
- Free tiers found by scanning, not by matching. The allowance was the
first zero-priced Global- tier in the file, whatever was being priced. CloudWatch publishes a dozen, so a metric-month got the free request allowance -- and adding the 10-metric tier, 100 calls priced at exactly $0.00. A missing allowance is a visible overcharge; a wrong one is silent.
- A metric-month billed per call.
PutMetricDatawas in the
one-unit-per-request set, so one ingest became up to a month's charge for a metric. It is now unpriced with a held-resource note, because a call counter cannot know how many metrics were retained.
- Metrics requested billed as calls.
GetMetricDatabills per metric in
the query, not per API call; the count is now read from the request.
- DynamoDB Streams priced from DynamoDB's file -- the wrong service's
rate, and none of Streams' own free tier.
- Kinesis and EventBridge billed per call for units that are per chunk.
Both now round up per record: 25 KB and 64 KB respectively.
The one known approximation — closed 2026-11-19
DynamoDB's request units are size-based, not item-based. From the AWS developers guide: a read is ceil(item size / 4 KB) request units and a write is ceil(item size / 1 KB), so a 10 KB item costs 3 read units and 10 write units. The meter used to count one unit per item, so an item over 4 KB (read) or 1 KB (write) priced low by the ratio of its size to the unit.
Now the meter weighs what the engine produced or consumed (dynamodb/server.py::_record_dynamodb): reads decode each wire-shaped item and bill ceil(size / 4 KB); writes decode the request's item and bill ceil(size / 1 KB). Key-only requests (DeleteItem, key-only updates) and responses that carry counts but not rows (Select=COUNT) bill the 1-unit floor, which is also what a miss costs on AWS. Pinned by oversize tests in tests/test_metered_quantities.py (10 KB read → 3 units, 2.5 KB write → 3 units); every pre-existing suite item is under both thresholds, so the November-19 figure below is unchanged by the fix.
The EventBridge free tier is the case that proves matching-by-name is not enough: AWS publishes Global-Event-8K-Chunks free and bills USE1-Event-64K-Chunks, and applying the 8K allowance to 64K requests would understate the bill fivefold. The rule requires the unit to agree, so no allowance is applied -- correct, and it means every chunk is charged.
What it deliberately does not estimate
| Dimension | Why |
|---|---|
| Data transfer out | Depends on where the caller is and how much leaves; an API call says neither |
| RDS instance-hours | Uptime × class |
| CloudWatch metric-months | How many distinct metrics were retained, not how often they were written |
| Support plans, Savings Plans, EDP | Account-level agreements |
These appear in the report as held_resources and not_estimable, with the reason. The subtotal excludes them and says so.
S3 and DynamoDB storage (GB-months) left this table too. The meter now carries a holdings block: `start.py registers a surveyor per store, and each reports the bytes it is holding right now -- S3 walks every .obj (including superseded versions, which a versioned bucket keeps billing) and DynamoDB sums its item payloads. The report prices holdings at the service's TimedStorage-ByteHrs rate (S3 $0.023/GB-Mo tiered, DynamoDB $0.25/GB-Mo past a 25 GB free tier) as a GB-Mo` row.
Read that row as one month's rent at today's occupancy, not a charge accrued since boot: a bucket filled a minute ago shows a full month's rent here and would show 1/43200 of one on a real bill. The report states this in its notes. If a store was never surveyed (no surveyor registered, or the store could not be read), the service keeps its `held_resources` line -- absent bytes and zero bytes are different facts and are reported as such.
Two more entries left this table on 2026-11-17. Lambda GB-seconds are now measured: the server times each handler and multiplies by the function's own MemorySize, so an invoke records GB-Seconds alongside its request count, and the report prices them as a second dimension at $0.0000166667/GB-s with the 400,000 GB-s monthly free tier. Step Functions transitions are now counted from the execution trail -- states visited, in both the StartExecution leg and the resumed leg after an activity -- and priced at $0.000025/transition (4,000 transitions/month free). A stale "not estimable" line is worse than no line: it tells a reader to ignore a number that is now in the total.
Verification
tests/test_metering.py-- the counter (enabled/disabled, per-dimension
summation, operation with no quantity still listed).
tests/test_pricing_feed.py-- the feed (free vs unpriced vs priced, cache
reuse, stale-cache fallback). Includes an opt-in live check (OFFSTACK_LIVE_PRICE_TESTS=1) that asserts every usage type the model names exists in AWS's current price file. That check found two real errors while this was being written: S3's usage type and Step Functions' region-prefixed one.
tests/test_pricing_report.py-- the arithmetic (free tier once, tier walk,
partial flag, held resources).
tests/test_cost_endpoint.py-- the seam (a real PUT is counted, a failed
PUT is not, the endpoint 404s without debug, the snapshot round-trips through build_report).
Known shape limits
- EventBridge and Step Functions usage types are region-prefixed in the
price file (USE1-...). The table carries the us-east-1 spelling; a different --region needs its own, and the live check catches the mismatch.
- SQS FIFO vs standard: the meter cannot see a queue's type, so the
report prices everything at the standard rate and says so.
- The meter counts operations, so the same app run twice meters twice.
Reset between runs (?_reset=1) when comparing configurations.
Want a live walkthrough or evaluation setup for Offstack? Message George Vranjesevic or reach out at george@developmentsnapshot.com.