Skip to content

fix(telemetry): records and metrics count PartiQL writes, throttles of failed calls, batch retries and rows - #131

Merged
kalaspuff merged 3 commits into
issues-stack/5-commit-and-batch-writerfrom
issues-stack/6-operation-metrics
Oct 31, 2026
Merged

kalaspuff merged 3 commits into
issues-stack/5-commit-and-batch-writerfrom
issues-stack/6-operation-metrics

Conversation

@fctl-sh

@fctl-sh fctl-sh Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

What and why

Five ways operation records and metrics miscounted (#90):

  • PartiQL write capacity counted as reads in client.metrics(): the core attributed the units of every PartiQL output to reads, and took capacity_units over a reported read/write split. Three INSERTs showed read_capacity_units=3.0, write=0.0. The core and collect() now keep a reported split as it is. Units reported only as a total count as the request's kind, and PartiQL statements say it: a SELECT reads, anything else writes, for ExecuteStatement, BatchExecuteStatement and ExecuteTransaction.
  • Failed calls lost their throttle count: the binding put only .attempts and .duration on errors, so a GetItem throttled on every attempt recorded 0 throttles in collect(), no dynamoxy.request.throttles point and no dynamoxy.throttles span attribute, while client.metrics() said 3. Errors of a call now also carry .throttles and .requests (stub, docs and the service fields copied onto model-level errors included).
  • summary()["retries"] counted batch chunks: retries summed attempts - 1, and requests meant attempts for single calls but rounds for managed batches, so a 60-item batch_write without throttling reported 2 retries. A single call is now one request however many attempts it takes (OperationStats.requests in the core), and retries is the attempts beyond the first of each request. A batch's chunks and rounds of unprocessed items count as requests, not retries.
  • A batch that ends in UnprocessedItemsError was recorded as a success (operation.succeeded, no error in collect(), unset span status), because the callers raise after the call was recorded. Managed batches that leave items unprocessed are now recorded as failed with UnprocessedItemsError: in collectors, metrics (error.type), the span (status ERROR) and operation.failed. A batch write's record counts only the items it wrote.
  • db.client.response.returned_rows counted written items: it now records the items of reads only (GetItem, Query, Scan, BatchGetItem, TransactGetItems, and PartiQL SELECT statements; INSERT, UPDATE and DELETE record none, also with RETURNING). OperationRecord.items still counts items returned or written, as documented.

Verified with Rust tests of the capacity split, of PartiQL write capacity in the core's metrics and of single-request stats. Python tests (in-memory backend, with the OpenTelemetry SDK's in-memory exporters) cover PartiQL capacity in metrics() and collect(), the throttles, requests and retries of successful, throttled and failed calls, unprocessed batch writes and reads as failures, and the rows metric. Each test fails without the fix, and make check passes.

Fixes #90

Checklist

  • Tests cover the change (Rust core and Python on the in-memory backend; fault injection and capacity reports exist only there)
  • Docs updated (observability guide, errors reference, AGENT_GUIDE, docstrings, _core.pyi, changelog)
  • make check passes locally (lint, types, clippy, consistency, tests)
  • Breaking change? No, but OperationRecord.requests, CallStats.requests and summary()["requests"] of a single call are now 1 instead of its attempts

Worth confirming

  • Decision: requests of a single call changes from its attempts to 1, so that retries = attempts - requests holds for single calls and batches alike. Dashboards built on summary()["requests"] see lower numbers for retried calls.
  • Decision: a managed batch that leaves items unprocessed counts as one failed operation (UnprocessedItemsError) even though DynamoDB answered, keeping its capacity in the record. Low-level batch_write_item calls, which return unprocessed items without raising, stay successes.

fctl session


Note

Low risk. It changes how operation records, collect() summaries and OpenTelemetry metrics are counted, plus the stats attached to errors, but no read or write path.

What it does. Fixes miscounted telemetry: PartiQL writes now count as write capacity, failed calls keep their throttle count, a single call counts as one request however many attempts it took, and a managed batch that leaves items unprocessed is recorded as a failure. Errors of a call now carry .throttles and .requests next to .attempts, and db.client.response.returned_rows is recorded only for reads and PartiQL SELECT statements. The latest commit only adds a test that a client with a meter provider and no tracer records the same returned rows.

