Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
2ad0d1f
feat(internal): scope observer
jpnurmi Jul 1, 2026
7907c62
sentry_scope_update_context: add missing notify
jpnurmi Jul 3, 2026
7c77665
sentry__ringbuffer_append returns -1 on failure
jpnurmi Jul 3, 2026
e05d07d
don't notify duplicate attachments
jpnurmi Jul 3, 2026
405f148
sentry_transaction_start: notify
jpnurmi Jul 3, 2026
236a9d6
notity scope-level attachment changes
jpnurmi Jul 3, 2026
9b33928
fix sentry_clear_attachments
jpnurmi Jul 3, 2026
9d38f2b
add_observer: return bool
jpnurmi Jul 4, 2026
542b8df
add remove_observer
jpnurmi Jul 4, 2026
2f6f32b
update tests
jpnurmi Jul 4, 2026
df89cad
prevent array shift during notify iteration
jpnurmi Jul 4, 2026
48ef4dc
fix nested notify
jpnurmi Jul 4, 2026
a57f1b9
test no flush
jpnurmi Jul 4, 2026
c9c24e1
was_notifying (tsan)
jpnurmi Jul 4, 2026
23a1baf
trace context
jpnurmi Jul 4, 2026
f7a02c8
Revert "trace context"
jpnurmi Jul 6, 2026
0f344d6
fix flush for reentrant scope changes
jpnurmi Jul 7, 2026
2ad380b
remove misleading notifications
jpnurmi Jul 7, 2026
071419b
remove clunky _len args
jpnurmi Jul 9, 2026
00e4236
eliminate unnecessary string allocations in scope_set_xxx
jpnurmi Jul 9, 2026
25c03a6
make format
jpnurmi Jul 9, 2026
df3338c
add note
jpnurmi Jul 9, 2026
a9514d3
Merge remote-tracking branch 'origin/master' into jpnurmi/feat/scope-…
jpnurmi Jul 20, 2026
679a483
avoid key copies on removals
jpnurmi Jul 20, 2026
43ce1df
add missing notification for scope_clear
jpnurmi Jul 20, 2026
fb78775
clear: fix is_notifying/pending_flush
jpnurmi Jul 20, 2026
c634cd9
fix up merge
jpnurmi Jul 20, 2026
881223e
add test coverage
jpnurmi Jul 20, 2026
975e299
test deferred flush
jpnurmi Jul 20, 2026
5ccbbeb
doc: explain data pointer
jpnurmi Jul 20, 2026
925cfa2
Merge remote-tracking branch 'origin/master' into jpnurmi/feat/scope-…
jpnurmi Jul 21, 2026
9236a62
call sentry_set_transaction_n
jpnurmi Jul 21, 2026
55d98f8
add more coverage
jpnurmi Jul 21, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/sentry_attachment.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,25 +262,27 @@ sentry__attachments_add_path(sentry_attachment_t **attachments_ptr,
return sentry__attachments_add(attachments_ptr, attachment);
}

void
bool
sentry__attachments_remove(
sentry_attachment_t **attachments_ptr, sentry_attachment_t *attachment)
{
if (!attachment) {
return;
return false;
}

sentry_attachment_t **next_ptr = attachments_ptr;

for (sentry_attachment_t *it = *attachments_ptr; it; it = it->next) {
if (it == attachment) {
*next_ptr = it->next;
sentry__attachment_free(it);
return;
it->next = NULL;
return true;
}

next_ptr = &it->next;
}

return false;
}

