Skip to content
This repository was archived by the owner on Sep 17, 2025. It is now read-only.

Commit afca369

Browse files
authored
Fix TypeError when local file storage is above max limit in opencensus-ext-azure (#1114)
1 parent c609ef0 commit afca369

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

contrib/opencensus-ext-azure/opencensus/ext/azure/common/storage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ def _check_storage_size(self):
196196
if size >= self.max_size:
197197
logger.warning(
198198
"Persistent storage max capacity has been "
199-
"reached. Currently at %fKB. Telemetry will be "
199+
"reached. Currently at %sKB. Telemetry will be "
200200
"lost. Please consider increasing the value of "
201201
"'storage_max_size' in exporter config.",
202202
format(size/1024)

contrib/opencensus-ext-azure/tests/test_storage.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,16 @@ def test_check_storage_size_error(self):
151151
os_mock.return_value = True
152152
self.assertTrue(stor._check_storage_size())
153153

154+
def test_check_storage_size_above_max_limit(self):
155+
input = (1, 2, 3)
156+
with LocalFileStorage(os.path.join(TEST_FOLDER, 'asd5'), 1) as stor:
157+
with mock.patch('os.path.getsize') as os_mock:
158+
os_mock.return_value = 52000000
159+
stor.put(input)
160+
with mock.patch('os.path.islink') as os_mock:
161+
os_mock.return_value = True
162+
self.assertFalse(stor._check_storage_size())
163+
154164
def test_maintenance_routine(self):
155165
with mock.patch('os.makedirs') as m:
156166
LocalFileStorage(os.path.join(TEST_FOLDER, 'baz'))

0 commit comments

Comments
 (0)