Skip to content

Conversation

denrase
Copy link
Collaborator

@denrase denrase commented Jul 1, 2025

#skip-changelog

📜 Description

  • Adds SentryLogger, which is the user facing API:
// Enable through experimental options
...
options.experimental.enableLogs = true
...

// Log away
SentrySDK.logger.warn("These are not the droids i'm looking for...")

💡 Motivation and Context

This is similar to the structures we have on the Flutter SDK and should be seen as a first attempt to integrate this into cocoa. So please scrutinise it and give me feedback so we can get this right. 🙇

The placement in the Swift folders of the added classes is also something i was not sure about.

Also, this is obviously missing many other features (default attributes, user attributes, batching, etc), but the PR is large enough as is and I hope that the next ones are smaller again.

Relates to #5122

Closes #5585
Closes #5586
Closes #5584

💚 How did you test it?

Unit tests + tried to send a log in the sample app.

📝 Checklist

You have to check all boxes before merging:

  • I added tests to verify the changes.
  • 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.

Copy link
Contributor

github-actions bot commented Jul 1, 2025

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

Generated by 🚫 dangerJS against 9fa370c

Copy link

codecov bot commented Jul 1, 2025

Codecov Report

Attention: Patch coverage is 99.28058% with 1 line in your changes missing coverage. Please review.

Project coverage is 86.566%. Comparing base (8fa44b5) to head (9fa370c).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
Sources/Swift/Tools/SentryLogBatcher.swift 94.117% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##              main     #5532       +/-   ##
=============================================
+ Coverage   86.518%   86.566%   +0.048%     
=============================================
  Files          415       417        +2     
  Lines        35307     35435      +128     
  Branches     15300     15369       +69     
=============================================
+ Hits         30547     30675      +128     
+ Misses        4720      4716        -4     
- Partials        40        44        +4     
Files with missing lines Coverage Δ
SentryTestUtils/TestClient.swift 84.552% <100.000%> (+0.519%) ⬆️
Sources/Sentry/SentryClient.m 98.486% <100.000%> (+0.021%) ⬆️
Sources/Sentry/SentryDataCategoryMapper.m 96.747% <100.000%> (+0.226%) ⬆️
Sources/Sentry/SentrySDK.m 88.721% <100.000%> (+0.626%) ⬆️
Sources/Swift/Protocol/SentryLog.swift 100.000% <100.000%> (ø)
Sources/Swift/Protocol/SentryLogAttribute.swift 100.000% <100.000%> (ø)
Sources/Swift/SentryExperimentalOptions.swift 83.333% <100.000%> (+1.515%) ⬆️
Sources/Swift/Tools/SentryLogger.swift 100.000% <100.000%> (ø)
Sources/Swift/Tools/SentryLogBatcher.swift 94.117% <94.117%> (ø)

... and 10 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 8fa44b5...9fa370c. Read the comment docs.

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

@denrase denrase changed the title [Structured Logging] Send logs via envelopes [Structured Logging] Public API & Send Logs Envelope Jul 3, 2025
Copy link
Member

@philipphofmann philipphofmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost LGTM, please address the remaining comments and please add a changelog entry. Thank you @denrase 💪

@denrase denrase changed the title [Structured Logging] Public API & Send Logs Envelope Add support for capturing structured logs via SentrySDK.logger Jul 10, 2025
@denrase denrase requested a review from philipphofmann July 10, 2025 13:21
Copy link
Member

@philipphofmann philipphofmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When CI is green, LGTM. Thank you @denrase.

@denrase denrase changed the title Add support for capturing structured logs via SentrySDK.logger Add experimental support for capturing structured logs via SentrySDK.logger Jul 11, 2025
@denrase
Copy link
Collaborator Author

denrase commented Jul 11, 2025

It looks to me like Flaky tests. They are running into timeouts on specific Xcode versions. They run fine locally on Xcode 16.3 on iOS.

Bildschirmfoto 2025-07-11 um 12 56 46

@denrase denrase merged commit 7d23639 into main Jul 14, 2025
127 checks passed
@denrase denrase deleted the feat/structured-logs-send-via-envelopes branch July 14, 2025 08:13
@Tarasovych
Copy link

Thanks for your effort @denrase!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Structured Logs: Send via Envelopes Structured Logs: Public API Structured Logs: Client Reports for logs
3 participants