Skip to content

Commit 3e687f1

Browse files
authored
Remove profiling support (#595)
1 parent 3ab112c commit 3e687f1

File tree

11 files changed

+5
-553
lines changed

11 files changed

+5
-553
lines changed

sentry-core/Cargo.toml

-11
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ client = ["rand"]
2626
# and macros actually expand features (and extern crate) where they are used!
2727
debug-logs = ["dep:log"]
2828
test = ["client"]
29-
profiling = ["pprof", "build_id", "uuid", "sys-info", "findshlibs", "rustc_version_runtime", "libc", "indexmap"]
30-
frame-pointer = ["pprof?/frame-pointer"]
3129

3230
[dependencies]
3331
log = { version = "0.4.8", optional = true, features = ["std"] }
@@ -37,15 +35,6 @@ sentry-types = { version = "0.31.5", path = "../sentry-types" }
3735
serde = { version = "1.0.104", features = ["derive"] }
3836
serde_json = { version = "1.0.46" }
3937
uuid = { version = "1.0.0", features = ["v4", "serde"], optional = true }
40-
sys-info = { version = "0.9.1", optional = true }
41-
build_id = { version = "0.2.1", optional = true }
42-
findshlibs = { version = "=0.10.2", optional = true }
43-
rustc_version_runtime = { version = "0.2.1", optional = true }
44-
indexmap = { version = "1.9.1", optional = true }
45-
46-
[target.'cfg(target_family = "unix")'.dependencies]
47-
pprof = { version = "0.11.0", optional = true, default-features = false }
48-
libc = { version = "^0.2.66", optional = true }
4938

5039
[dev-dependencies]
5140
# Because we re-export all the public API in `sentry`, we actually run all the

sentry-core/src/clientoptions.rs

+1-17
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::sync::Arc;
44
use std::time::Duration;
55

66
use crate::constants::USER_AGENT;
7-
use crate::performance::{ProfilesSampler, TracesSampler};
7+
use crate::performance::TracesSampler;
88
use crate::protocol::{Breadcrumb, Event};
99
use crate::types::Dsn;
1010
use crate::{Integration, IntoDsn, TransportFactory};
@@ -80,17 +80,6 @@ pub struct ClientOptions {
8080
/// Return a sample rate between 0.0 and 1.0 for the transaction in question.
8181
/// Takes priority over the `sample_rate`.
8282
pub traces_sampler: Option<Arc<TracesSampler>>,
83-
/// Enables profiling
84-
pub enable_profiling: bool,
85-
/// The sample rate for profiling a transactions. (0.0 - 1.0, defaults to 0.0)
86-
///
87-
/// This represents the probability that a sampled transaction
88-
/// will send a profile to Sentry
89-
pub profiles_sample_rate: f32,
90-
/// If given, called with a TransactionContext for each profile to determine the sampling rate.
91-
///
92-
/// Return a sample rate between 0.0 and 1.0 for the profile in question.
93-
pub profiles_sampler: Option<Arc<ProfilesSampler>>,
9483
/// Maximum number of breadcrumbs. (defaults to 100)
9584
pub max_breadcrumbs: usize,
9685
/// Attaches stacktraces to messages.
@@ -213,8 +202,6 @@ impl fmt::Debug for ClientOptions {
213202
.as_ref()
214203
.map(|arc| std::ptr::addr_of!(**arc)),
215204
)
216-
.field("enable_profiling", &self.enable_profiling)
217-
.field("profiles_sample_rate", &self.profiles_sample_rate)
218205
.field("max_breadcrumbs", &self.max_breadcrumbs)
219206
.field("attach_stacktrace", &self.attach_stacktrace)
220207
.field("send_default_pii", &self.send_default_pii)
@@ -249,9 +236,6 @@ impl Default for ClientOptions {
249236
sample_rate: 1.0,
250237
traces_sample_rate: 0.0,
251238
traces_sampler: None,
252-
enable_profiling: false,
253-
profiles_sample_rate: 0.0,
254-
profiles_sampler: None,
255239
max_breadcrumbs: 100,
256240
attach_stacktrace: false,
257241
send_default_pii: false,

sentry-core/src/lib.rs

-3
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,6 @@ pub use crate::client::Client;
150150
#[cfg(feature = "test")]
151151
pub mod test;
152152

153-
#[cfg(all(feature = "profiling", not(target_os = "windows")))]
154-
mod profiling;
155-
156153
// public api from other crates
157154
#[doc(inline)]
158155
pub use sentry_types as types;

sentry-core/src/performance.rs

+1-69
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ use std::collections::BTreeMap;
22
use std::ops::{Deref, DerefMut};
33
use std::sync::{Arc, Mutex, MutexGuard};
44

5-
#[cfg(all(feature = "profiling", target_family = "unix"))]
6-
use crate::profiling;
7-
85
use crate::{protocol, Hub};
96

107
#[cfg(feature = "client")]
@@ -230,9 +227,6 @@ impl TransactionContext {
230227
/// or ignore it.
231228
pub type TracesSampler = dyn Fn(&TransactionContext) -> f32 + Send + Sync;
232229

233-
/// Same as TracesSampler but for profiles
234-
pub type ProfilesSampler = TracesSampler;
235-
236230
// global API types:
237231

238232
/// A wrapper that groups a [`Transaction`] and a [`Span`] together.
@@ -360,8 +354,6 @@ pub(crate) struct TransactionInner {
360354
sampled: bool,
361355
pub(crate) context: protocol::TraceContext,
362356
pub(crate) transaction: Option<protocol::Transaction<'static>>,
363-
#[cfg(all(feature = "profiling", target_family = "unix"))]
364-
pub(crate) profiler_guard: Option<profiling::ProfilerGuard>,
365357
}
366358

367359
type TransactionArc = Arc<Mutex<TransactionInner>>;
@@ -384,18 +376,6 @@ fn transaction_sample_rate(
384376
}
385377
}
386378

387-
#[cfg(all(feature = "profiling", target_family = "unix"))]
388-
fn profile_sample_rate(
389-
profile_sampler: Option<&ProfilesSampler>,
390-
ctx: &TransactionContext,
391-
profiles_sample_rate: f32,
392-
) -> f32 {
393-
match (profile_sampler, profiles_sample_rate) {
394-
(Some(profile_sampler), _) => profile_sampler(ctx),
395-
(None, profiles_sample_rate) => profiles_sample_rate,
396-
}
397-
}
398-
399379
/// Determine whether the new transaction should be sampled.
400380
#[cfg(feature = "client")]
401381
impl Client {
@@ -407,16 +387,6 @@ impl Client {
407387
client_options.traces_sample_rate,
408388
))
409389
}
410-
411-
#[cfg(all(feature = "profiling", target_family = "unix"))]
412-
pub(crate) fn is_profile_sampled(&self, ctx: &TransactionContext) -> bool {
413-
let client_options = self.options();
414-
self.sample_should_send(profile_sample_rate(
415-
client_options.traces_sampler.as_deref(),
416-
ctx,
417-
client_options.profiles_sample_rate,
418-
))
419-
}
420390
}
421391

422392
/// A running Performance Monitoring Transaction.
@@ -437,14 +407,6 @@ impl Transaction {
437407
client.is_transaction_sampled(&ctx),
438408
Some(protocol::Transaction {
439409
name: Some(ctx.name.clone()),
440-
#[cfg(all(feature = "profiling", target_family = "unix"))]
441-
active_thread_id: Some(
442-
// NOTE: `pthread_t` is a `usize`, so clippy is wrong complaining about this cast
443-
#[allow(clippy::unnecessary_cast)]
444-
unsafe {
445-
libc::pthread_self() as u64
446-
},
447-
),
448410
..Default::default()
449411
}),
450412
),
@@ -454,7 +416,7 @@ impl Transaction {
454416
let context = protocol::TraceContext {
455417
trace_id: ctx.trace_id,
456418
parent_span_id: ctx.parent_span_id,
457-
op: Some(ctx.op.clone()),
419+
op: Some(ctx.op),
458420
..Default::default()
459421
};
460422

@@ -464,25 +426,13 @@ impl Transaction {
464426
transaction = None;
465427
client = None;
466428
}
467-
// if the transaction was sampled then a profile, linked to the transaction,
468-
// might as well be sampled
469-
#[cfg(all(feature = "profiling", target_family = "unix"))]
470-
let profiler_guard = if sampled {
471-
client
472-
.as_deref()
473-
.and_then(|cli| profiling::start_profiling(cli, &ctx))
474-
} else {
475-
None
476-
};
477429

478430
Self {
479431
inner: Arc::new(Mutex::new(TransactionInner {
480432
client,
481433
sampled,
482434
context,
483435
transaction,
484-
#[cfg(all(feature = "profiling", target_family = "unix"))]
485-
profiler_guard,
486436
})),
487437
}
488438
}
@@ -502,8 +452,6 @@ impl Transaction {
502452
sampled,
503453
context,
504454
transaction: None,
505-
#[cfg(all(feature = "profiling", target_family = "unix"))]
506-
profiler_guard: None,
507455
})),
508456
}
509457
}
@@ -577,27 +525,11 @@ impl Transaction {
577525
transaction.environment = opts.environment.clone();
578526
transaction.sdk = Some(std::borrow::Cow::Owned(client.sdk_info.clone()));
579527

580-
// if the profiler is running for the given transaction
581-
// then call finish_profiling to return the profile
582-
#[cfg(all(feature = "profiling", target_family = "unix"))]
583-
let sample_profile = inner.profiler_guard.take().and_then(|profiler_guard| {
584-
profiling::finish_profiling(&transaction, profiler_guard, inner.context.trace_id)
585-
});
586528
drop(inner);
587529

588530
let mut envelope = protocol::Envelope::new();
589531
envelope.add_item(transaction);
590532

591-
#[cfg(all(feature = "profiling", target_family = "unix"))]
592-
if let Some(sample_profile) = sample_profile {
593-
if !sample_profile.profile.samples.is_empty(){
594-
envelope.add_item(sample_profile);
595-
}
596-
else {
597-
sentry_debug!("the profile is being dropped because it contains no samples");
598-
}
599-
}
600-
601533
client.send_envelope(envelope)
602534
}
603535
}

0 commit comments

Comments
 (0)