-
-
Notifications
You must be signed in to change notification settings - Fork 443
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
[WIP] fix console samples #3979
base: feat/update-otel-sample-readme
Are you sure you want to change the base?
Changes from 6 commits
3d8511b
cb5dec2
4ab84f2
2286edd
cb09dcc
1c79edf
eb50dd9
2ffbf93
bbfcea0
ca4cb47
ef4ff97
1836553
4eed72a
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")) { | ||
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. Makes the code do what the comment says :) |
||
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,7 +156,9 @@ 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"); | ||
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); | ||
|
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.
AutoConfiguredOpentelemetry
is needed to initialize spi provided classes.We can make this a little simpler by using
setResultAsGlobal()
on the builder: