Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

log consumed capacity if set #4

Merged
merged 1 commit into from
Apr 17, 2023
Merged

Conversation

jsilhan
Copy link

@jsilhan jsilhan commented Apr 4, 2023

the logged extra_data looks like this:

{
    'consumed_capacity': [{
        'TableName': 'mallpay-be-local-eventlog',
        'CapacityUnits': 6.0,
        'Table': {
            'CapacityUnits': 2.0
        },
        'GlobalSecondaryIndexes': {
            'related_objects_slug_triggered_at_index': {
                'CapacityUnits': 2.0
            },
            'related_object_triggered_at_index': {
                'CapacityUnits': 2.0
            }
        }
    }],
    'updated_columns': [{
        'related_object': 'eventlog-90f753ae-77fc-4fc0-a32a-e9d234b6ab0f',
        'slug': 'customer'
    }, {
        'related_object': 'customers-customer-9',
        'slug': 'customer'
    }]
}

settings then looks like (configurable for each table):

PYDJAMODB_DATABASE = {
    ...
    'LOGGING': {
        'eventlog': {
            'RETURN_CONSUMED_CAPACITY': 'INDEXES',
            'COLUMNS': {'slug', 'related_object'},
        },
        'reversion': {
            'RETURN_CONSUMED_CAPACITY': 'NONE',
        },
    }
}

@coveralls
Copy link

coveralls commented Apr 4, 2023

Pull Request Test Coverage Report for Build 4680022371

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 15 of 18 (83.33%) changed or added relevant lines in 1 file are covered.
  • 7 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.2%) to 90.175%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pydjamodb/connection.py 15 18 83.33%
Files with Coverage Reduction New Missed Lines %
pydjamodb/connection.py 7 82.42%
Totals Coverage Status
Change from base Build 4039717060: -0.2%
Covered Lines: 514
Relevant Lines: 570

💛 - Coveralls

@@ -22,6 +27,7 @@ def __init__(self, table_name,
aws_access_key_id=None,
aws_secret_access_key=None,
aws_session_token=None):
self.table_name_postfix = table_name
Copy link
Author

Choose a reason for hiding this comment

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

self.table contains prefixes of env and also "test-"

@jsilhan jsilhan force-pushed the consumed-capacity branch 3 times, most recently from f85cfb5 to cd089aa Compare April 12, 2023 15:21
@dstlmrk
Copy link

dstlmrk commented Apr 14, 2023

It seems good 👍

table_settings = logging_settings.get(self.table_name_postfix, {})
return table_settings.get('RETURN_CONSUMED_CAPACITY'), table_settings.get('COLUMNS', set())

def _log_consumed_capacity(self, data, operation_name, updated_columns):

Choose a reason for hiding this comment

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

Is this method used? Maybe I'm missing something but didn't you want to use this method on lines 163-171?

Copy link
Author

Choose a reason for hiding this comment

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

this is leftover. I have deleted it. Thanks

Copy link

@radimsuckr radimsuckr left a comment

Choose a reason for hiding this comment

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

LGTM

@dstlmrk dstlmrk merged commit 78a77c5 into skip-pay:master Apr 17, 2023
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