[Feature] Integrate Sentry with Opentelemetry agent to send server error alert#112
[Feature] Integrate Sentry with Opentelemetry agent to send server error alert#112
Conversation
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📝 WalkthroughWalkthroughIntegrates Sentry: updates versions and version catalog, adds Sentry JVM Gradle plugin and agent handling in builds, injects the Sentry OpenTelemetry agent into Docker images and JVM startup, adds Sentry dependencies and Spring component for custom fingerprinting, and updates monitoring config. Changes
sequenceDiagram
participant Build as Build System
participant Artifact as Agent Artifact (libs)
participant Docker as Dockerfile / Image
participant App as JVM App
participant Sentry as Sentry (External)
Build->>Artifact: declare sentryAgent dependency & copy task
Build->>Artifact: resolve and copy agent -> build output (agent/)
Docker->>Build: use agent from build output / agent-downloader stage
Docker->>Docker: place /opt/sentry/agent.jar in image
App->>App: JVM starts with -javaagent:/opt/sentry/agent.jar and -Dsentry.auto.init=false
App->>Sentry: agent/instrumentation sends telemetry/events
App->>App: BeforeSendCallback (SentryFingerprintCallback) enriches events before send
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
🚥 Pre-merge checks | ✅ 5 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Fix all issues with AI agents
In `@docker/DockerfileDev`:
- Around line 1-2: The DockerfileDev currently downloads the Sentry agent
unpinned in the agent-downloader stage using wget to
/sentry-opentelemetry-agent.jar; update this to download a specific, versioned
artifact (match the version in libs.versions.toml or core-api/build.gradle.kts)
from a stable URL (e.g., Maven Central coordinates for
sentry-opentelemetry-agent) and add an integrity check (verify SHA256 or other
checksum) before accepting the file so builds are reproducible and supply-chain
safe.
- Around line 13-16: The CMD line places the JVM option -Xmx2048m after -jar so
the launcher will treat it as the JAR path; reorder the JVM flags so all JVM
options (e.g., -javaagent:/opt/sentry/agent.jar and -Dsentry.auto.init=false and
-Xmx2048m) appear before -jar and then the JAR file
(/service/pida/core-api-0.0.1.jar) so the JVM recognizes -Xmx2048m as a memory
flag rather than a JAR filename.
In `@pida-core/core-api/build.gradle.kts`:
- Around line 24-32: The copySentryAgent Gradle task (copySentryAgent) produces
build/agent/sentry-opentelemetry-agent.jar but DockerfileDev and DockerfileProd
still wget the agent, creating two supply chains; pick one approach. Preferred:
switch DockerfileDev/DockerfileProd to COPY the Gradle output
(build/agent/sentry-opentelemetry-agent.jar) into the image and remove the wget
step so the Docker build uses the pinned libs.versions.toml artifact (keep the
copySentryAgent task and its dependency on build). Alternative: remove the
copySentryAgent task and any sentryAgent configuration if you want to keep
downloading via wget (accepting loss of version pinning).
In `@pida-supports/monitoring/src/main/resources/monitoring.yml`:
- Line 14: The configuration in monitoring.yml currently sets send-default-pii:
true which causes Sentry to collect PII (IP addresses, user details, cookies);
change the send-default-pii setting to false (or wire it to an
environment/config flag) to stop transmitting PII by default, and if you must
enable it, gate it behind an explicit opt-in flag and document the decision in
privacy/GDPR notes; update any Sentry initialization code that reads this key to
respect the new flag if present.
🧹 Nitpick comments (2)
pida-supports/monitoring/src/main/resources/monitoring.yml (1)
12-12:traces-sample-rate: 1.0sends 100% of traces to Sentry — consider lowering for production.Sampling all transactions can generate significant volume and cost. A rate of
0.1–0.25is typical for production workloads. If this is intentional for the initial rollout, consider parameterizing it via an environment variable (likedsn) so it can be tuned per environment without a code change.Suggested change
- traces-sample-rate: 1.0 + traces-sample-rate: ${SENTRY_TRACES_SAMPLE_RATE:1.0}pida-core/core-api/build.gradle.kts (1)
5-12: Sentry org and project names are hardcoded — acceptable but worth noting.
org.set("pida-za")andprojectName.set("pida")are hardcoded. This is fine for a single-project setup, but consider extracting these togradle.propertiesif they may change or be shared across modules.
| tasks.register<Copy>("copySentryAgent") { | ||
| from(sentryAgent) | ||
| into(layout.buildDirectory.dir("agent")) | ||
| rename { "sentry-opentelemetry-agent.jar" } | ||
| } | ||
|
|
||
| tasks.named("build") { | ||
| dependsOn("copySentryAgent") | ||
| } |
There was a problem hiding this comment.
copySentryAgent task output is unused — Dockerfiles download the agent from a URL instead.
The Gradle task copies the agent to build/agent/sentry-opentelemetry-agent.jar, but both DockerfileDev and DockerfileProd download the agent via wget from https://get.sentry.io/sentry-opentelemetry-agent.jar. This means the Gradle-resolved artifact is never used at runtime, creating two separate supply chains for the same artifact — with potentially different versions.
Pick one approach:
- Option A (preferred): Use the Gradle-resolved agent in Docker (guarantees the version matches
libs.versions.toml). COPY the build output in the Dockerfile instead ofwget. - Option B: Remove the
copySentryAgenttask andsentryAgentconfiguration, and rely solely on the Docker download (but you lose version pinning).
🤖 Prompt for AI Agents
In `@pida-core/core-api/build.gradle.kts` around lines 24 - 32, The
copySentryAgent Gradle task (copySentryAgent) produces
build/agent/sentry-opentelemetry-agent.jar but DockerfileDev and DockerfileProd
still wget the agent, creating two supply chains; pick one approach. Preferred:
switch DockerfileDev/DockerfileProd to COPY the Gradle output
(build/agent/sentry-opentelemetry-agent.jar) into the image and remove the wget
step so the Docker build uses the pinned libs.versions.toml artifact (keep the
copySentryAgent task and its dependency on build). Alternative: remove the
copySentryAgent task and any sentryAgent configuration if you want to keep
downloading via wget (accepting loss of version pinning).
char-yb
left a comment
There was a problem hiding this comment.
LGTM!
나중에 모니터링 모듈에는 domain 모듈에서 공통 Exception 코드와 같은 클래스들을 common 모듈을 별도 분리해서 수정하면 좋을 듯합니당
안그래도 그 부분 말씀드리고 싶었는데 좋네요 👍👍 |
🌱 관련 이슈
📌 작업 내용 및 특이 사항
📝 참고
📌 체크 리스트
Summary by CodeRabbit
New Features
Chores