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

feat: add emitting of transaction data inside context trace data #1075

Merged
3 changes: 3 additions & 0 deletions src/sentry_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -934,6 +934,8 @@ sentry_transaction_finish(sentry_transaction_t *opaque_tx)
sentry_value_t trace_context
= sentry__value_get_trace_context(opaque_tx->inner);
sentry_value_t contexts = sentry_value_new_object();
sentry_value_set_by_key(
contexts, "data", sentry_value_get_by_key(tx, "extra"));
supervacuus marked this conversation as resolved.
Show resolved Hide resolved
JoshuaMoelans marked this conversation as resolved.
Show resolved Hide resolved
sentry_value_set_by_key(contexts, "trace", trace_context);
sentry_value_set_by_key(tx, "contexts", contexts);

Expand All @@ -944,6 +946,7 @@ sentry_transaction_finish(sentry_transaction_t *opaque_tx)
sentry_value_remove_by_key(tx, "op");
sentry_value_remove_by_key(tx, "description");
sentry_value_remove_by_key(tx, "status");
sentry_value_remove_by_key(tx, "extra");
supervacuus marked this conversation as resolved.
Show resolved Hide resolved

sentry__transaction_decref(opaque_tx);

Expand Down
13 changes: 13 additions & 0 deletions tests/unit/test_tracing.c
Original file line number Diff line number Diff line change
Expand Up @@ -1097,6 +1097,19 @@ SENTRY_TEST(txn_data)
sentry__transaction_decref(txn);
}

SENTRY_TEST(ctx_trace_data)
{
sentry_transaction_t *txn
= sentry__transaction_new(sentry_value_new_object());

sentry_transaction_set_data(
txn, "os.name", sentry_value_new_string("Linux"));
check_after_set(txn->inner, "extra", "os.name", "Linux");
sentry_value_set_by_key(txn->inner, "sampled", sentry_value_new_bool(true));

sentry_transaction_finish(txn);
JoshuaMoelans marked this conversation as resolved.
Show resolved Hide resolved
}

SENTRY_TEST(span_data)
{
sentry_transaction_t *txn
Expand Down
1 change: 1 addition & 0 deletions tests/unit/tests.inc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ XX(concurrent_uninit)
XX(count_sampled_events)
XX(crash_marker)
XX(crashed_last_run)
XX(ctx_trace_data)
XX(custom_logger)
XX(discarding_before_send)
XX(distributed_headers)
Expand Down
Loading