-
-
Notifications
You must be signed in to change notification settings - Fork 451
[WIP] fix console samples #3979
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
fae85e1
4fa4327
44d5b42
3d8511b
cb5dec2
4ab84f2
2286edd
cb09dcc
1c79edf
92e1fde
eb50dd9
8e9ce93
2ffbf93
8e854e7
bbfcea0
b1a5b9e
c7c68dd
0926957
ca4cb47
ef4ff97
1836553
848737d
4eed72a
f7d558d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
import io.sentry.SentryEvent; | ||
import io.sentry.SentryLevel; | ||
import io.sentry.SpanStatus; | ||
import io.sentry.TransactionOptions; | ||
import io.sentry.protocol.Message; | ||
import io.sentry.protocol.User; | ||
import java.util.Collections; | ||
|
@@ -86,10 +87,10 @@ public static void main(String[] args) throws InterruptedException { | |
options.setTracesSampler( | ||
context -> { | ||
// only 10% of transactions with "/product" prefix will be collected | ||
if (!context.getTransactionContext().getName().startsWith("/products")) { | ||
if (context.getTransactionContext().getName().startsWith("/products")) { | ||
return 0.1; | ||
} else { | ||
return 0.5; | ||
return 1.0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. set to |
||
} | ||
}); | ||
}); | ||
|
@@ -155,11 +156,15 @@ public static void main(String[] args) throws InterruptedException { | |
// | ||
// Transactions collect execution time of the piece of code that's executed between the start | ||
// and finish of transaction. | ||
ITransaction transaction = Sentry.startTransaction("transaction name", "op"); | ||
// Transactions need to be bound to scope in order to have `Messages` or `Exceptions` linked to | ||
// them | ||
final TransactionOptions options = new TransactionOptions(); | ||
options.setBindToScope(true); | ||
ITransaction transaction = Sentry.startTransaction("transaction name", "op", options); | ||
Comment on lines
+161
to
+163
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Binding the transaction to scope is required here for the sample to work as expected as later in the code we have a line |
||
// Transactions can contain one or more Spans | ||
ISpan outerSpan = transaction.startChild("child"); | ||
Thread.sleep(100); | ||
// Spans create a tree structure. Each span can have one ore more spans inside. | ||
// Spans create a tree structure. Each span can have one or more spans inside. | ||
ISpan innerSpan = outerSpan.startChild("jdbc", "select * from product where id = :id"); | ||
innerSpan.setStatus(SpanStatus.OK); | ||
Thread.sleep(300); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes the code do what the comment says :)