Repository navigation
Conversation
- Add unit tests for DynamoDBExporter.measure, which should return the DynamoDB item size of the item that export() writes, key attributes included - Add a public-path test where the record JSON fits the 400,000-byte default but the DynamoDB item does not These tests fail on the current code, which measures the record's JSON text instead of the item (aws#1005).
- Add DynamoDBExporter.measure, which returns the DynamoDB item size of the item that export() writes, key attributes included, using the sizing rules in the DynamoDB developer guide - Build the item in one place, so export() and measure() use the same keys and the same number marshalling - Document the measured size in the README The size limiter measured the record's JSON text, but DynamoDB counts the item: a list element costs one byte more than its JSON comma, so a record could pass the 400,000-byte check, skip truncation and still fail PutItem. Fixes aws#1005
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue #, if available
Fixes #1005
Description of changes
Before:
DynamoDBExporterwas size-limited by the length of the record's JSON. DynamoDB counts the item, which can be larger: each list or map element costs one byte of overhead that JSON pays only as a comma. A record of 130,000 empty arrays is about 390 KB as JSON, under the 400,000-byte default, so truncation was skipped, but about 520 KB as an item, soPutItemfailed and the record was lost.After: the size limiter measures the DynamoDB item that
export()writes, key attributes included. The same record now has its oldest results dropped until the item fits, and is written.How:
DynamoDBExportergets ameasure(rendered)method, the optional hook the size limiter already uses forLambdaLogExporter. It builds the item exactly asexport()does (one shared_itemmethod, so keys and number marshalling cannot drift apart) and sums attribute sizes using the rules in the DynamoDB developer guide.Design
See Rules for every change.
DynamoDBExporter.measure, which implements the existing optionalmeasurehook ofTelemetryExporter. Problem: the limit is checked against a size DynamoDB does not use. Cause: the limiter's default measure is compact JSON bytes. Options: (a) lower the default limit to leave headroom, which still fails for element-heavy records and wastes space for others; (b) a new item-size limiter path intruncation.py, which duplicates the existing hook; (c) implement the existingmeasurehook on the exporter. Chosen: (c), it reuses the mechanismLambdaLogExporteralready uses and changes nothing for other exporters. Nothing is removed.truncate_recordmeasuredcompact_dumps(render(record))for this exporter, while the destination limit applies to the marshalled DynamoDB item.dynamodb_exporter.py; +1 public member (DynamoDBExporter.measure).Assumptions
Each assumption about the service, Lambda, the runtime or another library, with its evidence, or marked "unverified" (rule 6):
Decisions not covered by the issue or the design note
pk, andskwhen set) are counted, because they are part of the item DynamoDB stores.measurereturnNone, so the record is written unchanged, as the default JSON measure already does.Checklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.