Make hub a required argument for Transaction constructor#1401
Conversation
| attr_reader :name, :parent_sampled, :hub, :configuration, :logger | ||
|
|
||
| def initialize(name: nil, parent_sampled: nil, hub: Sentry.get_current_hub, **options) | ||
| def initialize(name: nil, parent_sampled: nil, hub:, **options) |
There was a problem hiding this comment.
@st0012 I'm learning Ruby from you, thanks!
I just tried this out on irb. So if hub is not set, there's an error:
ArgumentError (missing keyword: hub)
Nice!
Not in the scope of this PR, but wanted to share that this could as well be the behavior for name. Transactions must have a name. Deciding if it is required or not in the constructor is debatable though, sometimes you don't know the name or need to update it later before sending the transaction. In some languages we write a debug message if the name is not set right before sending the transaction to Sentry.
If a transaction is sent without a name it gets a default value, but that's not very useful. The transaction name is what is used to group the many different traces.
There was a problem hiding this comment.
thanks for pointing out the potential issue. I'll keep that in mind 🙂
This implements the change proposed in #1393.
Closes #1393