Skip to content

[Internal] Code Analysis Rules: Fixes analyzer issues in Cosmos project.#5091

Merged
microsoft-github-policy-service[bot] merged 8 commits intomasterfrom
users/aavasthy/enable_analyzers_telemetry
Mar 29, 2025
Merged

[Internal] Code Analysis Rules: Fixes analyzer issues in Cosmos project.#5091
microsoft-github-policy-service[bot] merged 8 commits intomasterfrom
users/aavasthy/enable_analyzers_telemetry

Conversation

@aavasthy
Copy link
Copy Markdown
Contributor

@aavasthy aavasthy commented Mar 25, 2025

Pull Request Template

Description

Integrating exception handling analyzers rules with Cosmos project. These rules will enhance stability, prevent performance pitfalls, and ensure better logging practices. Also, suppressing the rules in certain places where logging full stack trace is necessary. This PR covers primarily DocumentClient and Telemetry files.

Performance tests in master branch:

Method Type EnableBinaryResponseOnPointOperations Mean (µs) Error (µs) StdDev (µs) P90 (µs) P95 (µs) P100 (µs) Op/s Gen0 Allocated
CreateItem Stream False 298.62 3.44 3.22 302.51 303.68 305.26 3,348.72 1.4648 26793 B
CreateStreamItem_EnableBinaryResponseOnPointOperations_False Stream False 293.50 3.65 3.42 298.33 299.08 299.83 3,407.17 1.4648 26794 B
DeleteItemExists Stream False 300.57 4.27 3.79 305.14 307.27 310.32 3,326.97 1.4648 26810 B
DeleteItemNotExists Stream False 320.20 4.38 4.09 324.52 325.98 327.49 3,123.06 2.4414 40025 B
ReadFeed Stream False 357.41 6.62 6.51 366.23 368.86 369.54 2,797.91 1.9531 36963 B
ReadItemExists Stream False 321.23 3.58 2.99 323.75 325.50 327.79 3,113.08 1.4648 28089 B
ReadItemNotExists Stream False 341.28 5.72 5.35 347.59 348.10 349.03 2,930.18 2.4414 41293 B
UpdateItem Stream False 297.01 3.59 3.19 300.65 301.38 302.28 3,366.87 1.4648 27002 B
UpsertItem Stream False 300.65 5.63 5.26 305.01 307.38 312.73 3,326.08 1.4648 27006 B
QuerySinglePartitionOnePage Stream False 2564.54 14.57 12.17 2578.23 2581.78 2586.88 389.93 58.5938 996767 B
QuerySinglePartitionMultiplePages Stream False 15267.89 47.63 42.22 15326.44 15338.37 15341.00 65.50 343.75 5880526 B
CreateItem Stream True 298.07 2.73 2.42 301.19 301.91 302.77 3,354.93 1.4648 27766 B
CreateStreamItem_EnableBinaryResponseOnPointOperations_False Stream True 309.31 3.34 2.96 313.80 314.34 314.34 3,232.97 1.4648 29648 B
DeleteItemExists Stream True 306.23 2.56 2.27 308.96 309.65 310.26 3,265.52 1.4648 27246 B
DeleteItemNotExists Stream True 337.83 5.73 5.63 345.83 348.08 349.93 2,960.05 1.9531 35828 B
ReadFeed Stream True 355.30 6.49 6.07 362.33 363.57 365.40 2,814.52 1.9531 36971 B
ReadItemExists Stream True 327.99 6.21 6.37 334.79 338.23 339.62 3,048.85 1.4648 28529 B
ReadItemNotExists Stream True 354.90 3.51 3.11 358.33 359.42 361.20 2,817.66 1.9531 37092 B
UpdateItem Stream True 307.85 4.42 3.91 311.92 312.19 312.66 3,248.34 1.4648 27979 B
UpsertItem Stream True 310.13 6.17 9.05 323.30 323.92 324.70 3,224.41 1.4648 28569 B
QuerySinglePartitionOnePage Stream True 2547.10 13.13 10.25 2553.99 2562.13 2571.72 392.60 58.5938 996763 B
QuerySinglePartitionMultiplePages Stream True 15271.09 89.96 75.12 15334.47 15338.17 15343.42 65.48 343.75 5880719 B
CreateItem OfT False 323.48 2.48 2.07 326.06 326.34 326.47 3,091.37 1.9531 38537 B
CreateStreamItem_EnableBinaryResponseOnPointOperations_False OfT False 0.01 0.00 0.00 0.01 0.01 0.01 73,066,308.61 - -
DeleteItemExists OfT False 319.05 2.17 1.81 320.29 321.89 322.44 3,134.28 1.9531 34554 B
DeleteItemNotExists OfT False 391.12 3.54 3.31 395.50 396.20 397.32 2,556.78 2.4414 43436 B
ReadFeed OfT False 2029.51 7.11 6.66 2039.60 2042.04 2042.66 492.73 31.25 538238 B
ReadItemExists OfT False 346.53 5.90 5.52 352.76 352.88 354.15 2,885.73 1.9531 35811 B
ReadItemNotExists OfT False 405.45 3.66 3.25 409.30 409.57 409.94 2,466.38 1.9531 44705 B
UpdateItem OfT False 333.98 6.46 6.64 343.40 345.68 346.49 2,994.15 1.9531 38745 B
UpsertItem OfT False 336.87 6.55 7.54 347.87 351.73 352.27 2,968.51 1.9531 41297 B
QuerySinglePartitionOnePage OfT False 4853.18 93.51 134.12 4984.12 5078.05 5153.95 206.05 101.56 2184586 B
QuerySinglePartitionMultiplePages OfT False 29185.41 417.55 390.58 29575.65 29584.94 29591.58 34.26 593.75 13006177 B
CreateItem OfT False 343.09 2.56 2.00 345.05 345.95 347.00 2,914.70 1.9531 34781 B
CreateStreamItem_EnableBinaryResponseOnPointOperations_False OfT False 0.01 0.00 0.00 0.01 0.01 0.01 71,558,237.41 - -
DeleteItemExists OfT False 327.41 4.76 4.22 331.34 333.39 335.29 3,054.24 1.4648 30067 B
DeleteItemNotExists OfT False 395.30 4.27 3.99 400.34 401.55 402.10 2,529.75 1.9531 39050 B
ReadFeed OfT False 2026.36 9.99 9.35 2037.72 2038.93 2040.85 493.50 31.25 538229 B
ReadItemExists OfT False 350.31 5.96 5.28 356.28 357.49 358.94 2,854.61 1.9531 31354 B
ReadItemNotExists OfT False 409.55 5.46 5.10 416.43 417.63 419.87 2,441.68 1.9531 40324 B
UpdateItem OfT False 347.23 4.33 4.05 350.79 352.32 355.43 2,879.90 1.9531 35012 B
UpsertItem OfT False 354.04 4.29 4.01 359.55 359.84 360.31 2,824.53 1.9531 34997 B
QuerySinglePartitionOnePage OfT False 4833.96 67.22 59.59 4887.08 4909.85 4946.76 206.87 101.56 2184671 B
QuerySinglePartitionMultiplePages OfT False 29571.21 525.13 491.21 29334.47 29338.17 29343.42 65.48 593.75 13006177 B

Performance Tests after the change:

Method Type EnableBinaryResponseOnPointOperations Mean (µs) Error (µs) StdDev (µs) P90 (µs) P95 (µs) P100 (µs) Op/s Gen0 Allocated
CreateItem Stream False 305.47 6.01 6.43 315.16 315.90 317.74 3,273.60 1.4648 26794 B
CreateStreamItem_EnableBinaryResponseOnPointOperations_False Stream False 292.63 1.55 1.29 294.24 294.62 294.94 3,417.31 1.4648 26793 B
DeleteItemExists Stream False 301.75 3.40 3.01 305.77 306.77 308.51 3,314.00 1.4648 26827 B
DeleteItemNotExists Stream False 321.53 5.30 4.96 327.87 328.66 329.84 3,110.16 2.4414 40038 B
ReadFeed Stream False 354.59 3.88 3.63 358.94 360.12 360.50 2,820.16 1.9531 36978 B
ReadItemExists Stream False 319.79 3.04 2.54 323.22 324.29 325.10 3,127.04 1.4648 28080 B
ReadItemNotExists Stream False 340.28 5.37 5.02 345.94 346.43 346.75 2,938.71 2.4414 41295 B
UpdateItem Stream False 295.47 3.20 2.84 298.46 299.41 301.13 3,384.39 1.4648 27002 B
UpsertItem Stream False 298.47 4.36 3.87 302.32 303.41 305.06 3,350.45 1.4648 27002 B
QuerySinglePartitionOnePage Stream False 2512.89 13.89 12.99 2525.53 2528.71 2535.11 397.95 58.5938 996766 B
QuerySinglePartitionMultiplePages Stream False 15480.71 47.08 44.03 15522.17 15534.46 15552.77 64.60 343.75 5880820 B
CreateItem Stream True 298.14 1.95 1.73 300.25 300.89 301.38 3,354.10 1.4648 27754 B
CreateStreamItem_EnableBinaryResponseOnPointOperations_False Stream True 306.86 2.51 2.22 309.80 310.31 310.85 3,258.82 1.4648 29625 B
DeleteItemExists Stream True 303.48 2.17 1.92 305.49 305.90 306.43 3,295.13 1.4648 27250 B
DeleteItemNotExists Stream True 335.40 4.51 4.22 338.92 341.18 345.82 2,981.50 1.9531 35839 B
ReadFeed Stream True 413.71 16.33 48.14 468.34 490.55 554.75 2,417.14 1.9531 37467 B
ReadItemExists Stream True 327.74 6.54 5.80 334.66 337.14 340.58 3,051.21 1.4648 28529 B
ReadItemNotExists Stream True 355.90 4.03 3.58 359.56 361.23 363.69 2,809.75 1.9531 37093 B
UpdateItem Stream True 306.29 5.59 7.27 315.91 318.38 325.81 3,264.85 1.4648 28646 B
UpsertItem Stream True 306.33 4.31 3.60 310.21 312.14 314.57 3,264.47 1.4648 27981 B
QuerySinglePartitionOnePage Stream True 2515.12 11.21 9.94 2524.59 2529.21 2537.47 397.59 58.5938 996766 B
QuerySinglePartitionMultiplePages Stream True 15397.03 152.24 134.96 15495.62 15532.86 15601.85 64.95 343.75 5880663 B
CreateItem OfT False 324.88 2.15 1.68 325.97 326.74 327.67 3,078.11 1.9531 38537 B
CreateStreamItem_EnableBinaryResponseOnPointOperations_False OfT False 0.01 0.00 0.00 0.01 0.01 0.01 72,548,143.66 - -
DeleteItemExists OfT False 321.54 4.33 3.84 325.91 326.31 326.55 3,110.02 1.9531 34533 B
DeleteItemNotExists OfT False 393.26 6.70 6.27 402.53 403.30 404.96 2,542.83 2.4414 43429 B
ReadFeed OfT False 2139.60 31.19 32.03 2166.32 2189.26 2242.76 467.38 31.25 538217 B
ReadItemExists OfT False 346.27 4.45 3.94 351.42 352.45 353.44 2,887.95 1.9531 35794 B
ReadItemNotExists OfT False 412.37 4.98 4.41 418.29 418.86 419.20 2,425.01 1.9531 44703 B
UpdateItem OfT False 339.21 5.01 4.69 344.19 345.27 347.15 2,948.06 1.9531 38753 B
UpsertItem OfT False 338.96 6.56 8.06 349.28 350.84 352.47 2,950.16 1.9531 41305 B
QuerySinglePartitionOnePage OfT False 4835.19 62.24 58.22 4893.65 4900.18 4903.42 206.82 109.38 2184730 B
QuerySinglePartitionMultiplePages OfT False 29545.34 558.40 597.49 29888.00 30022.06 30592.09 33.85 562.50 13006169 B
CreateItem OfT True 345.25 5.60 5.24 352.00 354.29 354.73 2,896.48 1.9531 34809 B
CreateStreamItem_EnableBinaryResponseOnPointOperations_False OfT True 0.01 0.00 0.00 0.01 0.01 0.01 71,222,536.20 - -
DeleteItemExists OfT True 326.70 4.45 3.72 330.56 330.73 330.84 3,060.89 1.4648 30067 B
DeleteItemNotExists OfT True 391.82 4.45 4.16 396.14 397.58 400.23 2,552.16 1.9531 39050 B
ReadFeed OfT True 2108.14 5.97 4.99 2112.07 2114.55 2117.97 474.35 31.25 538231 B
ReadItemExists OfT True 351.85 6.05 5.66 356.63 359.29 365.25 2,842.09 1.9531 31351 B
ReadItemNotExists OfT True 413.03 6.76 5.99 421.71 422.77 424.03 2,421.14 1.9531 40340 B
UpdateItem OfT True 352.24 6.81 7.00 362.11 363.40 365.63 2,838.96 1.9531 35013 B
UpsertItem OfT True 352.68 5.39 4.78 357.94 360.66 363.94 2,835.40 1.9531 34997 B
QuerySinglePartitionOnePage OfT True 4892.02 70.59 66.03 4953.62 4980.92 5008.40 204.41 101.56 2184656 B
QuerySinglePartitionMultiplePages OfT True 29880.67 546.15 510.87 30275.86 30369.45 30698.68 33.47 593.75 13006303 B
CreateItem OfT False 331.30 6.20 5.80 340.74 342.71 343.13 3,018.39 1.9531 38533 B
CreateStreamItem_EnableBinaryResponseOnPointOperations_False OfT False 0.01 0.00 0.00 0.01 0.01 0.01 71,418,122.29 - -
DeleteItemExists OfT False 324.07 4.39 4.10 328.72 330.62 333.79 3,085.75 1.9531 34532 B
DeleteItemNotExists OfT False 392.66 4.18 3.71 397.59 398.67 399.38 2,546.74 2.4414 43439 B
ReadFeed OfT False 2077.43 7.10 6.29 2083.17 2086.36 2091.79 481.36 31.25 538248 B
ReadItemExists OfT False 347.83 4.68 3.91 352.45 352.84 352.99 2,874.98 1.9531 31352 B
ReadItemNotExists OfT False 415.00 6.68 6.25 424.94 426.69 427.71 2,409.63 1.9531 40323 B
UpdateItem OfT False 348.77 4.88 4.33 353.87 355.35 356.48 2,867.18 1.9531 34254 B
UpsertItem OfT False 349.78 3.86 3.42 352.97 353.56 354.62 2,858.97 1.9531 34254 B
QuerySinglePartitionOnePage OfT False 4747.35 94.22 100.82 4847.31 4855.14 4892.31 210.64 101.56 2184665 B
QuerySinglePartitionMultiplePages OfT False 29366.81 582.58 670.90 29876.16 29907.80 30056.13 34.05 562.50 13006844 B

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

Closing issues

To automatically close an issue: closes #IssueNumber

Comment thread Microsoft.Azure.Cosmos/src/Util/Extensions.cs Outdated
Comment thread Microsoft.Azure.Cosmos/FaultInjection/src/FaultInjection.csproj Outdated
Comment thread Microsoft.Azure.Cosmos/src/DocumentClient.cs
@aavasthy aavasthy marked this pull request as ready for review March 26, 2025 20:21
@aavasthy aavasthy added the auto-merge Enables automation to merge PRs label Mar 28, 2025
@microsoft-github-policy-service microsoft-github-policy-service Bot enabled auto-merge (squash) March 28, 2025 21:55
@microsoft-github-policy-service microsoft-github-policy-service Bot merged commit 300a3e3 into master Mar 29, 2025
27 checks passed
@microsoft-github-policy-service microsoft-github-policy-service Bot deleted the users/aavasthy/enable_analyzers_telemetry branch March 29, 2025 01:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-merge Enables automation to merge PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants