Replies: 3 comments 3 replies
-
Hello @jnsLn. While it seems like a fair request to me it could potentially break a lot of existing code out there if we were to change it. |
Beta Was this translation helpful? Give feedback.
-
What is your use case for doing this, @jnsLn? ITransaction transaction = Sentry.startTransaction("transactionName", "operation");
ISpan span = transaction .getLatestActiveSpan(); Is this not sufficient? ITransaction transaction = Sentry.startTransaction("transactionName", "operation");
ISpan span = transaction .getLatestActiveSpan();
if (span == null) {
span = transaction.startChild(/***/)
} |
Beta Was this translation helpful? Give feedback.
-
Hi @adinauer, thanks for your answer. Fair point about breaking existing code. It's more about how I use the transaction. I put it in my request scope / context. So when I inject it in my services it can be the first or a subsequent span.
So when I ever I inject my transaction I just call getLatestActiveSpanOrTransaction. A function that return the latest active child or the transaction itself would make it just a bit more convenient to use. Maybe I am just too picky or confused, but I expected a function called getLatestActiveSpan to return the transaction. Edit: Updating the Api would be nice, but considering it is an interface the behaviour might not be consistent.
|
Beta Was this translation helpful? Give feedback.
-
Hello,
I would expect getLatestActiveSpan() (Java integration) to return the transaction itself when no active child is present and not null.
ITransaction transaction = Sentry.startTransaction("transactionName", "operation");
ISpan span = transaction .getLatestActiveSpan()
Transaction is an ISpan and is active but it returns null.
Solution:
Beta Was this translation helpful? Give feedback.
All reactions