boto3-assist 0.1.10__py3-none-any.whl → 0.1.12__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- boto3_assist/connection_tracker.py +19 -11
- boto3_assist/dynamodb/dynamodb_connection_tracker.py +4 -33
- boto3_assist/version.py +1 -1
- {boto3_assist-0.1.10.dist-info → boto3_assist-0.1.12.dist-info}/METADATA +1 -1
- {boto3_assist-0.1.10.dist-info → boto3_assist-0.1.12.dist-info}/RECORD +8 -8
- {boto3_assist-0.1.10.dist-info → boto3_assist-0.1.12.dist-info}/WHEEL +0 -0
- {boto3_assist-0.1.10.dist-info → boto3_assist-0.1.12.dist-info}/licenses/LICENSE-EXPLAINED.txt +0 -0
- {boto3_assist-0.1.10.dist-info → boto3_assist-0.1.12.dist-info}/licenses/LICENSE.txt +0 -0
|
@@ -15,12 +15,19 @@ class ConnectionTracker:
|
|
|
15
15
|
"""
|
|
16
16
|
|
|
17
17
|
def __init__(self, service_name: str) -> None:
|
|
18
|
-
self.__stack_trace_env_var: str = "
|
|
18
|
+
self.__stack_trace_env_var: str = "BOTO3_ASSIST_CONNECTION_STACK_TRACE"
|
|
19
19
|
self.__connection_couter: int = 0
|
|
20
20
|
self.__service_name: str = service_name
|
|
21
|
-
self.__issue_stack_trace: bool =
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
self.__issue_stack_trace: bool | None = None
|
|
22
|
+
|
|
23
|
+
@property
|
|
24
|
+
def issue_stack_trace(self) -> bool:
|
|
25
|
+
"""Returns True if the stack trace should be issued"""
|
|
26
|
+
if self.__issue_stack_trace is None:
|
|
27
|
+
self.__issue_stack_trace = (
|
|
28
|
+
os.getenv(self.__stack_trace_env_var, "").lower() == "true"
|
|
29
|
+
)
|
|
30
|
+
return self.__issue_stack_trace
|
|
24
31
|
|
|
25
32
|
def increment_connection(self) -> None:
|
|
26
33
|
"""Increments the connection counter"""
|
|
@@ -32,11 +39,18 @@ class ConnectionTracker:
|
|
|
32
39
|
if self.__service_name:
|
|
33
40
|
service_message = f"Your {self.__service_name} service has more than one connection.\n"
|
|
34
41
|
|
|
35
|
-
if not self.
|
|
42
|
+
if not self.issue_stack_trace:
|
|
36
43
|
stack_trace_message = (
|
|
37
44
|
f"\nTo add addtional information to the log and determine where additional connections are being created"
|
|
38
45
|
f", set the environment variable {self.__stack_trace_env_var} to true.\n"
|
|
39
46
|
)
|
|
47
|
+
else:
|
|
48
|
+
stack = "\n".join(traceback.format_stack())
|
|
49
|
+
stack_trace_message = (
|
|
50
|
+
f"\nStack Trace Enabeld with {self.__stack_trace_env_var}"
|
|
51
|
+
f"\n{stack}"
|
|
52
|
+
)
|
|
53
|
+
|
|
40
54
|
self.__log_warning(
|
|
41
55
|
f"{service_message}"
|
|
42
56
|
f"Your dynamodb connection count is {self.connection_count}. "
|
|
@@ -48,12 +62,6 @@ class ConnectionTracker:
|
|
|
48
62
|
f"{stack_trace_message}"
|
|
49
63
|
)
|
|
50
64
|
|
|
51
|
-
# do a stack trace
|
|
52
|
-
if self.__issue_stack_trace:
|
|
53
|
-
print("Stack Trace")
|
|
54
|
-
traceback.print_stack()
|
|
55
|
-
print("")
|
|
56
|
-
|
|
57
65
|
def decrement_connection(self) -> None:
|
|
58
66
|
"""Decrements the connection counter"""
|
|
59
67
|
self.__connection_couter -= 1
|
|
@@ -4,43 +4,14 @@ Maintainers: Eric Wilson
|
|
|
4
4
|
MIT License. See Project Root for the license information.
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
|
+
from boto3_assist.connection_tracker import ConnectionTracker
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
|
|
10
|
+
class DynamoDBConnectionTracker(ConnectionTracker):
|
|
9
11
|
"""
|
|
10
12
|
Tracks DynamoDB Connection Requests.
|
|
11
13
|
Useful in for performance tuning and debugging.
|
|
12
14
|
"""
|
|
13
15
|
|
|
14
16
|
def __init__(self) -> None:
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
def increment_connection(self) -> None:
|
|
18
|
-
"""Increments the connection counter"""
|
|
19
|
-
self.__connection_couter += 1
|
|
20
|
-
|
|
21
|
-
if self.connection_count > 1:
|
|
22
|
-
self.__log_warning(
|
|
23
|
-
f"Your dynamodb connection count is {self.connection_count}. "
|
|
24
|
-
"Under most circumstances you should be able to use the same connection "
|
|
25
|
-
"vs. creating a new one. Connections are expensive in terms of time / latency. "
|
|
26
|
-
"If you are seeing perforance issues, check how and where you are creating your "
|
|
27
|
-
"connections. You should be able to pass the .db connection to your other objects "
|
|
28
|
-
"and reuse your dynamodb boto connections."
|
|
29
|
-
)
|
|
30
|
-
|
|
31
|
-
def decrement_connection(self) -> None:
|
|
32
|
-
"""Decrements the connection counter"""
|
|
33
|
-
self.__connection_couter -= 1
|
|
34
|
-
|
|
35
|
-
@property
|
|
36
|
-
def connection_count(self) -> int:
|
|
37
|
-
"""Returns the current connection count"""
|
|
38
|
-
return self.__connection_couter
|
|
39
|
-
|
|
40
|
-
def reset(self) -> None:
|
|
41
|
-
"""Resets the connection counter"""
|
|
42
|
-
self.__connection_couter = 0
|
|
43
|
-
|
|
44
|
-
def __log_warning(self, message: str) -> None:
|
|
45
|
-
"""Logs a warning message"""
|
|
46
|
-
print(f"Warning: {message}")
|
|
17
|
+
super().__init__("DynamoDB")
|
boto3_assist/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = '0.1.
|
|
1
|
+
__version__ = '0.1.12'
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
boto3_assist/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
2
|
boto3_assist/boto3session.py,sha256=J20E2lkqJOaey4Ohi-xRe2xABj7QsA8DrggzK29-5es,6415
|
|
3
|
-
boto3_assist/connection_tracker.py,sha256=
|
|
4
|
-
boto3_assist/version.py,sha256=
|
|
3
|
+
boto3_assist/connection_tracker.py,sha256=ggCp2gQ7Y-2fHSGFk8QCHJz-Rq1yVNO4aRYgrYTP178,2987
|
|
4
|
+
boto3_assist/version.py,sha256=WBOcXh8XZ4FNX3RRgliAF5LcxRZyjlt2fyuSPGfwP98,23
|
|
5
5
|
boto3_assist/dynamodb/dynamodb.py,sha256=vV0HvFCESnVK6BcAfcrWsMsNxIIsctvDX_3xdzOVCT0,14623
|
|
6
6
|
boto3_assist/dynamodb/dynamodb_connection.py,sha256=JMCmWOsMzy45rikGl3Z2xqlG2vUTEKSYqi6dpsfJ750,4418
|
|
7
|
-
boto3_assist/dynamodb/dynamodb_connection_tracker.py,sha256=
|
|
7
|
+
boto3_assist/dynamodb/dynamodb_connection_tracker.py,sha256=0BWHRfi5_vjkJLuCSX6sYwvA6wc7BSYCQnGrzbhfyKA,404
|
|
8
8
|
boto3_assist/dynamodb/dynamodb_helpers.py,sha256=ajpTJ5bJOm9PDgE2Zx9p2zkTRFV4xswqJRS81SOTn1s,12198
|
|
9
9
|
boto3_assist/dynamodb/dynamodb_importer.py,sha256=nCKsyRQeMqDSf0Q5mQ_X_oVIg4PRnu0hcUzZnBli610,3471
|
|
10
10
|
boto3_assist/dynamodb/dynamodb_index.py,sha256=LRQgSci222s-pU-JXgnaAoOa71ABX9h3uJPeCVPl1GE,6315
|
|
@@ -25,8 +25,8 @@ boto3_assist/utilities/datetime_utility.py,sha256=TbqGQkJDTahqvaZAIV550nhYnW1Bsq
|
|
|
25
25
|
boto3_assist/utilities/logging_utility.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
26
26
|
boto3_assist/utilities/serialization_utility.py,sha256=s_QQRIhtwIE7xN5nU13mNk2wtWyErBX_Sg7n0gbHj-M,4308
|
|
27
27
|
boto3_assist/utilities/string_utility.py,sha256=w8l063UT3GE48tuJopETyZrjG4CgAzWkyDWMAYMg5Og,7432
|
|
28
|
-
boto3_assist-0.1.
|
|
29
|
-
boto3_assist-0.1.
|
|
30
|
-
boto3_assist-0.1.
|
|
31
|
-
boto3_assist-0.1.
|
|
32
|
-
boto3_assist-0.1.
|
|
28
|
+
boto3_assist-0.1.12.dist-info/METADATA,sha256=L0NqaWNQfcYR9iMS2sL70jiQ-0MFZiZOP3LhJvMgPZI,1805
|
|
29
|
+
boto3_assist-0.1.12.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
|
|
30
|
+
boto3_assist-0.1.12.dist-info/licenses/LICENSE-EXPLAINED.txt,sha256=WFREvTpfTjPjDHpOLADxJpCKpIla3Ht87RUUGii4ODU,606
|
|
31
|
+
boto3_assist-0.1.12.dist-info/licenses/LICENSE.txt,sha256=PXDhFWS5L5aOTkVhNvoitHKbAkgxqMI2uUPQyrnXGiI,1105
|
|
32
|
+
boto3_assist-0.1.12.dist-info/RECORD,,
|
|
File without changes
|
{boto3_assist-0.1.10.dist-info → boto3_assist-0.1.12.dist-info}/licenses/LICENSE-EXPLAINED.txt
RENAMED
|
File without changes
|
|
File without changes
|