Skip to content

Commit 613d843

Browse files
authored
Revert "refactor(logs): remove UNSTABLE prefix from feature flag (#832)"
This reverts commit 87c9b54.
1 parent 87c9b54 commit 613d843

File tree

10 files changed

+34
-34
lines changed

10 files changed

+34
-34
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
### Features
66

77
Support for [Sentry structured logs](https://docs.sentry.io/product/explore/logs/) has been added to the SDK.
8-
- To set up logs, enable the `logs` feature of the `sentry` crate and set `enable_logs` to `true` in your client options.
8+
- To set up logs, enable the `UNSTABLE_logs` feature of the `sentry` crate and set `enable_logs` to `true` in your client options.
99
- Then, use the `logger_trace!`, `logger_debug!`, `logger_info!`, `logger_warn!`, `logger_error!` and `logger_fatal!` macros to capture logs.
1010
- To filter or update logs before they are sent, you can use the `before_send_log` client option.
1111
- Please note that breaking changes could occur until the API is finalized.

sentry-core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ default = []
2424
client = ["rand"]
2525
test = ["client", "release-health"]
2626
release-health = []
27-
logs = []
27+
UNSTABLE_logs = []
2828

2929
[dependencies]
3030
log = { version = "0.4.8", optional = true, features = ["std"] }

sentry-core/src/client.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rand::random;
1111
use sentry_types::random_uuid;
1212

1313
use crate::constants::SDK_INFO;
14-
#[cfg(feature = "logs")]
14+
#[cfg(feature = "UNSTABLE_logs")]
1515
use crate::logs::LogsBatcher;
1616
use crate::protocol::{ClientSdkInfo, Event};
1717
#[cfg(feature = "release-health")]
@@ -20,7 +20,7 @@ use crate::types::{Dsn, Uuid};
2020
#[cfg(feature = "release-health")]
2121
use crate::SessionMode;
2222
use crate::{ClientOptions, Envelope, Hub, Integration, Scope, Transport};
23-
#[cfg(feature = "logs")]
23+
#[cfg(feature = "UNSTABLE_logs")]
2424
use sentry_types::protocol::v7::{Log, LogAttribute};
2525

2626
impl<T: Into<ClientOptions>> From<T> for Client {
@@ -53,7 +53,7 @@ pub struct Client {
5353
transport: TransportArc,
5454
#[cfg(feature = "release-health")]
5555
session_flusher: RwLock<Option<SessionFlusher>>,
56-
#[cfg(feature = "logs")]
56+
#[cfg(feature = "UNSTABLE_logs")]
5757
logs_batcher: RwLock<Option<LogsBatcher>>,
5858
integrations: Vec<(TypeId, Arc<dyn Integration>)>,
5959
pub(crate) sdk_info: ClientSdkInfo,
@@ -78,7 +78,7 @@ impl Clone for Client {
7878
self.options.session_mode,
7979
)));
8080

81-
#[cfg(feature = "logs")]
81+
#[cfg(feature = "UNSTABLE_logs")]
8282
let logs_batcher = RwLock::new(if self.options.enable_logs {
8383
Some(LogsBatcher::new(transport.clone()))
8484
} else {
@@ -90,7 +90,7 @@ impl Clone for Client {
9090
transport,
9191
#[cfg(feature = "release-health")]
9292
session_flusher,
93-
#[cfg(feature = "logs")]
93+
#[cfg(feature = "UNSTABLE_logs")]
9494
logs_batcher,
9595
integrations: self.integrations.clone(),
9696
sdk_info: self.sdk_info.clone(),
@@ -161,7 +161,7 @@ impl Client {
161161
options.session_mode,
162162
)));
163163

164-
#[cfg(feature = "logs")]
164+
#[cfg(feature = "UNSTABLE_logs")]
165165
let logs_batcher = RwLock::new(if options.enable_logs {
166166
Some(LogsBatcher::new(transport.clone()))
167167
} else {
@@ -173,7 +173,7 @@ impl Client {
173173
transport,
174174
#[cfg(feature = "release-health")]
175175
session_flusher,
176-
#[cfg(feature = "logs")]
176+
#[cfg(feature = "UNSTABLE_logs")]
177177
logs_batcher,
178178
integrations,
179179
sdk_info,
@@ -349,7 +349,7 @@ impl Client {
349349
if let Some(ref flusher) = *self.session_flusher.read().unwrap() {
350350
flusher.flush();
351351
}
352-
#[cfg(feature = "logs")]
352+
#[cfg(feature = "UNSTABLE_logs")]
353353
if let Some(ref batcher) = *self.logs_batcher.read().unwrap() {
354354
batcher.flush();
355355
}
@@ -370,7 +370,7 @@ impl Client {
370370
pub fn close(&self, timeout: Option<Duration>) -> bool {
371371
#[cfg(feature = "release-health")]
372372
drop(self.session_flusher.write().unwrap().take());
373-
#[cfg(feature = "logs")]
373+
#[cfg(feature = "UNSTABLE_logs")]
374374
drop(self.logs_batcher.write().unwrap().take());
375375
let transport_opt = self.transport.write().unwrap().take();
376376
if let Some(transport) = transport_opt {
@@ -395,7 +395,7 @@ impl Client {
395395
}
396396

397397
/// Captures a log and sends it to Sentry.
398-
#[cfg(feature = "logs")]
398+
#[cfg(feature = "UNSTABLE_logs")]
399399
pub fn capture_log(&self, log: Log, scope: &Scope) {
400400
if !self.options().enable_logs {
401401
return;
@@ -409,7 +409,7 @@ impl Client {
409409

410410
/// Prepares a log to be sent, setting the `trace_id` and other default attributes, and
411411
/// processing it through `before_send_log`.
412-
#[cfg(feature = "logs")]
412+
#[cfg(feature = "UNSTABLE_logs")]
413413
fn prepare_log(&self, mut log: Log, scope: &Scope) -> Option<Log> {
414414
scope.apply_to_log(&mut log, self.options.send_default_pii);
415415

@@ -422,7 +422,7 @@ impl Client {
422422
Some(log)
423423
}
424424

425-
#[cfg(feature = "logs")]
425+
#[cfg(feature = "UNSTABLE_logs")]
426426
fn set_log_default_attributes(&self, log: &mut Log) {
427427
if !log.attributes.contains_key("sentry.environment") {
428428
if let Some(environment) = self.options.environment.as_ref() {

sentry-core/src/clientoptions.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::time::Duration;
55

66
use crate::constants::USER_AGENT;
77
use crate::performance::TracesSampler;
8-
#[cfg(feature = "logs")]
8+
#[cfg(feature = "UNSTABLE_logs")]
99
use crate::protocol::Log;
1010
use crate::protocol::{Breadcrumb, Event};
1111
use crate::types::Dsn;
@@ -147,7 +147,7 @@ pub struct ClientOptions {
147147
/// Callback that is executed for each Breadcrumb being added.
148148
pub before_breadcrumb: Option<BeforeCallback<Breadcrumb>>,
149149
/// Callback that is executed for each Log being added.
150-
#[cfg(feature = "logs")]
150+
#[cfg(feature = "UNSTABLE_logs")]
151151
pub before_send_log: Option<BeforeCallback<Log>>,
152152
// Transport options
153153
/// The transport to use.
@@ -171,7 +171,7 @@ pub struct ClientOptions {
171171
/// server integrations. Needs `send_default_pii` to be enabled to have any effect.
172172
pub max_request_body_size: MaxRequestBodySize,
173173
/// Determines whether captured structured logs should be sent to Sentry (defaults to false).
174-
#[cfg(feature = "logs")]
174+
#[cfg(feature = "UNSTABLE_logs")]
175175
pub enable_logs: bool,
176176
// Other options not documented in Unified API
177177
/// Disable SSL verification.
@@ -232,7 +232,7 @@ impl fmt::Debug for ClientOptions {
232232
#[derive(Debug)]
233233
struct BeforeBreadcrumb;
234234
let before_breadcrumb = self.before_breadcrumb.as_ref().map(|_| BeforeBreadcrumb);
235-
#[cfg(feature = "logs")]
235+
#[cfg(feature = "UNSTABLE_logs")]
236236
let before_send_log = {
237237
#[derive(Debug)]
238238
struct BeforeSendLog;
@@ -279,7 +279,7 @@ impl fmt::Debug for ClientOptions {
279279
.field("auto_session_tracking", &self.auto_session_tracking)
280280
.field("session_mode", &self.session_mode);
281281

282-
#[cfg(feature = "logs")]
282+
#[cfg(feature = "UNSTABLE_logs")]
283283
debug_struct
284284
.field("enable_logs", &self.enable_logs)
285285
.field("before_send_log", &before_send_log);
@@ -325,9 +325,9 @@ impl Default for ClientOptions {
325325
trim_backtraces: true,
326326
user_agent: Cow::Borrowed(USER_AGENT),
327327
max_request_body_size: MaxRequestBodySize::Medium,
328-
#[cfg(feature = "logs")]
328+
#[cfg(feature = "UNSTABLE_logs")]
329329
enable_logs: false,
330-
#[cfg(feature = "logs")]
330+
#[cfg(feature = "UNSTABLE_logs")]
331331
before_send_log: None,
332332
}
333333
}

sentry-core/src/hub.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ impl Hub {
247247
}
248248

249249
/// Captures a structured log.
250-
#[cfg(feature = "logs")]
250+
#[cfg(feature = "UNSTABLE_logs")]
251251
pub fn capture_log(&self, log: Log) {
252252
with_client_impl! {{
253253
let top = self.inner.with(|stack| stack.top().clone());

sentry-core/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,15 @@ pub use crate::intodsn::IntoDsn;
132132
pub use crate::performance::*;
133133
pub use crate::scope::{Scope, ScopeGuard};
134134
pub use crate::transport::{Transport, TransportFactory};
135-
#[cfg(feature = "logs")]
135+
#[cfg(feature = "UNSTABLE_logs")]
136136
mod logger; // structured logging macros exported with `#[macro_export]`
137137

138138
// client feature
139139
#[cfg(feature = "client")]
140140
mod client;
141141
#[cfg(feature = "client")]
142142
mod hub_impl;
143-
#[cfg(all(feature = "client", feature = "logs"))]
143+
#[cfg(all(feature = "client", feature = "UNSTABLE_logs"))]
144144
mod logs;
145145
#[cfg(feature = "client")]
146146
mod session;

sentry-core/src/scope/noop.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::fmt;
22

3-
#[cfg(feature = "logs")]
3+
#[cfg(feature = "UNSTABLE_logs")]
44
use crate::protocol::Log;
55
use crate::protocol::{Context, Event, Level, User, Value};
66
use crate::TransactionOrSpan;
@@ -113,7 +113,7 @@ impl Scope {
113113
}
114114

115115
/// Applies the contained scoped data to fill a log.
116-
#[cfg(feature = "logs")]
116+
#[cfg(feature = "UNSTABLE_logs")]
117117
pub fn apply_to_log(&self, log: &mut Log) {
118118
let _log = log;
119119
minimal_unreachable!();

sentry-core/src/scope/real.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::performance::TransactionOrSpan;
99
use crate::protocol::{
1010
Attachment, Breadcrumb, Context, Event, Level, TraceContext, Transaction, User, Value,
1111
};
12-
#[cfg(feature = "logs")]
12+
#[cfg(feature = "UNSTABLE_logs")]
1313
use crate::protocol::{Log, LogAttribute};
1414
#[cfg(feature = "release-health")]
1515
use crate::session::Session;
@@ -350,7 +350,7 @@ impl Scope {
350350

351351
/// Applies the contained scoped data to a log, setting the `trace_id` and certain default
352352
/// attributes.
353-
#[cfg(feature = "logs")]
353+
#[cfg(feature = "UNSTABLE_logs")]
354354
pub fn apply_to_log(&self, log: &mut Log, send_default_pii: bool) {
355355
if let Some(span) = self.span.as_ref() {
356356
log.trace_id = Some(span.get_trace_context().trace_id);

sentry/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ opentelemetry = ["sentry-opentelemetry"]
4848
# other features
4949
test = ["sentry-core/test"]
5050
release-health = ["sentry-core/release-health", "sentry-actix?/release-health"]
51-
logs = ["sentry-core/logs"]
51+
UNSTABLE_logs = ["sentry-core/UNSTABLE_logs"]
5252
# transports
5353
transport = ["reqwest", "native-tls"]
5454
reqwest = ["dep:reqwest", "httpdate", "tokio"]

sentry/tests/test_basic.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ fn test_panic_scope_pop() {
265265
);
266266
}
267267

268-
#[cfg(feature = "logs")]
268+
#[cfg(feature = "UNSTABLE_logs")]
269269
#[test]
270270
fn test_basic_capture_log() {
271271
use std::time::SystemTime;
@@ -314,7 +314,7 @@ fn test_basic_capture_log() {
314314
}
315315
}
316316

317-
#[cfg(feature = "logs")]
317+
#[cfg(feature = "UNSTABLE_logs")]
318318
#[test]
319319
fn test_basic_capture_log_macro_message() {
320320
use sentry_core::logger_info;
@@ -349,7 +349,7 @@ fn test_basic_capture_log_macro_message() {
349349
}
350350
}
351351

352-
#[cfg(feature = "logs")]
352+
#[cfg(feature = "UNSTABLE_logs")]
353353
#[test]
354354
fn test_basic_capture_log_macro_message_formatted() {
355355
use sentry::protocol::LogAttribute;
@@ -416,7 +416,7 @@ fn test_basic_capture_log_macro_message_formatted() {
416416
}
417417
}
418418

419-
#[cfg(feature = "logs")]
419+
#[cfg(feature = "UNSTABLE_logs")]
420420
#[test]
421421
fn test_basic_capture_log_macro_message_with_attributes() {
422422
use sentry::protocol::LogAttribute;
@@ -475,7 +475,7 @@ fn test_basic_capture_log_macro_message_with_attributes() {
475475
}
476476
}
477477

478-
#[cfg(feature = "logs")]
478+
#[cfg(feature = "UNSTABLE_logs")]
479479
#[test]
480480
fn test_basic_capture_log_macro_message_formatted_with_attributes() {
481481
use sentry::protocol::LogAttribute;

0 commit comments

Comments
 (0)