Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sentry events missing added context #675

Closed
2 of 3 tasks
tycho opened this issue Feb 9, 2022 · 1 comment · Fixed by #676
Closed
2 of 3 tasks

Sentry events missing added context #675

tycho opened this issue Feb 9, 2022 · 1 comment · Fixed by #676

Comments

@tycho
Copy link

tycho commented Feb 9, 2022

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);
@Swatinem
Copy link
Member

Thanks for the report and the patch @tycho !

This must have been a oversight when developing our performance monitoring integration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants