ES /docs

Api::V1::ElementRecordsController#bulk (avg 224651ms, max 224651ms)

Fix Plan: Api::V1::ElementRecordsController#bulk latency (Cupix::HttpClient timeout 미설정)

Changes#

tesla: lib/cupix/http_client.rb#

  • What: 모듈 상단에 DEFAULT_OPEN_TIMEOUT = 5 (초), DEFAULT_READ_TIMEOUT = 30 (초) 상수 추가. get / post / put / patch / delete 5개 메서드 모두 RestClient.<verb>(...) 호출을 RestClient::Request.execute(method: :<verb>, url: url, payload: payload, headers: headers, open_timeout: DEFAULT_OPEN_TIMEOUT, read_timeout: DEFAULT_READ_TIMEOUT) 형태로 교체. 반환 타입/재시도 backoff 로직/RETRIABLE_STATUS_CODES 판정은 그대로 유지.
  • Why: RCA H1 (Confirmed). RestClient 기본 read timeout이 무제한이라 upstream(Siteinsights API Gateway)이 hang될 때 controller가 무기한 blocking됨. read_timeout=30s 도입 시 upstream hang은 3회 재시도 포함 최악 (30*3)+(1+2+4) = 97s 이내에 RestClient::Exceptions::ReadTimeout으로 실패하여 request-level bound가 생김.
  • Lines: 대략 file 전체 5개 메서드 begin 블록 (약 5~7 라인 * 5).

tesla: spec/lib/cupix/http_client_spec.rb#

  • What: 기존 shared_examples의 RestClient.<verb> mock을 RestClient::Request.execute mock으로 교체하거나, 신규 context "passes explicit timeouts to RestClient::Request.execute"를 추가하여 open_timeout: 5, read_timeout: 30 인자가 전달되는지 검증. 재시도/non-retriable 경로 커버리지는 유지.
  • Why: 구현 변경(RestClient.<verb> → RestClient::Request.execute)이 있으므로 기존 stub이 미매칭되어 스펙이 깨짐. 회귀 방지를 위해 timeout이 실제로 전달되는지 explicit assertion 추가.
  • Lines: shared_examples 두 블록 (with body / without body). 대략 각각 stub 3~4곳 수정 + 신규 assertion 1개.

Acceptance Criteria#

  • git grep -n "RestClient\\.\\(get\\|post\\|put\\|patch\\|delete\\)(" lib/cupix/http_client.rb 결과 0건 (모두 RestClient::Request.execute 로 대체됨).
  • git grep -n "open_timeout\\|read_timeout" lib/cupix/http_client.rb 결과 최소 5건 이상 (각 verb 메서드에 timeout 지정).
  • bundle exec rspec spec/lib/cupix/http_client_spec.rb 통과.
  • bundle exec rubocop lib/cupix/http_client.rb spec/lib/cupix/http_client_spec.rb 오류 0건.
  • bundle exec srb tc lib/cupix/http_client.rb 통과 (기존 sig 반환 타입 RestClient::ResponseRestClient::Request.execute 반환값과 호환됨을 확인 — Sorbet).

Tests#

  • 기존 테스트: spec/lib/cupix/http_client_spec.rb — 5개 verb의 성공/재시도/최대 재시도 소진/비재시도 상태 케이스 유지.
  • 신규 테스트: 각 verb에서 RestClient::Request.executeopen_timeout: 5, read_timeout: 30 로 호출되는지 검증하는 케이스 (shared_examples 내 1개 추가).