7
7
import io .sentry .Sentry ;
8
8
import io .sentry .spring .jakarta .webflux .ReactorUtils ;
9
9
import org .jetbrains .annotations .NotNull ;
10
+ import org .jetbrains .annotations .Nullable ;
11
+ import org .springframework .beans .factory .annotation .Value ;
10
12
import org .springframework .web .bind .annotation .GetMapping ;
11
13
import org .springframework .web .bind .annotation .PathVariable ;
12
14
import org .springframework .web .bind .annotation .RestController ;
@@ -24,6 +26,9 @@ public class TodoController {
24
26
private final RestClient restClient ;
25
27
private final Tracer tracer ;
26
28
29
+ @ Value ("sentry.sample.todo-url" )
30
+ public @ Nullable String todoUrl ;
31
+
27
32
public TodoController (
28
33
RestTemplate restTemplate , WebClient webClient , RestClient restClient , Tracer tracer ) {
29
34
this .restTemplate = restTemplate ;
@@ -38,8 +43,7 @@ Todo todo(@PathVariable Long id) {
38
43
try (final @ NotNull Scope spanScope = otelSpan .makeCurrent ()) {
39
44
ISpan sentrySpan = Sentry .getSpan ().startChild ("todoSpanSentryApi" );
40
45
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 );
43
47
} finally {
44
48
sentrySpan .finish ();
45
49
}
@@ -58,7 +62,7 @@ Todo todoWebClient(@PathVariable Long id) {
58
62
x ->
59
63
webClient
60
64
.get ()
61
- .uri ("https://jsonplaceholder.typicode.com /todos/{id}" , id )
65
+ .uri (todoUrl + " /todos/{id}" , id )
62
66
.retrieve ()
63
67
.bodyToMono (Todo .class )
64
68
.map (response -> response )))
@@ -73,7 +77,7 @@ Todo todoRestClient(@PathVariable Long id) {
73
77
try {
74
78
return restClient
75
79
.get ()
76
- .uri ("https://jsonplaceholder.typicode.com /todos/{id}" , id )
80
+ .uri (todoUrl + " /todos/{id}" , id )
77
81
.retrieve ()
78
82
.body (Todo .class );
79
83
} finally {
0 commit comments