static sentry_attachment_t *
Expand Down
3 changes: 2 additions & 1 deletion src/sentry_attachment.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ sentry_attachment_t *sentry__attachments_add_path(

/**
* Removes an attachment from the attachments list at `attachments_ptr`.
* Returns true if the attachment was found and removed.
*/
void sentry__attachments_remove(
bool sentry__attachments_remove(
sentry_attachment_t **attachments_ptr, sentry_attachment_t *attachment);

/**
Expand Down
84 changes: 58 additions & 26 deletions src/sentry_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,7 @@ sentry_set_release_n(const char *release, size_t release_len)
scope->release = sentry__string_clone_n(release, release_len);
sentry_value_set_by_key(scope->dynamic_sampling_context, "release",
sentry_value_new_string(scope->release));
SENTRY_SCOPE_NOTIFY(scope, set_release, scope->release);
}
}

Expand All @@ -945,6 +946,7 @@ sentry_set_environment_n(const char *environment, size_t environment_len)
= sentry__string_clone_n(environment, environment_len);
sentry_value_set_by_key(scope->dynamic_sampling_context, "environment",
sentry_value_new_string(scope->environment));
SENTRY_SCOPE_NOTIFY(scope, set_environment, scope->environment);
}
}

Expand Down Expand Up @@ -1010,15 +1012,22 @@ void
sentry_remove_tag(const char *key)
{
SENTRY_WITH_SCOPE_MUT (scope) {
sentry_value_remove_by_key(scope->tags, key);
if (sentry_value_remove_by_key(scope->tags, key) == 0) {
SENTRY_SCOPE_NOTIFY(scope, remove_tag, key);
}
}
}

void
sentry_remove_tag_n(const char *key, size_t key_len)
{
SENTRY_WITH_SCOPE_MUT (scope) {
sentry_value_remove_by_key_n(scope->tags, key, key_len);
char *k
= sentry__value_remove_and_take_key_n(scope->tags, key, key_len);
if (k) {
SENTRY_SCOPE_NOTIFY(scope, remove_tag, k);
}
sentry_free(k);
}
}

Expand All @@ -1042,15 +1051,22 @@ void
sentry_remove_extra(const char *key)
{
SENTRY_WITH_SCOPE_MUT (scope) {
sentry_value_remove_by_key(scope->extra, key);
if (sentry_value_remove_by_key(scope->extra, key) == 0) {
SENTRY_SCOPE_NOTIFY(scope, remove_extra, key);
}
}
}

void
sentry_remove_extra_n(const char *key, size_t key_len)
{
SENTRY_WITH_SCOPE_MUT (scope) {
sentry_value_remove_by_key_n(scope->extra, key, key_len);
char *k
= sentry__value_remove_and_take_key_n(scope->extra, key, key_len);
if (k) {
SENTRY_SCOPE_NOTIFY(scope, remove_extra, k);
}
sentry_free(k);
}
}

Expand Down Expand Up @@ -1151,15 +1167,22 @@ void
sentry_remove_context(const char *key)
{
SENTRY_WITH_SCOPE_MUT (scope) {
sentry_value_remove_by_key(scope->contexts, key);
if (sentry_value_remove_by_key(scope->contexts, key) == 0) {
SENTRY_SCOPE_NOTIFY(scope, remove_context, key);
}
}
}

void
sentry_remove_context_n(const char *key, size_t key_len)
{
SENTRY_WITH_SCOPE_MUT (scope) {
sentry_value_remove_by_key_n(scope->contexts, key, key_len);
char *k = sentry__value_remove_and_take_key_n(
scope->contexts, key, key_len);
if (k) {
SENTRY_SCOPE_NOTIFY(scope, remove_context, k);
}
sentry_free(k);
}
}

Expand Down Expand Up @@ -1196,6 +1219,7 @@ sentry_remove_fingerprint(void)
SENTRY_WITH_SCOPE_MUT (scope) {
sentry_value_decref(scope->fingerprint);
scope->fingerprint = sentry_value_new_null();
SENTRY_SCOPE_NOTIFY(scope, set_fingerprint, scope->fingerprint);
}
}

Expand Down Expand Up @@ -1257,14 +1281,7 @@ sentry_regenerate_trace(void)
void
sentry_set_transaction(const char *transaction)
{
SENTRY_WITH_SCOPE_MUT (scope) {
sentry_free(scope->transaction);
scope->transaction = sentry__string_clone(transaction);

if (scope->transaction_object) {
sentry_transaction_set_name(scope->transaction_object, transaction);
}
}
sentry_set_transaction_n(transaction, sentry__guarded_strlen(transaction));
}

void
Expand All @@ -1279,6 +1296,7 @@ sentry_set_transaction_n(const char *transaction, size_t transaction_len)
sentry_transaction_set_name_n(
scope->transaction_object, transaction, transaction_len);
}
SENTRY_SCOPE_NOTIFY(scope, set_transaction, scope->transaction);
}
}

Expand Down Expand Up @@ -1961,13 +1979,17 @@ sentry_capture_minidump_n(const char *path, size_t path_len)
static sentry_attachment_t *
add_attachment(sentry_attachment_t *attachment)
{
if (!attachment) {
return NULL;
}

SENTRY_WITH_OPTIONS (options) {
if (options->backend && options->backend->add_attachment_func) {
options->backend->add_attachment_func(options->backend, attachment);
}
}
SENTRY_WITH_SCOPE_MUT (scope) {
attachment = sentry__attachments_add(&scope->attachments, attachment);
attachment = sentry__scope_add_attachment(scope, attachment);
}
return attachment;
}
Comment thread
sentry[bot] marked this conversation as resolved.
Expand Down Expand Up @@ -2005,31 +2027,41 @@ sentry_clear_attachments(void)
{
SENTRY_WITH_OPTIONS (options) {
SENTRY_WITH_SCOPE_MUT (scope) {
if (options->backend && options->backend->remove_attachment_func) {
for (sentry_attachment_t *it = scope->attachments; it;
it = it->next) {
sentry_attachment_t *attachments = scope->attachments;
scope->attachments = NULL;
for (sentry_attachment_t *it = attachments; it; it = it->next) {
if (options->backend
&& options->backend->remove_attachment_func) {
options->backend->remove_attachment_func(
options->backend, it);
}
SENTRY_SCOPE_NOTIFY(scope, remove_attachment, it);
Comment thread
cursor[bot] marked this conversation as resolved.
}
sentry__attachments_free(scope->attachments);
scope->attachments = NULL;
sentry__attachments_free(attachments);
}
}
}

void
sentry_remove_attachment(sentry_attachment_t *attachment)
{
if (!attachment) {
return;
}

SENTRY_WITH_OPTIONS (options) {
if (options->backend && options->backend->remove_attachment_func) {
options->backend->remove_attachment_func(
options->backend, attachment);
SENTRY_WITH_SCOPE_MUT (scope) {
if (sentry__attachments_remove(&scope->attachments, attachment)) {
if (options->backend
&& options->backend->remove_attachment_func) {
options->backend->remove_attachment_func(
options->backend, attachment);
}
SENTRY_SCOPE_NOTIFY(scope, remove_attachment, attachment);
sentry__attachment_free(attachment);
}
Comment thread
jpnurmi marked this conversation as resolved.
}
}
SENTRY_WITH_SCOPE_MUT (scope) {
sentry__attachments_remove(&scope->attachments, attachment);
}
}

#ifdef SENTRY_PLATFORM_WINDOWS
Expand Down
Loading
Loading