Transaction.set_data() does not work
The following code
import sentry_sdk
from sentry_sdk import start_transaction
sentry_sdk.init(traces_sample_rate=1.0, dsn=...)
with start_transaction(op="GetDatasets", name='DUMMY') as span:
span.set_data('foo', 'bar')
print('foo')
will silently discard the data set in the transaction as it is only currently supported by child spans, not the transaction despite the transaction inheriting from span. One solution to fix this would be to make Transaction.set_data() raise an exception as it should not be used, but I think the best path forward would be to add actual support to extra data in Transaction.
I think this will require changes in the API thought.
This is more than a year old, but for sake of completeness, you can see in our specs how the API is meant to be used. You should use with_transaction and then with_span and set the data on the span.
Re-opening this issue after an internal conversation. Summary below
FYI @evanpurkhiser
https://github.com/evanpurkhiser/venmo-auto-cashout/blob/master/venmo_auto_cashout/cli.py#L105-L111
tran.set_data(
"transactions",
[
{"payer": t.payer.display_name, "amount": t.amount, "note": t.note}
for t in eligable_transactions
Transaction data not shown in product and also not in JSON, due to reason above.
same as original issue, discussion was again around that this is not the cOrReCt way to use set_data, but then "why do we allow it?". Checking the original implementation @untitaker gave the input "Yes set_data only works on spans and there's no reason we can't change that"
Any plans to address this?
It would be useful for transaction.set_data() to "work" instead of being silently discarded, so consider this a +1.
This is not yet on our roadmap, but we keep it in the backlog. It will happen someday.