sentry-cocoa icon indicating copy to clipboard operation
sentry-cocoa copied to clipboard

[Structured Logging] Models + Preparation

Open denrase opened this issue 6 months ago • 3 comments

:scroll: Description

  • Adds SentryLog, SentryLogAttribute and SentryLogLevel classes
  • Implements Serialization/Deserialization
  • Removes unused/deprecated SentryLogLovel enum
  • Renames previously named SentryLog.swift used for internal logging to SentryLogSwift.swift
  • Renames previously named SentrLog.h to SentryLogC.swift
  • Extract SentryAsyncLogWrapper from SentryLogC. to SentryAsyncLog.h

:bulb: Motivation and Context

Preparation for structured logs.

Relates to #5122

:green_heart: How did you test it?

Unit tests

:pencil: Checklist

You have to check all boxes before merging:

  • [x] I added tests to verify the changes.
  • [x] No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • [ ] I updated the docs if needed.
  • [ ] I updated the wizard if needed.
  • [ ] Review from the native team if needed.
  • [ ] No breaking change or entry added to the changelog.
  • [ ] No breaking change for hybrid SDKs or communicated to hybrid SDKs.

denrase avatar Jun 20 '25 16:06 denrase

Messages
:book: Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by :no_entry_sign: dangerJS against 124d3e32ab781cbb65c39e93193b8dafca3773e3

github-actions[bot] avatar Jun 20 '25 16:06 github-actions[bot]

I'm not sure regarding naming of the "old" SentryLog classes. Another possibility would be SentryLogging. Would not go with SentryLogger, as the new Logs API already has Sentry.logger.warn(...) as naming, so I'd like to leave this for now.

As far as i could tell we use it to print to console, so maybe calling it SentryConsoleLog would also be a potential candidate.

denrase avatar Jun 20 '25 16:06 denrase

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 86.316%. Comparing base (ac4739e) to head (124d3e3). Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##              main     #5441       +/-   ##
=============================================
+ Coverage   86.271%   86.316%   +0.044%     
=============================================
  Files          404       407        +3     
  Lines        34928     35042      +114     
  Branches     15142     15233       +91     
=============================================
+ Hits         30133     30247      +114     
+ Misses        4751      4748        -3     
- Partials        44        47        +3     
Files with missing lines Coverage Δ
Sources/Swift/Protocol/Codable/SentryCodable.swift 100.000% <100.000%> (ø)
Sources/Swift/Protocol/SentryLog.swift 100.000% <100.000%> (ø)
Sources/Swift/Protocol/SentryLogAttribute.swift 100.000% <100.000%> (ø)
Sources/Swift/Protocol/SentryLogLevel.swift 100.000% <100.000%> (ø)

... and 8 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update ac4739e...124d3e3. Read the comment docs.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov[bot] avatar Jun 24 '25 12:06 codecov[bot]

@denrase, I think it would be great if you could open an extra PR for renaming the existing internal logger. It would make reviewing this PR way easier. I don't have the bandwidth today to give you a proper review. I'm trying to get to this tomorrow, cause it will require some time.

philipphofmann avatar Jun 24 '25 12:06 philipphofmann

@philipphofmann Thank you, no worries. I'll split them up.

denrase avatar Jun 24 '25 13:06 denrase

Thank you @denrase.

philipphofmann avatar Jun 24 '25 13:06 philipphofmann

🚨 Detected changes in high risk code 🚨

High-risk code can easily blow up and is hard to test. We had severe bugs in the past. Be extra careful when changing these files, and have an extra careful look at these:

  • [ ] Sources/Sentry/SentryFileManager.m
  • [ ] Sources/Sentry/SentryNSDataSwizzling.m
  • [ ] Sources/Sentry/SentryNSFileManagerSwizzling.m
  • [ ] Sources/Sentry/SentryNetworkTracker.m
  • [ ] Sources/Sentry/SentrySerialization.m
  • [ ] Sources/Sentry/SentrySubClassFinder.m
  • [ ] Sources/Sentry/SentrySwizzle.m
  • [ ] Sources/Sentry/SentrySwizzleWrapper.m
  • [ ] Sources/Sentry/SentryUIViewControllerSwizzling.m

github-actions[bot] avatar Jun 24 '25 13:06 github-actions[bot]

Performance metrics :rocket:

  Plain With Sentry Diff
Startup time 1228.08 ms 1253.58 ms 25.50 ms
Size 23.74 KiB 872.51 KiB 848.77 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
55f739c66cf5491973cbe3f791c34d6c1ebb8ec5 1226.06 ms 1248.78 ms 22.71 ms
f97a070c7a30ad642fd7add3fe91604920aa8348 1218.88 ms 1253.12 ms 34.24 ms
acac7743bbad41f73175fd9ed9016565801df294 1217.76 ms 1253.29 ms 35.52 ms
b0e13a73f5c919b229bf8b99e1caa6e9ab1d42aa 1227.71 ms 1245.88 ms 18.16 ms
db9572abd5878e7fc709b0da9863fe416ca8bc01 1212.61 ms 1237.73 ms 25.13 ms
35c962f538ddb43d73414354a3ed6b504b5efda1 1207.61 ms 1235.90 ms 28.29 ms
db9572abd5878e7fc709b0da9863fe416ca8bc01 1200.27 ms 1234.80 ms 34.53 ms
b13e93a8889c87e7859c17613e790f89647aace3 1236.24 ms 1247.33 ms 11.08 ms
8047b9959dd14b959761cd3042e1bfc5267d1090 1226.37 ms 1246.63 ms 20.26 ms
8ea529392812f6159f226be117c1d6e6eaab9f9f 1242.70 ms 1262.25 ms 19.55 ms

App size

Revision Plain With Sentry Diff
55f739c66cf5491973cbe3f791c34d6c1ebb8ec5 23.75 KiB 858.73 KiB 834.98 KiB
f97a070c7a30ad642fd7add3fe91604920aa8348 23.75 KiB 858.68 KiB 834.93 KiB
acac7743bbad41f73175fd9ed9016565801df294 23.75 KiB 866.51 KiB 842.76 KiB
b0e13a73f5c919b229bf8b99e1caa6e9ab1d42aa 23.75 KiB 860.98 KiB 837.23 KiB
db9572abd5878e7fc709b0da9863fe416ca8bc01 23.75 KiB 858.65 KiB 834.90 KiB
35c962f538ddb43d73414354a3ed6b504b5efda1 23.75 KiB 854.77 KiB 831.02 KiB
db9572abd5878e7fc709b0da9863fe416ca8bc01 23.75 KiB 858.69 KiB 834.93 KiB
b13e93a8889c87e7859c17613e790f89647aace3 23.75 KiB 855.37 KiB 831.62 KiB
8047b9959dd14b959761cd3042e1bfc5267d1090 23.75 KiB 855.37 KiB 831.62 KiB
8ea529392812f6159f226be117c1d6e6eaab9f9f 23.75 KiB 852.24 KiB 828.49 KiB

Previous results on branch: feat/structured-logs-models

Startup times

Revision Plain With Sentry Diff
152587f56035aa7dcadebe7d226d474b59c37bcd 1232.74 ms 1247.65 ms 14.91 ms

App size

Revision Plain With Sentry Diff
152587f56035aa7dcadebe7d226d474b59c37bcd 23.74 KiB 872.45 KiB 848.71 KiB

github-actions[bot] avatar Jun 27 '25 13:06 github-actions[bot]

Thank you @denrase for implementing our feedback 👍

philprime avatar Jul 04 '25 09:07 philprime