Skip to content

[BE-3423] chore: wrangler 4로 올리고 Worker 로그·트레이스를 New Relic으로 내보내기 - #34

Merged
junha6316 merged 3 commits into
developfrom
BE-3423
Nov 13, 2026
Merged

junha6316 merged 3 commits into
developfrom
BE-3423

Conversation

@junha6316

@junha6316 junha6316 commented Nov 13, 2026 •

Copy link
Copy Markdown

무엇을 바꿨나요

  • 운영 Worker(code-push-server-preview)의 로그와 트레이스를 Cloudflare OTLP 내보내기로 New Relic에 보냅니다.
    • 로그: 전부 보내고, Cloudflare 대시보드 저장도 지금처럼 유지합니다.
    • 트레이스: 10%만 보내고, Cloudflare에는 저장하지 않습니다.
  • wrangler를 3.103.1에서 4.150.0으로 올립니다. 3.103.1은 observability.traces·destinations를 "Unexpected fields" 경고만 내고 버립니다(dry-run 확인).
  • wrangler 4에서 없어진 publish 명령을 deploy --env production으로 바꿉니다. Workers Builds 배포 명령이 pnpm run publish라서 이 스크립트를 그대로 씁니다.
  • apps/server/.node-version을 22로 둡니다. wrangler 4는 Node 22 이상이 필요한데, Workers Builds 빌드 변수에 NODE_VERSION이 없습니다.

왜 필요한가요

  • 지금은 CodePush 서버가 New Relic에 보이는 것이 없습니다.
  • 11/13에 모바일 Network 허용 목록에 Worker와 R2 호스트를 넣어서, 앱 쪽 성공·실패는 보이게 했습니다.
  • 다만 서버 안에서 왜 실패했는지(D1 조회, 서명 등)는 이 PR이 있어야 보입니다.

머지 전에 준비한 것

  • Cloudflare YP Labs 계정 Observability > Destinations에 newrelic-logs와 newrelic-traces를 만들었습니다. 이름이 apps/server/wrangler.toml과 같아야 합니다.
  • New Relic에 이 용도 전용 Ingest-License 키 cloudflare-codepush-otel을 만들었습니다. 이 키만 폐기하면 내보내기만 끊깁니다.

검증

  • 검증함
    • pnpm typecheck, pnpm check, CI=1 pnpm test(127개)가 모두 통과했습니다. 테스트 도구(@cloudflare/vitest-pool-workers 0.6)는 자체 wrangler 3을 쓰므로 이 테스트가 wrangler 4를 검증하지는 않습니다.
    • wrangler deploy --dry-run --env production이 경고 없이 통과했습니다. 업로드 크기는 627.7KB로, 이전 631.9KB와 거의 같습니다.
    • production 설정을 읽어 보니 logs·traces 설정이 위 의도대로 들어갔습니다. local 환경은 그대로입니다.
    • wrangler 4로 로컬 실행해 /health, /docs, update check 응답을 확인했습니다.
    • Workers Builds 설정(대시보드)은 브랜치 main, 루트 /apps/server, 빌드 pnpm run build, 배포 pnpm run publish입니다.
  • 검증 못 함
    • Workers Builds가 /apps/server/.node-version을 읽는지, 실제로 빌드되는지. 빌드 기록 API가 빈 목록이라 지난 자동 배포 기록은 확인하지 못했습니다.
    • 배포 뒤 New Relic에 로그·트레이스가 들어오는지

New Relic으로 나가는 로그 내용

  • 요청 로그(src/middleware/logging.ts:18)가 쿼리 문자열을 포함한 전체 URL을 남기고 있었습니다. 쿼리에는 update check의 deployment_key·기기 ID, OAuth 콜백의 code·state가 들어 있습니다.
  • 이 PR에서 경로(c.req.path)만 남기도록 바꿨습니다. Cloudflare 로그에서도 같이 빠집니다.

머지하면

  • main에 머지되면 Workers Builds가 운영에 바로 배포합니다(DEVELOPMENT.md와 위 대시보드 설정 기준).
  • 빌드나 배포가 실패하면 지금 버전이 그대로 남습니다.
  • 배포 뒤 New Relic에서 service.name이 Worker 이름인 Log·Span이 들어오는지 확인하겠습니다.
  • 문제가 생기면 이 PR을 되돌리거나, 대시보드에서 내보낼 곳 두 개를 끄면 됩니다.

🤖 Generated with Claude Code

https://claude.ai/code/session_011R1F79zi2fBnwMwn9JAddQ

junha6316 and others added 2 commits November 13, 2026 09:49
- wrangler 3.103.1은 observability.traces·destinations를 버려서 4.150.0으로 올림
- wrangler 4에서 없어진 publish 명령을 deploy로 바꿈
- production 환경에 logs·traces 내보낼 곳(newrelic-logs·newrelic-traces) 지정, 트레이스는 10% 표본·Cloudflare 저장 안 함

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011R1F79zi2fBnwMwn9JAddQ
- wrangler 4.150.0은 Node 22 이상이 필요한데 빌드 설정에 NODE_VERSION이 없음

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011R1F79zi2fBnwMwn9JAddQ
@junha6316 junha6316 self-assigned this Nov 13, 2026
- 쿼리에 deployment_key·기기 ID·OAuth code/state가 있어 New Relic으로 나가지 않게 함

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011R1F79zi2fBnwMwn9JAddQ
@junha6316
junha6316 marked this pull request as ready for review November 13, 2026 01:09
@junha6316
junha6316 merged commit c6a6d87 into develop Nov 13, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant