Conversation
…n.properties in noagent samples
Instructions and example for changelogPlease add an entry to Example: ## Unreleased
- [WIP] fix console samples ([#3979](https://github.com/getsentry/sentry-java/pull/3979))If none of the above apply, you can opt out of this check by adding |
Performance metrics 🚀
|
…-java into fix/fix-console-samples
…ter OTEL AutoInit
| final TransactionOptions options = new TransactionOptions(); | ||
| options.setBindToScope(true); | ||
| ITransaction transaction = Sentry.startTransaction("transaction name", "op", options); |
There was a problem hiding this comment.
Binding the transaction to scope is required here for the sample to work as expected as later in the code we have a line Sentry.captureMessage("this message is connected to the outerSpan"); which only works as described if the transaction is on the scope IIRC.
| 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.
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.
set to 1.0 for all transactions except for /products to make it easier for people trying this sample
| public class Main { | ||
|
|
||
| public static void main(String[] args) throws InterruptedException { | ||
| final OpenTelemetrySdk sdk = |
There was a problem hiding this comment.
AutoConfiguredOpentelemetry is needed to initialize spi provided classes.
We can make this a little simpler by using setResultAsGlobal() on the builder:
AutoConfiguredOpenTelemetrySdk.builder()
.setResultAsGlobal()
.addPropertiesSupplier(
() -> {
final Map<String, String> properties = new HashMap<>();
properties.put("otel.logs.exporter", "none");
properties.put("otel.metrics.exporter", "none");
properties.put("otel.traces.exporter", "none");
return properties;
})
.build();
# Conflicts: # sentry-opentelemetry/README.md # sentry-opentelemetry/sentry-opentelemetry-agent/README.md # sentry-opentelemetry/sentry-opentelemetry-agentless/README.md
📜 Description
Fixes the sentry console samples
💡 Motivation and Context
The
sentry-samples-console-opentelemetry-noagentsample did not produce any spans.💚 How did you test it?
📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps