File tree Expand file tree Collapse file tree 3 files changed +36
-4
lines changed
sdk/monitor/azure-monitor-opentelemetry-exporter
azure/monitor/opentelemetry/exporter/export Expand file tree Collapse file tree 3 files changed +36
-4
lines changed Original file line number Diff line number Diff line change 7
7
### Breaking Changes
8
8
9
9
### Bugs Fixed
10
+ - Fixes issues #42897 - TypeError in _ transmit_from_storage: LocalFileBlob.get() returns None
11
+ ([ #42897 ] ( https://github.com/Azure/azure-sdk-for-python/pull/42951 ) )
10
12
11
13
### Other Changes
12
14
29
31
([ #42655 ] ( https://github.com/Azure/azure-sdk-for-python/pull/42655 ) )
30
32
- Customer Facing SDKStats: Added telemetry_success field to dropped items as per [ Spec] - https://github.com/aep-health-and-standards/Telemetry-Collection-Spec/pull/606
31
33
([ #42846 ] ( https://github.com/Azure/azure-sdk-for-python/pull/42846 ) )
34
+ ### Breaking Changes
35
+
36
+ ### Bugs Fixed
32
37
- Customer Facing SDKStats: Refactor to use ` Manager ` and ` Singleton ` pattern
33
38
([ #42969 ] ( https://github.com/Azure/azure-sdk-for-python/pull/42969 ) )
34
39
Original file line number Diff line number Diff line change @@ -202,11 +202,16 @@ def _transmit_from_storage(self) -> None:
202
202
# give a few more seconds for blob lease operation
203
203
# to reduce the chance of race (for perf consideration)
204
204
if blob .lease (self ._timeout + 5 ):
205
- envelopes = [_format_storage_telemetry_item (TelemetryItem .from_dict (x )) for x in blob .get ()]
206
- result = self ._transmit (envelopes )
207
- if result == ExportResult .FAILED_RETRYABLE :
208
- blob .lease (1 )
205
+ blob_data = blob .get ()
206
+ if blob_data is not None :
207
+ envelopes = [_format_storage_telemetry_item (TelemetryItem .from_dict (x )) for x in blob_data ]
208
+ result = self ._transmit (envelopes )
209
+ if result == ExportResult .FAILED_RETRYABLE :
210
+ blob .lease (1 )
211
+ else :
212
+ blob .delete ()
209
213
else :
214
+ # If blob.get() returns None, delete the corrupted blob
210
215
blob .delete ()
211
216
212
217
Original file line number Diff line number Diff line change @@ -305,6 +305,28 @@ def test_transmit_from_storage_lease_failure(self):
305
305
blob_mock .lease .assert_called_once ()
306
306
blob_mock .delete .assert_not_called ()
307
307
308
+ def test_transmit_from_storage_blob_get_returns_none (self ):
309
+ """Test that when blob.get() returns None, it's handled properly without TypeError."""
310
+ exporter = BaseExporter ()
311
+ exporter .storage = mock .Mock ()
312
+ blob_mock = mock .Mock ()
313
+ blob_mock .lease .return_value = True
314
+
315
+ blob_mock .get .return_value = None
316
+ exporter .storage .gets .return_value = [blob_mock ]
317
+ transmit_mock = mock .Mock ()
318
+ exporter ._transmit = transmit_mock
319
+
320
+ # This should not raise a TypeError
321
+ exporter ._transmit_from_storage ()
322
+
323
+ # Verify that the blob was leased and deleted (since data was None)
324
+ exporter .storage .gets .assert_called_once ()
325
+ blob_mock .lease .assert_called_once ()
326
+ blob_mock .get .assert_called_once ()
327
+ blob_mock .delete .assert_called_once () # Corrupted blob should be deleted
328
+ transmit_mock .assert_not_called () # No transmission should occur
329
+
308
330
309
331
def test_format_storage_telemetry_item (self ):
310
332
time = datetime .now ()
You can’t perform that action at this time.
0 commit comments