260928_01_ENH: kon, kiwi api 요청 및 성공, 실패 로그 추가

This commit is contained in:
2026-09-28 11:03:38 +09:00
parent a3da353878
commit ccfc0f1cc8

View File

@@ -4,11 +4,13 @@ import com.kri.common.feature.http.ExternalApiClient;
import com.kri.common.feature.http.ExternalApiResponse; import com.kri.common.feature.http.ExternalApiResponse;
import com.kri.common.feature.web.BusinessException; import com.kri.common.feature.web.BusinessException;
import com.kri.contact.server.common.enums.SurveyType; import com.kri.contact.server.common.enums.SurveyType;
import java.net.URI;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.HashMap; import java.util.HashMap;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.concurrent.TimeUnit;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
@@ -64,13 +66,30 @@ public class ContactSurveyApiClient {
validate(pkey, psidx); validate(pkey, psidx);
String url = baseUrl(surveyType) + CONTACT_SURVEY_PATH; String url = baseUrl(surveyType) + CONTACT_SURVEY_PATH;
String target = target();
String body = "CRUD=" + crud String body = "CRUD=" + crud
+ "&COMMAND=" + CONTACT_SURVEY_COMMAND + "&COMMAND=" + CONTACT_SURVEY_COMMAND
+ "&PKEY=" + encode(pkey) + "&PKEY=" + encode(pkey)
+ "&PSIDX=" + psidx + "&PSIDX=" + psidx
+ "&TARGET=" + target(); + "&TARGET=" + target;
externalApiClient.post(url, headers(), body); String host = URI.create(url).getHost();
log.info("ContactSurvey API request surveyType={} crud={} target={} host={} path={}",
surveyType, crud, target, host, CONTACT_SURVEY_PATH);
long startedAt = System.nanoTime();
try {
ExternalApiResponse response = externalApiClient.post(url, headers(), body);
log.info("ContactSurvey API response surveyType={} crud={} target={} host={} status={} elapsedMs={}",
surveyType, crud, target, host, response.getStatusCode(),
TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startedAt));
} catch (RuntimeException e) {
Throwable cause = e.getCause();
log.warn("ContactSurvey API failure surveyType={} crud={} target={} host={} errorType={} causeType={} elapsedMs={}",
surveyType, crud, target, host, e.getClass().getSimpleName(),
cause == null ? "none" : cause.getClass().getSimpleName(),
TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startedAt));
throw e;
}
} }
private String baseUrl(SurveyType surveyType) { private String baseUrl(SurveyType surveyType) {