-
-
Notifications
You must be signed in to change notification settings - Fork 201
Closed
Description
Description
I've got a bunch of data added with sentry_set_context() but it isn't being reported by sentry-native. Events come in, missing all the context I added.
When does the problem happen
- During build
- During run-time
- When capturing a hard crash
Environment
N/A for this issue, as I've already root caused it. See further below.
Steps To Reproduce
- Build sentry-native without
SENTRY_PERFORMANCE_MONITORING - Add context with
sentry_set_context() - Send an event.
- Note the context is absent in the reported event.
Log output
N/A for this issue, as I've already root caused it. See below.
Patch
It appears that running a sentry-native build without SENTRY_PERFORMANCE_MONITORING causes context to be dropped at event submission time. I applied the following patch locally, which seems to solve it (this patch could be a bit cleaner if the context was added above the SENTRY_PERFORMANCE_MONITORING check, but I wanted to show a minimal patch to resolve it):
diff --git a/src/sentry_scope.c b/src/sentry_scope.c
index 417a1f6..3511b20 100644
--- a/src/sentry_scope.c
+++ b/src/sentry_scope.c
@@ -326,8 +326,8 @@ sentry__scope_apply_to_event(const sentry_scope_t *scope,
sentry__value_merge_objects(event_extra, scope->extra);
}
-#ifdef SENTRY_PERFORMANCE_MONITORING
sentry_value_t contexts = sentry__value_clone(scope->contexts);
+#ifdef SENTRY_PERFORMANCE_MONITORING
// prep contexts sourced from scope; data about transaction on scope needs
// to be extracted and inserted
sentry_value_t scope_trace = sentry__value_get_trace_context(
@@ -338,6 +338,7 @@ sentry__scope_apply_to_event(const sentry_scope_t *scope,
}
sentry_value_set_by_key(contexts, "trace", scope_trace);
}
+#endif
// merge contexts sourced from scope into the event
sentry_value_t event_contexts = sentry_value_get_by_key(event, "contexts");
@@ -347,7 +348,6 @@ sentry__scope_apply_to_event(const sentry_scope_t *scope,
sentry__value_merge_objects(event_contexts, contexts);
}
sentry_value_decref(contexts);
-#endif
if (mode & SENTRY_SCOPE_BREADCRUMBS) {
PLACE_CLONED_VALUE("breadcrumbs", scope->breadcrumbs);Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels