Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaMoelans committed Dec 23, 2024
1 parent 26ff58a commit cc77b52
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
3 changes: 2 additions & 1 deletion include/sentry.h
Original file line number Diff line number Diff line change
Expand Up @@ -1535,7 +1535,8 @@ SENTRY_EXPERIMENTAL_API double sentry_options_get_traces_sample_rate(

struct sentry_sampling_context_s;
typedef struct sentry_sampling_context_s sentry_sampling_context_t;
typedef double (*sentry_traces_sampler_function)(sentry_sampling_context_t *sampling_ctx);
typedef double (*sentry_traces_sampler_function)(
sentry_sampling_context_t *sampling_ctx);

/**
* Sets the traces sampler callback. Should be a function that returns a double
Expand Down
13 changes: 10 additions & 3 deletions src/sentry_sampling_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
#include <sentry_alloc.h>
#include <stdlib.h>

sentry_sampling_context_t *sentry_sampling_context_new(sentry_transaction_context_t *transaction_context) {
sentry_sampling_context_t *
sentry_sampling_context_new(sentry_transaction_context_t *transaction_context)
{
sentry_sampling_context_t *context = SENTRY_MAKE(sentry_sampling_context_t);
if (context) {
context->transaction_context = transaction_context; // todo incref?
Expand All @@ -12,8 +14,13 @@ sentry_sampling_context_t *sentry_sampling_context_new(sentry_transaction_contex
return context;
}

sentry_sampling_context_t *sentry_sampling_context_new_with_custom(sentry_transaction_context_t *transaction_context, void *custom_sampling_context) {
sentry_sampling_context_t *context = sentry_sampling_context_new(transaction_context);
sentry_sampling_context_t *
sentry_sampling_context_new_with_custom(
sentry_transaction_context_t *transaction_context,
void *custom_sampling_context)
{
sentry_sampling_context_t *context
= sentry_sampling_context_new(transaction_context);
if (context) {
context->custom_sampling_context = custom_sampling_context;
}
Expand Down
7 changes: 5 additions & 2 deletions src/sentry_sampling_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ typedef struct sentry_sampling_context_s {
} sentry_sampling_context_t;

// TODO add refcounting for this; users might want to reuse this
sentry_sampling_context_t *sentry_sampling_context_new(sentry_transaction_context_t *transaction_context);
sentry_sampling_context_t *sentry_sampling_context_new_with_custom(sentry_transaction_context_t *transaction_context, void *custom_sampling_context);
sentry_sampling_context_t *sentry_sampling_context_new(
sentry_transaction_context_t *transaction_context);
sentry_sampling_context_t *sentry_sampling_context_new_with_custom(
sentry_transaction_context_t *transaction_context,
void *custom_sampling_context);

#endif // SENTRY_SAMPLING_CONTEXT_H_INCLUDED

0 comments on commit cc77b52

Please sign in to comment.