Skip to content

Commit

Permalink
better names for functions to avoid confusion
Browse files Browse the repository at this point in the history
  • Loading branch information
relaxolotl committed Dec 14, 2021
1 parent cae8d9d commit ffc13df
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/sentry_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -386,27 +386,27 @@ sentry_capture_event(sentry_value_t event)
}

bool
sentry__make_sampling_decision(double sample_rate)
sentry__is_unsampled(double sample_rate)
{
uint64_t rnd;
return sample_rate < 1.0 && !sentry__getrandom(&rnd, sizeof(rnd))
&& ((double)rnd / (double)UINT64_MAX) > sample_rate;
}

bool
sentry__should_sample_transaction(sentry_value_t tx_cxt)
sentry__should_skip_transaction(sentry_value_t tx_cxt)
{
sentry_value_t context_setting = sentry_value_get_by_key(tx_cxt, "sampled");
if (!sentry_value_is_null(context_setting)) {
return sentry_value_is_true(context_setting);
return !sentry_value_is_true(context_setting);
}

bool sample = false;
bool skip = true;
SENTRY_WITH_OPTIONS (options) {
sample = sentry__make_sampling_decision(options->traces_sample_rate);
skip = sentry__is_unsampled(options->traces_sample_rate);
// TODO: run through traces sampler function if rate is unavailable
}
return sample;
return skip;
}

bool
Expand All @@ -415,11 +415,11 @@ sentry__should_skip_event(const sentry_options_t *options, sentry_value_t event)
sentry_value_t event_type = sentry_value_get_by_key(event, "type");
// Not a transaction
if (sentry_value_is_null(event_type)) {
return sentry__make_sampling_decision(options->sample_rate);
return sentry__is_unsampled(options->sample_rate);
} else {
// The sampling decision should already be made for transactions
// during their construction. No need to recalculate here.
// See `sentry__should_sample_transaction`.
// See `sentry__should_skip_transaction`.
return !sentry_value_is_true(sentry_value_get_by_key(event, "sampled"));
}
}
Expand Down

0 comments on commit ffc13df

Please sign in to comment.