You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Cosmos Diagnostics Logging Filters and optimizations. (Azure#39897)
* Updates on Cosmos Diagnostics
Adds the ability to use logging.Filters on diagnostics logs based on the same filterable parameters as the cosmos diagnostics handler. Also adds some optimizations to reduce time spent on logging diagnostics. Lastly improves the formatting of the diagnostics log to improve readabilty especially when errors are logged.
* Update CHANGELOG.md
* Update CHANGELOG.md
* updates to cosmos diagnostics
* update to logging policy and tests
* pylint updates
* Update README.md
* Remove diagnostics handler
This removes the custom diagnostics handler and instead allows the use of logging filters.
* Update CHANGELOG.md
* Update _cosmos_http_logging_policy.py
* update recommended changes
* updates
Copy file name to clipboardExpand all lines: sdk/cosmos/azure-cosmos/CHANGELOG.md
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,7 @@
3
3
### 4.10.0b5 (Unreleased)
4
4
5
5
#### Features Added
6
+
* Added ability to use Filters from Logging module on Diagnostics Logging based on Http request/response related attributes. See [PR 39897](https://github.com/Azure/azure-sdk-for-python/pull/39897)
6
7
7
8
#### Breaking Changes
8
9
@@ -11,8 +12,10 @@
11
12
* Fixed health check to check the first write region when it is not specified in the preferred regions. See [PR 40588](https://github.com/Azure/azure-sdk-for-python/pull/40588).
12
13
13
14
#### Other Changes
15
+
* Optimized Diagnostics Logging by reducing time spent on logging. Logged Errors are more readable and formatted. See [PR 39897](https://github.com/Azure/azure-sdk-for-python/pull/39897)
14
16
* Health checks are now done concurrently and for all regions for async apis. See [PR 40588](https://github.com/Azure/azure-sdk-for-python/pull/40588).
**NOTICE: The Following is a Preview Feature that is subject to significant change.**
954
-
To further customize what gets logged, you can use a **PREVIEW** diagnostics handler to filter out the logs you don't want to see.
955
-
There are several ways to use the diagnostics handler, those include the following:
956
-
- Using the "CosmosDiagnosticsHandler" class, which has default behaviour that can be modified.
957
-
**NOTE: The diagnostics handler will only be used if the `enable_diagnostics_logging` argument is passed in at the client constructor.
958
-
The CosmosDiagnosticsHandler is also a special type of dictionary that is callable and that has preset keys. The values it expects are functions related to it's relevant diagnostic data. (e.g. ```diagnostics_handler["duration"]``` expects a function that takes in an int and returns a boolean as it relates to the duration of an operation to complete).**
959
-
```python
960
-
from azure.cosmos import CosmosClient, CosmosDiagnosticsHandler
- Using a function that will replace the should_log function in the CosmosHttpLoggingPolicy which expects certain paramameters and returns a boolean. **Note: the parameters of the custom should_log must match the parameters of the original should_log function as shown in the sample.**
985
-
```python
986
-
# Custom should_log method
987
-
defshould_log(self, **kwargs):
988
-
return kwargs.get('duration') and kwargs['duration'] >2000
989
-
990
-
# Initialize the logger
953
+
**NOTICE: The Following is a Preview Feature.**
954
+
To further customize what gets logged, you can use logger filters to filter out the logs you don't want to see. You are able to filter based on the following attributes in the log record of cosmos diagnostics logs:
955
+
-`status_code`
956
+
-`sub_status_code`
957
+
-`duration`
958
+
-`verb`
959
+
-`database_name`
960
+
-`collection_name`
961
+
-`operation_type`
962
+
-`url`
963
+
-`resource_type`
964
+
-`is_request`
965
+
966
+
You can take a look at the samples [here][cosmos_diagnostics_filter_sample] or take a quick look at this snippet:
967
+
- Using **filters** from the **logging** library, it is possible to filter the diagnostics logs. Several filterable attributes are made available to the log record of the diagnostics logs when using logging filters.
0 commit comments