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

Version 3.1.0 #55

Merged
merged 2 commits into from
Jun 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,3 +236,6 @@ flow_log_reader = FlowLogsReader('flowlog_group')
key_fields = ('srcaddr', 'dstaddr')
records = list(aggregated_records(flow_log_reader, key_fields=key_fields))
```

The number of bytes processed after iterating is available in the `bytes_processed` attribute.
For `S3FlowLogsReader` instances there is also a `compressed_bytes_processed` attribute.
3 changes: 3 additions & 0 deletions flowlogs_reader/flowlogs_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,8 @@ def __init__(
self.bucket, self.prefix = location_parts
self.thread_count = thread_count

self.compressed_bytes_processed = 0

self.include_accounts = (
None if include_accounts is None else set(include_accounts)
)
Expand All @@ -383,6 +385,7 @@ def _read_file(self, key):
yield from reader
with THREAD_LOCK:
self.bytes_processed += gz_f.tell()
self.compressed_bytes_processed += resp['ContentLength']

def _get_keys(self, prefix):
# S3 keys have a file name like:
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

[metadata]
name = flowlogs_reader
version = 3.0.0
version = 3.1.0
license = Apache
url = https://github.com/obsrvbl/flowlogs-reader
description = Reader for AWS VPC Flow Logs
Expand Down
9 changes: 9 additions & 0 deletions tests/test_flowlogs_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,9 @@ def test_serial(self):
]
reader = self._test_iteration(V3_FILE, expected)
self.assertEqual(reader.bytes_processed, len(V3_FILE.encode()))
self.assertEqual(
reader.compressed_bytes_processed, len(compress(V3_FILE.encode()))
)

def test_serial_v4(self):
expected = [
Expand Down Expand Up @@ -686,6 +689,9 @@ def test_serial_v4(self):
]
reader = self._test_iteration(V4_FILE, expected)
self.assertEqual(reader.bytes_processed, len(V4_FILE.encode()))
self.assertEqual(
reader.compressed_bytes_processed, len(compress(V4_FILE.encode()))
)

def test_serial_v5(self):
expected = [
Expand Down Expand Up @@ -747,6 +753,9 @@ def test_serial_v5(self):
]
reader = self._test_iteration(V5_FILE, expected)
self.assertEqual(reader.bytes_processed, len(V5_FILE.encode()))
self.assertEqual(
reader.compressed_bytes_processed, len(compress(V5_FILE.encode()))
)

def test_threads(self):
expected = [
Expand Down