|
3 | 3 | import com.fasterxml.jackson.core.JsonProcessingException; |
4 | 4 | import com.fasterxml.jackson.databind.JsonNode; |
5 | 5 | import com.fasterxml.jackson.databind.ObjectMapper; |
| 6 | +import io.micrometer.observation.Observation; |
| 7 | +import io.micrometer.observation.ObservationRegistry; |
6 | 8 | import lombok.RequiredArgsConstructor; |
7 | 9 | import lombok.extern.slf4j.Slf4j; |
8 | 10 | import org.springframework.stereotype.Component; |
@@ -34,6 +36,7 @@ public class RetryableAiCallerService { |
34 | 36 | private final JsonUtils jsonUtils; |
35 | 37 | private static final int MAX_RETRY = 2; |
36 | 38 | private final ContextAwareExecutor contextAwareExecutor; |
| 39 | + private final ObservationRegistry observationRegistry; |
37 | 40 |
|
38 | 41 | // Feign 동기 호출 |
39 | 42 | public String callSync(String prompt) { |
@@ -107,9 +110,13 @@ public String callSyncWithField(String prompt, String taskName, String requiredF |
107 | 110 | try { |
108 | 111 | log.info("{} 호출 시작", taskName); |
109 | 112 |
|
110 | | - String content = openAiFeignClient |
111 | | - .createReport(CreateReportAiRequestDto.from(prompt)) |
112 | | - .getContent(); |
| 113 | + // 부모 Span(job.process) 아래에 AI 호출 구간을 child Span으로 기록 |
| 114 | + String content = Observation.createNotStarted("ai.call", observationRegistry) |
| 115 | + .contextualName(taskName) |
| 116 | + .observe(() -> openAiFeignClient |
| 117 | + .createReport(CreateReportAiRequestDto.from(prompt)) |
| 118 | + .getContent()); |
| 119 | + |
113 | 120 | String cleaned = jsonUtils.clean(content); |
114 | 121 | validateJsonSyncWithField(cleaned, requiredField); |
115 | 122 |
|
|
0 commit comments