|
46 | 46 | )
|
47 | 47 | # from azure.monitor.opentelemetry.exporter._configuration import _ConfigurationManager
|
48 | 48 | from azure.monitor.opentelemetry.exporter._connection_string_parser import ConnectionStringParser
|
49 |
| -from azure.monitor.opentelemetry.exporter._storage import ( |
50 |
| - LocalFileStorage, |
51 |
| - StorageExportResult, |
52 |
| -) |
| 49 | +from azure.monitor.opentelemetry.exporter._storage import LocalFileStorage |
53 | 50 | from azure.monitor.opentelemetry.exporter._utils import _get_auth_policy
|
54 | 51 | from azure.monitor.opentelemetry.exporter.statsbeat._state import (
|
55 | 52 | get_statsbeat_initial_success,
|
56 | 53 | get_statsbeat_shutdown,
|
57 | 54 | increment_and_check_statsbeat_failure_count,
|
58 | 55 | is_statsbeat_enabled,
|
59 | 56 | set_statsbeat_initial_success,
|
60 |
| - get_local_storage_setup_state_exception, |
61 | 57 | )
|
62 | 58 | from azure.monitor.opentelemetry.exporter.statsbeat._utils import (
|
63 | 59 | _update_requests_map,
|
64 | 60 | _track_dropped_items,
|
65 | 61 | _track_retry_items,
|
66 | 62 | _track_successful_items,
|
| 63 | + _track_dropped_items_from_storage, |
67 | 64 | )
|
68 | 65 |
|
69 | 66 |
|
@@ -207,24 +204,7 @@ def _handle_transmit_from_storage(self, envelopes: List[TelemetryItem], result:
|
207 | 204 | envelopes_to_store = [x.as_dict() for x in envelopes]
|
208 | 205 | result_from_storage_put = self.storage.put(envelopes_to_store)
|
209 | 206 | if self._customer_statsbeat_metrics and self._should_collect_customer_statsbeat():
|
210 |
| - if result_from_storage_put == StorageExportResult.CLIENT_STORAGE_DISABLED: |
211 |
| - # Track items that would have been retried but are dropped since client has local storage disabled |
212 |
| - _track_dropped_items(self._customer_statsbeat_metrics, envelopes, DropCode.CLIENT_STORAGE_DISABLED) |
213 |
| - elif result_from_storage_put == StorageExportResult.CLIENT_READONLY: |
214 |
| - # If filesystem is readonly, track dropped items in customer statsbeat |
215 |
| - _track_dropped_items(self._customer_statsbeat_metrics, envelopes, DropCode.CLIENT_READONLY) |
216 |
| - elif result_from_storage_put == StorageExportResult.CLIENT_PERSISTENCE_CAPACITY_REACHED: |
217 |
| - # If data has to be dropped due to persistent storage being full, track dropped items |
218 |
| - _track_dropped_items(self._customer_statsbeat_metrics, envelopes, DropCode.CLIENT_PERSISTENCE_CAPACITY) |
219 |
| - elif get_local_storage_setup_state_exception() != "": |
220 |
| - # For exceptions caught in _check_and_set_folder_permissions during storage setup |
221 |
| - _track_dropped_items(self._customer_statsbeat_metrics, envelopes, DropCode.CLIENT_EXCEPTION, result_from_storage_put) |
222 |
| - elif isinstance(result_from_storage_put, str): |
223 |
| - # For any exceptions occurred in put method of either LocalFileStorage or LocalFileBlob, track dropped item with reason |
224 |
| - _track_dropped_items(self._customer_statsbeat_metrics, envelopes, DropCode.CLIENT_EXCEPTION, result_from_storage_put) |
225 |
| - else: |
226 |
| - # LocalFileBlob.put returns StorageExportResult.LOCAL_FILE_BLOB_SUCCESS here. Don't need to track anything in this case. |
227 |
| - pass |
| 207 | + _track_dropped_items_from_storage(self._customer_statsbeat_metrics, result_from_storage_put, envelopes) |
228 | 208 | elif result == ExportResult.SUCCESS:
|
229 | 209 | # Try to send any cached events
|
230 | 210 | self._transmit_from_storage()
|
@@ -295,7 +275,9 @@ def _transmit(self, envelopes: List[TelemetryItem]) -> ExportResult:
|
295 | 275 | )
|
296 | 276 | if self.storage and resend_envelopes:
|
297 | 277 | envelopes_to_store = [x.as_dict() for x in resend_envelopes]
|
298 |
| - self.storage.put(envelopes_to_store, 0) |
| 278 | + result_from_storage = self.storage.put(envelopes_to_store, 0) |
| 279 | + if self._customer_statsbeat_metrics and self._should_collect_customer_statsbeat(): |
| 280 | + _track_dropped_items_from_storage(self._customer_statsbeat_metrics, result_from_storage, resend_envelopes) |
299 | 281 | self._consecutive_redirects = 0
|
300 | 282 | elif resend_envelopes:
|
301 | 283 | # Track items that would have been retried but are dropped since client has local storage disabled
|
|
0 commit comments