Changed meaning of requests. OperationRecord.requests and summary()["requests"] of a single call are now 1 instead of its attempts, so dashboards built on them see lower numbers for retried calls.

fctl review's first look at 071f009 · 16 files, +353 −65 · Review agent settings

…f failed calls, batch retries and rows

client.metrics() counted the capacity of PartiQL writes as reads, and
capacity reported without a read/write split followed the operation
only: PartiQL statements now count as writes unless they are SELECTs.
Errors of a call now carry their throttles and requests, so failed
calls record them. A single call is one request however many attempts
it takes, so retries are the attempts beyond the first of each request
and managed batches no longer report their chunks as retries. Managed
batches that leave items unprocessed are recorded as failures, and
returned_rows records the items of reads only.

Fixes #90

Co-authored-by: Carl Oscar Aaro <[email protected]>
@fctl-review

fctl-review Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Partly addressed as of ce09bd8. Later commits fixed 1 of the 2 issues this review found.


fctl reviewed 3a9acfc and found 2 issues.

The counting fixes hold up: the capacity split, the per-call requests, the failed-batch records and the new error attributes agree between the core, the binding and the Python layer, and all callers of the managed batches already raise on unprocessed items. Two small loose ends remain.

On lines the diff doesn't show:

  • Errors reference still lists only .attempts and .duration · Low severity · docs/reference/errors.md line 10: Errors of a call now also carry .throttles and .requests, and python/dynamoxy/errors.py, AGENT_GUIDE.md and the stub were updated, but this reference page (which AGENTS.md lists under the docs to update) still names only .attempts and .duration.

Reviewed by fctl · Review agent settings

Comment thread python/dynamoxy/telemetry.py Resolved
The rows metric now takes whether a call's items are rows from the
request, so INSERT, UPDATE and DELETE statements record none; the errors
reference lists .throttles and .requests.

Co-authored-by: Carl Oscar Aaro <[email protected]>
@fctl-sh

fctl-sh Bot commented Oct 31, 2026

Copy link
Copy Markdown
Contributor Author

Errors reference finding: fixed in ce09bd8. docs/reference/errors.md now lists .throttles and .requests with .attempts and .duration for errors of a call.

@fctl-review

This comment has been minimized.

Comment thread python/dynamoxy/client.py Resolved
@fctl-sh

fctl-sh Bot commented Oct 31, 2026

Copy link
Copy Markdown
Contributor Author

Stack of 10 pull requests, merged in this order with "Squash and merge":

  1. fix(models): numbers of union fields render as stored, and literals of plain enum members write #126 fix(models): numbers of union fields render as stored, and literals of plain enum members write
  2. fix(client): calls keep their middleware chain and deliver all their events #127 fix(client): calls keep their middleware chain and deliver all their events
  3. fix(pydantic): use_enum_values, forward references, RootModel fields and data-taking factories work #128 fix(pydantic): use_enum_values, forward references, RootModel fields and data-taking factories work
  4. fix(unique)!: upserts that race with creates, unique floats written back, and collections refused #129 fix(unique)!: upserts that race with creates, unique floats written back, and collections refused
  5. fix(transactions): commit() no longer raises after the transaction was applied #130 fix(transactions): commit() no longer raises after the transaction was applied
  6. fix(telemetry): records and metrics count PartiQL writes, throttles of failed calls, batch retries and rows #131 fix(telemetry): records and metrics count PartiQL writes, throttles of failed calls, batch retries and rows ← this pull request
  7. fix(testing): purge_expired, inject_fault(table=) and replayed transactions behave like DynamoDB #132 fix(testing): purge_expired, inject_fault(table=) and replayed transactions behave like DynamoDB
  8. fix(memory): queries refuse empty key values and start keys outside the key condition, and index keys have size limits #133 fix(memory): queries refuse empty key values and start keys outside the key condition, and index keys have size limits
  9. fix(binding): conversions take any mapping and refuse invalid wire values, and unknown table statuses are not active #134 fix(binding): conversions take any mapping and refuse invalid wire values, and unknown table statuses are not active
  10. fix(memory): PartiQL and expressions follow DynamoDB's rules, and hand-written conditions get no redundant parentheses #135 fix(memory): PartiQL and expressions follow DynamoDB's rules, and hand-written conditions get no redundant parentheses

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.

Operation records and metrics miscount: PartiQL writes, throttles of failed calls, batch retries and rows

1 participant