Skip to content

Commit

Permalink
Merge cb5dec2 into 44d5b42
Browse files Browse the repository at this point in the history
  • Loading branch information
lbloder authored Dec 10, 2024
2 parents 44d5b42 + cb5dec2 commit 42a4b98
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import io.opentelemetry.api.trace.Span;
import io.opentelemetry.api.trace.StatusCode;
import io.opentelemetry.context.Scope;
import io.opentelemetry.sdk.OpenTelemetrySdk;
import io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdk;
import io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdkBuilder;
import io.sentry.Breadcrumb;
import io.sentry.EventProcessor;
import io.sentry.Hint;
Expand All @@ -17,10 +20,23 @@
import io.sentry.protocol.Message;
import io.sentry.protocol.User;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

public class Main {

public static void main(String[] args) throws InterruptedException {
final OpenTelemetrySdk sdk = AutoConfiguredOpenTelemetrySdk.builder()
.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().getOpenTelemetrySdk();
GlobalOpenTelemetry.set(sdk);

Sentry.init(
options -> {
// NOTE: Replace the test DSN below with YOUR OWN DSN to see the events from this app in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,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;
}
});
});
Expand Down Expand Up @@ -155,7 +155,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);
// Transactions can contain one or more Spans
ISpan outerSpan = transaction.startChild("child");
Thread.sleep(100);
Expand Down

0 comments on commit 42a4b98

Please sign in to comment.