-
-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tracing): Drop unfinished spans from a transaction
- Loading branch information
1 parent
d07e1f0
commit 8f8ee90
Showing
4 changed files
with
79 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -455,5 +455,61 @@ SENTRY_TEST(overflow_spans) | |
sentry_close(); | ||
} | ||
|
||
static void | ||
check_spans(sentry_envelope_t *envelope, void *data) | ||
{ | ||
uint64_t *called = data; | ||
*called += 1; | ||
|
||
sentry_value_t transaction = sentry_envelope_get_transaction(envelope); | ||
TEST_CHECK(!sentry_value_is_null(transaction)); | ||
|
||
size_t span_count = sentry_value_get_length( | ||
sentry_value_get_by_key(transaction, "spans")); | ||
TEST_CHECK_INT_EQUAL(span_count, 1); | ||
|
||
sentry_envelope_free(envelope); | ||
} | ||
|
||
SENTRY_TEST(drop_unfinished_spans) | ||
{ | ||
uint64_t called_transport = 0; | ||
|
||
sentry_options_t *options = sentry_options_new(); | ||
sentry_options_set_dsn(options, "https://[email protected]/42"); | ||
|
||
sentry_transport_t *transport = sentry_transport_new(check_spans); | ||
sentry_transport_set_state(transport, &called_transport); | ||
sentry_options_set_transport(options, transport); | ||
|
||
sentry_options_set_traces_sample_rate(options, 1.0); | ||
sentry_options_set_max_spans(options, 2); | ||
sentry_init(options); | ||
|
||
sentry_value_t tx_cxt = sentry_value_new_transaction_context("wow!", NULL); | ||
sentry_transaction_start(tx_cxt); | ||
|
||
sentry_value_t child | ||
= sentry_span_start_child(sentry_value_new_null(), "honk", "goose"); | ||
TEST_CHECK(!sentry_value_is_null(child)); | ||
|
||
sentry_value_t grandchild = sentry_span_start_child(child, "beep", "car"); | ||
TEST_CHECK(!sentry_value_is_null(grandchild)); | ||
sentry_span_finish(grandchild); | ||
|
||
sentry_value_t scope_tx = sentry__scope_get_span(); | ||
TEST_CHECK_INT_EQUAL( | ||
sentry_value_get_length(sentry_value_get_by_key(scope_tx, "spans")), 2); | ||
|
||
sentry_uuid_t event_id = sentry_transaction_finish(); | ||
TEST_CHECK(!sentry_uuid_is_nil(&event_id)); | ||
|
||
sentry_value_decref(child); | ||
|
||
sentry_close(); | ||
|
||
TEST_CHECK_INT_EQUAL(called_transport, 1); | ||
} | ||
|
||
#undef IS_NULL | ||
#undef CHECK_STRING_PROPERTY |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters