sentry-python icon indicating copy to clipboard operation
sentry-python copied to clipboard

Transaction.set_data() does not work

Open remilapeyre opened this issue 5 years ago • 2 comments

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.

remilapeyre avatar Nov 24 '20 20:11 remilapeyre

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.

sl0thentr0py avatar Dec 15 '21 15:12 sl0thentr0py

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"

smeubank avatar Apr 08 '22 09:04 smeubank

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.

eddyg avatar Oct 29 '22 02:10 eddyg

This is not yet on our roadmap, but we keep it in the backlog. It will happen someday.

antonpirker avatar Nov 07 '22 13:11 antonpirker