Skip to content

Commit a90f316

Browse files
committed
make todo url configurable
1 parent 156b915 commit a90f316

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

sentry-samples/sentry-samples-spring-boot-jakarta-opentelemetry/src/main/java/io/sentry/samples/spring/boot/jakarta/TodoController.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import io.sentry.Sentry;
88
import io.sentry.spring.jakarta.webflux.ReactorUtils;
99
import org.jetbrains.annotations.NotNull;
10+
import org.jetbrains.annotations.Nullable;
11+
import org.springframework.beans.factory.annotation.Value;
1012
import org.springframework.web.bind.annotation.GetMapping;
1113
import org.springframework.web.bind.annotation.PathVariable;
1214
import org.springframework.web.bind.annotation.RestController;
@@ -24,6 +26,9 @@ public class TodoController {
2426
private final RestClient restClient;
2527
private final Tracer tracer;
2628

29+
@Value("sentry.sample.todo-url")
30+
public @Nullable String todoUrl;
31+
2732
public TodoController(
2833
RestTemplate restTemplate, WebClient webClient, RestClient restClient, Tracer tracer) {
2934
this.restTemplate = restTemplate;
@@ -38,8 +43,7 @@ Todo todo(@PathVariable Long id) {
3843
try (final @NotNull Scope spanScope = otelSpan.makeCurrent()) {
3944
ISpan sentrySpan = Sentry.getSpan().startChild("todoSpanSentryApi");
4045
try {
41-
return restTemplate.getForObject(
42-
"https://jsonplaceholder.typicode.com/todos/{id}", Todo.class, id);
46+
return restTemplate.getForObject(todoUrl + "/todos/{id}", Todo.class, id);
4347
} finally {
4448
sentrySpan.finish();
4549
}
@@ -58,7 +62,7 @@ Todo todoWebClient(@PathVariable Long id) {
5862
x ->
5963
webClient
6064
.get()
61-
.uri("https://jsonplaceholder.typicode.com/todos/{id}", id)
65+
.uri(todoUrl + "/todos/{id}", id)
6266
.retrieve()
6367
.bodyToMono(Todo.class)
6468
.map(response -> response)))
@@ -73,7 +77,7 @@ Todo todoRestClient(@PathVariable Long id) {
7377
try {
7478
return restClient
7579
.get()
76-
.uri("https://jsonplaceholder.typicode.com/todos/{id}", id)
80+
.uri(todoUrl + "/todos/{id}", id)
7781
.retrieve()
7882
.body(Todo.class);
7983
} finally {

sentry-samples/sentry-samples-spring-boot-jakarta-opentelemetry/src/main/resources/application.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ sentry.enable-backpressure-handling=true
1616
sentry.enable-spotlight=true
1717
sentry.enablePrettySerializationOutput=false
1818
in-app-includes="io.sentry.samples"
19+
sentry.sample.todo-url=https://jsonplaceholder.typicode.com
1920

2021
# Uncomment and set to true to enable aot compatibility
2122
# This flag disables all AOP related features (i.e. @SentryTransaction, @SentrySpan)

test/system-test-spring-server-start.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ fi
1515

1616
echo "$JAVA_AGENT_STRING"
1717

18-
SENTRY_DSN="http://502f25099c204a2fbf4cb16edc5975d1@localhost:8000/0" SENTRY_AUTO_INIT=${JAVA_AGENT_AUTO_INIT} SENTRY_TRACES_SAMPLE_RATE=1.0 OTEL_TRACES_EXPORTER=none OTEL_METRICS_EXPORTER=none OTEL_LOGS_EXPORTER=none java ${JAVA_AGENT_STRING} -jar sentry-samples/${SAMPLE_MODULE}/build/libs/${SAMPLE_MODULE}-0.0.1-SNAPSHOT.jar > spring-server.txt 2>&1 &
18+
SENTRY_DSN="http://502f25099c204a2fbf4cb16edc5975d1@localhost:8000/0" SENTRY_SAMPLE_TODO_URL="http://localhost:48080" SENTRY_AUTO_INIT=${JAVA_AGENT_AUTO_INIT} SENTRY_TRACES_SAMPLE_RATE=1.0 OTEL_TRACES_EXPORTER=none OTEL_METRICS_EXPORTER=none OTEL_LOGS_EXPORTER=none java ${JAVA_AGENT_STRING} -jar sentry-samples/${SAMPLE_MODULE}/build/libs/${SAMPLE_MODULE}-0.0.1-SNAPSHOT.jar > spring-server.txt 2>&1 &
1919
echo $! > spring-server.pid

0 commit comments

Comments
 (0)