Skip to content

Commit f5d75da

Browse files
authored
Structured Logs: Move options out of experimental (#6359)
1 parent caa7e70 commit f5d75da

File tree

14 files changed

+146
-94
lines changed

14 files changed

+146
-94
lines changed

.github/workflows/test-cross-platform.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
with:
5656
repository: getsentry/sentry-react-native
5757
path: sentry-react-native
58-
ref: removeEnableTracing
58+
ref: denrase/options-enable-logs
5959

6060
- name: Enable Corepack
6161
working-directory: sentry-react-native

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
- Removes deprecated user feedback API, this is replaced with the new feedback API (#5591)
1414
- Removes `enablePerformanceV2` option and makes this the default. The app start duration will now finish when the first frame is drawn instead of when the OS posts the UIWindowDidBecomeVisibleNotification. (#6008)
1515
- Removes enableTracing property from SentryOptions (#5694)
16+
- Structured Logs: Move options out of experimental (#6359)
1617

1718
### Features
1819

Samples/SentrySampleShared/SentrySampleShared/SentrySDKWrapper.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,11 @@ public struct SentrySDKWrapper {
161161
}
162162
#endif // !os(macOS) && !os(tvOS) && !os(watchOS) && !os(visionOS)
163163

164+
options.enableLogs = true
165+
164166
// Experimental features
165167
options.experimental.enableFileManagerSwizzling = !SentrySDKOverrides.Other.disableFileManagerSwizzling.boolValue
166168
options.experimental.enableUnhandledCPPExceptionsV2 = true
167-
options.experimental.enableLogs = true
168169
}
169170

170171
func configureInitialScope(scope: Scope, options: Options) -> Scope {

Sources/Sentry/Public/SentryOptions.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,13 @@ NS_SWIFT_NAME(Options)
157157
*/
158158
@property (nullable, nonatomic, copy) SentryBeforeSendSpanCallback beforeSendSpan NS_SWIFT_SENDABLE;
159159

160+
/**
161+
* When enabled, the SDK sends logs to Sentry. Logs can be captured using the @c SentrySDK.logger
162+
* API, which provides structured logging with attributes.
163+
* @note Default value is @c NO .
164+
*/
165+
@property (nonatomic, assign) BOOL enableLogs;
166+
160167
#if !SWIFT_PACKAGE
161168
/**
162169
* Use this callback to drop or modify a log before the SDK sends it to Sentry. Return @c nil to

Sources/Sentry/SentryOptions.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ - (instancetype)init
117117
self.enableNetworkTracking = YES;
118118
self.enableFileIOTracing = YES;
119119
self.enableNetworkBreadcrumbs = YES;
120+
self.enableLogs = NO;
120121
self.tracesSampleRate = nil;
121122
#if SENTRY_TARGET_PROFILING_SUPPORTED
122123
# if !SDK_V9

Sources/Sentry/SentyOptionsInternal.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ + (BOOL)validateOptions:(NSDictionary<NSString *, id> *)options
155155
sentryOptions.maxBreadcrumbs = [options[@"maxBreadcrumbs"] unsignedIntValue];
156156
}
157157

158+
[self setBool:options[@"enableLogs"] block:^(BOOL value) { sentryOptions.enableLogs = value; }];
159+
158160
[self setBool:options[@"enableNetworkBreadcrumbs"]
159161
block:^(BOOL value) { sentryOptions.enableNetworkBreadcrumbs = value; }];
160162

@@ -172,6 +174,12 @@ + (BOOL)validateOptions:(NSDictionary<NSString *, id> *)options
172174
sentryOptions.beforeSend = options[@"beforeSend"];
173175
}
174176

177+
#if !SWIFT_PACKAGE
178+
if ([self isBlock:options[@"beforeSendLog"]]) {
179+
sentryOptions.beforeSendLog = options[@"beforeSendLog"];
180+
}
181+
#endif // !SWIFT_PACKAGE
182+
175183
if ([self isBlock:options[@"beforeSendSpan"]]) {
176184
sentryOptions.beforeSendSpan = options[@"beforeSendSpan"];
177185
}

Sources/Swift/Helper/SentrySDK.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import Foundation
3737
}
3838
let hub = SentryDependencyContainerSwiftHelper.currentHub()
3939
var batcher: SentryLogBatcher?
40-
if let client = hub.getClient(), client.options.experimental.enableLogs {
40+
if let client = hub.getClient(), client.options.enableLogs {
4141
batcher = SentryLogBatcher(client: client, dispatchQueue: Dependencies.dispatchQueueWrapper)
4242
}
4343
let logger = SentryLogger(

Sources/Swift/SentryExperimentalOptions.swift

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public final class SentryExperimentalOptions: NSObject {
3030
* - Experiment: This is an experimental feature and is therefore disabled by default. We'll enable it by default in a future major release.
3131
*/
3232
public var enableUnhandledCPPExceptionsV2 = false
33-
33+
3434
/**
3535
* Forces enabling of session replay in unreliable environments.
3636
*
@@ -48,11 +48,6 @@ public final class SentryExperimentalOptions: NSObject {
4848
*/
4949
public var enableSessionReplayInUnreliableEnvironment = false
5050

51-
/**
52-
* Logs are considered beta.
53-
*/
54-
public var enableLogs = false
55-
5651
@_spi(Private) public func validateOptions(_ options: [String: Any]?) {
5752
}
5853
}

Tests/SentryTests/SentryLogBatcherTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ final class SentryLogBatcherTests: XCTestCase {
1414
super.setUp()
1515

1616
options = Options()
17-
options.experimental.enableLogs = true
17+
options.enableLogs = true
1818

1919
testClient = TestClient(options: options)
2020
testDispatchQueue = TestSentryDispatchQueueWrapper()

Tests/SentryTests/SentryLoggerTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ final class SentryLoggerTests: XCTestCase {
311311
}
312312

313313
func testCaptureLog_SetsTraceIdFromPropagationContext() {
314-
fixture.options.experimental.enableLogs = true
314+
fixture.options.enableLogs = true
315315

316316
let expectedTraceId = SentryId()
317317
let propagationContext = SentryPropagationContext(trace: expectedTraceId, spanId: SpanId())

0 commit comments

Comments
 (0)