Я создал образец приложения Spring Boot для тестирования.
Я добавил эти зависимости в pom.xml:
Код: Выделить всё
org.springframework.boot
spring-boot-starter-actuator
org.springframework.boot
spring-boot-starter-aop
io.micrometer
micrometer-registry-datadog
runtime
io.micrometer
micrometer-tracing-bridge-brave
runtime
io.micrometer
micrometer-tracing
Код: Выделить всё
spring:
application:
name: datadog-sample
server:
port: 8090
management:
metrics:
distribution:
percentiles-histogram:
http:
server:
requests: true
endpoint:
health:
cache:
time-to-live: 6s
show-details: always
metrics:
enabled: true
endpoints:
web:
exposure:
include: health,info,metrics
health:
jmx:
metrics:
export:
enabled: true
step: 1m
info:
env:
enabled: true
datadog:
metrics:
export:
apiKey: test
tracing:
sampling:
probability: 1.0
propagation:
type: W3C
logging:
pattern:
console: .%5p [${spring.application.name:},%X{traceId:-},%X{spanId:-}]
- %msg%n
Код: Выделить всё
@RestController
@Slf4j
public class TestController {
@GetMapping(value = "/method1")
public ResponseEntity method1(@RequestParam String input) throws IOException, InterruptedException {
log.info("Inside the method1 with data = {}",input);
HttpRequest request = HttpRequest.newBuilder().uri(URI.create("http://localhost:8090/method2")).build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
return ResponseEntity.ok(response.body());
}
@GetMapping(value = "/method2")
public ResponseEntity method2() {
log.info("Inside the method2");
return ResponseEntity.ok("Called method2 successfully");
}
}
Код: Выделить всё
http://localhost:8090/method1?input=testdataКод: Выделить всё
. INFO [datadog-sample,652553b7e89ee89b58c1c37b35cb6102,58c1c37b35cb6102] - Inside the method1 with data = testdata
. INFO [datadog-sample,652553b7ec4d43c0f0e090c94225d91c,f0e090c94225d91c] - Inside the method2
- Разве это не должен быть одиночный Идентификатор трассировки с несколькими идентификаторами диапазона, чтобы можно было легко отслеживать поток?
- Должен ли Мне нужно где-нибудь использовать аннотацию @Obesrved, чтобы не нужно было настраивать какое-либо поведение?
- Для отправки показателей/ сведения о наблюдаемости в Datadog:
- Нужно ли мне добавлять что-то конкретное в код/конфигурацию, кроме включения конкретных зависимостей Datadog в POM наряду с запуском агента Datadog в фоновом режиме?
- Работает ли микрометрическая наблюдаемость «из коробки» для Spring Cloud-Kafka-Binder или ему нужна какая-то особая настройка? Если да, может ли кто-нибудь предоставить справочный пример?
Подробнее здесь: https://stackoverflow.com/questions/772 ... ces-and-ka
Мобильная версия