Skip to content

feat: OTel agent 감지 시 -javaagent 자동 적용#194

Merged
unam98 merged 1 commit into
devfrom
feature/otel-agent-deploy
Jul 21, 2026
Merged

feat: OTel agent 감지 시 -javaagent 자동 적용#194
unam98 merged 1 commit into
devfrom
feature/otel-agent-deploy

Conversation

@unam98

@unam98 unam98 commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

작업 배경

  • Grafana Cloud(OpenTelemetry) 기반 모니터링을 dev/staging 서버에 도입하기 위해, 배포 스크립트가 OTel Java agent를 자동으로 붙이도록 수정

변경 사항

영역 내용
scripts/deploy.sh /home/ec2-user/app/grafana-opentelemetry-java.jarotel.env가 존재하면 자동 감지해서 -javaagent 옵션과 env var를 적용, 없으면 기존과 동일하게 부팅

영향 범위

  • CI/CD 워크플로우(dev-cd.yml 등)는 변경 없음 — 배포 스크립트 로직만 조건부 분기 추가
  • OTel agent 파일이 서버에 없는 경우 동작에 영향 없음 (하위 호환)
  • dev/staging(runnect-staging, t3.micro) 서버에 agent jar + otel.env 파일을 이미 수동 배치 완료 (git에는 포함되지 않는 민감/대용량 파일이라 서버에 직접 배치)

Test Plan

  • bash -n scripts/deploy.sh 문법 검증
  • SSH로 EC2 접속해 agent jar(24MB, 유효한 zip) + otel.env(권한 600) 배치 확인
  • 이 PR 머지 후 CD 파이프라인으로 재배포되어 실제로 Grafana Cloud에 메트릭이 수집되는지 확인

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added optional Grafana OpenTelemetry instrumentation during application startup when the required configuration and agent files are available.
    • Applications continue to start normally when instrumentation files are not present.

grafana-opentelemetry-java.jar와 otel.env가 배포 서버에 있으면
자동으로 감지해서 -javaagent 옵션을 붙여 실행. 없으면 기존과 동일하게 부팅.
@unam98 unam98 self-assigned this Jul 21, 2026
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The deployment script now conditionally loads OpenTelemetry configuration and attaches the Java agent when both required files are present, while preserving startup without instrumentation when either file is missing.

Changes

OpenTelemetry startup instrumentation

Layer / File(s) Summary
Conditional agent launch
scripts/deploy.sh
Defines OpenTelemetry paths, sources otel.env when available, configures JAVA_AGENT_OPTS, and includes the optional agent in the nohup java command.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed OTel JAR와 otel.env 감지 시 -javaagent를 자동 적용하는 मुख्य 변경을 잘 요약합니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/otel-agent-deploy

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/deploy.sh`:
- Around line 32-34: Reorder the arguments in the java invocation so the
-Duser.timezone=Asia/Seoul JVM option appears before -jar, with $JAR_PATH
immediately following -jar. Preserve the existing nohup, $JAVA_AGENT_OPTS, and
continuation structure.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ef6408ed-d5cd-4587-924b-faecf52081ca

📥 Commits

Reviewing files that changed from the base of the PR and between 86fe2f8 and 640d40c.

📒 Files selected for processing (1)
  • scripts/deploy.sh

Comment thread scripts/deploy.sh
@unam98
unam98 merged commit 6f56643 into dev Jul 21, 2026
2 checks 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.

2 participants