1. Sentry๋?
Sentry๋ ์ ํ๋ฆฌ์ผ์ด์ ์์ ๋ฐ์ํ๋ ์๋ฌ ๋ฐ ์์ธ๋ฅผ ์ค์๊ฐ์ผ๋ก ์์งํ๊ณ ์๊ฐํํ์ฌ ๋น ๋ฅด๊ฒ ๋ฌธ์ ๋ฅผ ํ์ ํ๊ณ ๋์ํ ์ ์๊ฒ ๋๋ ์คํ์์ค ๊ธฐ๋ฐ์ ์ค๋ฅ ์ถ์ ์์คํ ์ด๋ค.
์ฃผ๋ก ์น, ๋ชจ๋ฐ์ผ, ๋ฐ์คํฌํ ๋ฑ ๋ค์ํ ํ๋ซํผ์์ ๋ฐ์ํ๋ ๋ฐํ์ ์ค๋ฅ๋ ์ฑ๋ฅ ์ ํ ์ด์๋ฅผ ์ถ์ ํ๋ ๋ฐ ํ์ฉ๋๋ค.
“Application Monitoring and Error Tracking that helps developers see what actually matters, solve quicker, and learn continuously in production.”
2. Sentry๋ก ํ ์ ์๋ ๊ฒ๋ค
- โ ์๋ฌ ์ถ์
- ์๋ฌ ๋ฐ์ ์ ์คํ ํธ๋ ์ด์ค๋ฅผ ํฌํจํ ์์ธ ๋ก๊ทธ๋ฅผ ์์งํด ์ด๋์ ๋ฌธ์ ๊ฐ ๋ฐ์ํ๋์ง ์๊ฐ์ ์ผ๋ก ํ์ ํ ์ ์์
- โ ์ด์ ์๋ ๋ถ๋ฅ ๋ฐ ๊ทธ๋ฃนํ
- ๋์ผํ ์ข ๋ฅ์ ์๋ฌ๋ฅผ ํ๋์ ์ด์๋ก ๋ฌถ์ด ๊ด๋ฆฌํ ์ ์์ด ์ด์ ์ ๋ฆฌ๊ฐ ์์ํจ
- โ ์๋ฆผ ์ค์
- ์ฌ๋, ์ด๋ฉ์ผ, ์นํ ๋ฑ ๋ค์ํ ๋ฐฉ์์ผ๋ก ์๋ฆผ์ ๋ฐ์ ์ ์์ → ๋์ค์ ๋์ค์ฝ๋ ์๋ ์ฐ๋
- โ ๋ฆด๋ฆฌ์ฆ ํธ๋ํน
- ์ด๋ค ๋ฐฐํฌ ๋ฒ์ ์์ ์ด๋ค ์ค๋ฅ๊ฐ ๋ฐ์ํ๋์ง ์ถ์ ๊ฐ๋ฅ
- โ ์ฑ๋ฅ ๋ชจ๋ํฐ๋ง
- API ์๋ต ์๊ฐ, ํธ๋์ญ์ ๋ณ๋ชฉ ํ์ ๋ฑ์ ์ถ์ ํ์ฌ ์ฑ๋ฅ ๊ฐ์ ์ ๊ธฐ์ฌ ๊ฐ๋ฅ
3. Sentry SaaS vs On-Premise
ํญ๋ชฉ | SaaS (sentry.io) | On-Premise |
ํธ์คํ | Sentry ํด๋ผ์ฐ๋์์ ์ด์ | ์ฌ๋ด ์ธํ๋ผ์์ ์ง์ ์ด์ |
์ค์น/์ ์ง๋ณด์ | ์์ (์๋ ์ ๊ณต) | ์ง์ ์ค์น ๋ฐ ๊ด๋ฆฌ ํ์ |
๋ณด์/๋ฐ์ดํฐ ํต์ | ์ธ๋ถ ์ ์ฅ | ๋ด๋ถ๋ง ์ ์ง ๊ฐ๋ฅ (๋ณด์ ๊ฐํ) |
ํ์ฅ์ฑ | Sentry๊ฐ ๊ด๋ฆฌ | ์์ฒด์ ์ผ๋ก ๊ตฌ์ฑ ํ์ |
์๊ธ | ์ฌ์ฉ๋ ๊ธฐ๋ฐ ์ ๋ฃ | ๋ฌด๋ฃ (์คํ์์ค) or ์์ฒด ์ธํ๋ผ ๋น์ฉ |
๋ณด์์ด ์ค์ํ ๊ธฐ์ ํ๊ฒฝ์์๋ On-Premise๊ฐ ์ ํธ๋จ
4. ์ ์ฐ๋ฆฌ๋ Sentry๋ฅผ ๋์ ํ๋?
์ฐ๋ฆฌ ํ์ ์ฌ์ฉ์ ํ๊ฒฝ์์ ๋ฐ์ํ๋ ํ๋ก ํธ์๋ ์ค๋ฅ๋ฅผ ์ฌ์ ์ ์ธ์งํ๊ณ ์ ์ํ ๋์ํ๊ธฐ ์ํ ๋ฐฉ์์ผ๋ก Sentry๋ฅผ ๋์ ํ๋ค.
ํนํ, ์ฌ๋ด ์๋น์ค๊ฐ ์ฌ๋ผ๊ฐ ํ๊ฒฝ์ด ์ธ๋ถ ํด๋ผ์ฐ๋ ์๋น์ค ์ฌ์ฉ์ด ์ ํ๋ ํ์๋ง ํ๊ฒฝ์ด์๊ธฐ ๋๋ฌธ์, Sentry SaaS๊ฐ ์๋ On-Premise ๋ฒ์ ์ ์ ํํ์ฌ ์ฌ๋ด ์ธํ๋ผ์ ์ง์ ๊ตฌ์ถํ๋ค.
๋ํ, ์ ๋ด QA ํ๋ก์ธ์ค๋ฅผ ๋ณ๋๋ก ์ด์ํ์ง ์๊ณ ์๋ ์ํฉ์์, ์๋น์ค ๊ด๋ จ ์ค๋ฅ๋ฅผ ์ฌ๋์ด ์๋์ผ๋ก ์ฐพ๋ ๋ฐฉ์์๋ ํ๊ณ๊ฐ ์์๊ณ , ์๋ฌ๋ฅผ ์๋์ผ๋ก ์์งํ๊ณ ๋ถ๋ฅํด์ฃผ๋ ์์คํ ์ด ํ์ํ๋ค๊ณ ํ๋จํ๋ค.
๐งฉ ๋์ ์ ๋ฌธ์ ์
- ์ฝ์ ๋ก๊ทธ๊ฐ ์์ง๋์ง ์์ ์ฌ์ฉ์ ์ด์ ํ์ ์ ํ๊ณ
- ๋ณ๋์ QA๊ฐ ๋ฐ๋ก ์์ง ์์ ์ด์๊ฐ ๋ค๋ฆ๊ฒ ๋ฐ๊ฒฌ
- ์ฌํ ๋ถ๊ฐ๋ฅํ ๋ฒ๊ทธ ๋ฐ์ ์ ์ ํํ ์์ธ ํ์ ์ด ์ด๋ ค์
โ ๋์ ํ ๊ธฐ๋ ํจ๊ณผ
- ํ๋ก ํธ์๋ ์ค๋ฅ์ ์ค์๊ฐ ๊ฐ์ง ๋ฐ Discord ์๋ฆผ ์๋ํ
- ์คํ ํธ๋ ์ด์ค๋ฅผ ํตํ ๋น ๋ฅด๊ณ ์ ํํ ์ค๋ฅ ์์น ๋ถ์
- ์ด๋ค ์ฝ๋ ๋ฆด๋ฆฌ์ฆ ๋ฒ์ ์์ ๋ฌธ์ ๊ฐ ๋ฐ์ํ๋์ง ๋ฒ์ ๋ณ ์ถ์ ๊ฐ๋ฅ
Sentry ๋์ ์ ํตํด, ์๋น์ค ์ด์ ์์ ์ฑ์ ํ๋ณดํ๊ณ ์ฌ์ฉ์ ๊ฒฝํ์ ๊ฐ์ ํ ์ ์๋ ๊ธฐ๋ฐ์ ๋ง๋ จํ ์ ์์๋ค.
5. ์ค์น ๋ฐ ์ฐ๋ ๋ฐฉ๋ฒ
๐ถ
on-premise ํ๊ฒฝ์ sentry self-hosted ๋ฐฉ๋ฒ์ docker compose๋ฅผ ํ์ฉํ๋ค.
๋ฐ๋ผ์ ์ฌ์ ์ docker ํ๊ฒฝ์ด ์ธํ ๋์ด์ผ ํ๋ค.
๋์ ๊ฒฝ์ฐ ์ด๋ฏธ docker๊ฐ ์ค์น๋์ด ์์ด docker ํ๊ฒฝ ์ธํ ์ ๋ํด์๋ ๋ฐ๋ก ๋ค๋ฃจ์ง ์๋๋ค.
โ on-premise sentry self-host ์๋ฒ ์ค์น
1. sentry self-host ์ ํด๋ก ๋ฐ์์จ๋ค.
VERSION=$(curl -Ls -o /dev/null -w %{url_effective} https://github.com/getsentry/self-hosted/releases/latest)
VERSION=${VERSION##*/}
sentry self- hosted docs์์๋ version์ ์ต์ ์ผ๋ก ๋ก๊ฒจ์ค๋ script๊ฐ ๋ค์๊ณผ ๊ฐ์์ผ๋ ์ค๋ฅ๊ฐ ๋ฐ์ํ์ฌ ํน์ ๋ฒ์ ์ ์ง์ ํ์๋ค.
(์๋ ๋ช ๋ น์ด ์ฐธ๊ณ )
VERSION="25.5.1"
git clone https://github.com/getsentry/self-hosted.git
cd self-hosted
git checkout ${VERSION}
2. ํด๋ก ๋ฐ์์จ ๋ธ๋์น ๋ด๋ถ์ install๊ด๋ จ script๋ฅผ ์คํํ๋ค
sudo ./install.sh
์ค๊ฐ์ ๋์ค๋ ํ๋กฌํํธ
1. ์๋ฌ ๋ด์ฉ sentry์ ๊ณต์ ์ฌ๋ถ (y/n ๋ง์๋๋ก)
2. admin ๊ณ์ ๋ง๋ค์ง ์ฌ๋ถ - ์ด์ฐจํผ ๋ก๊ทธ์ธ ํ ๊ณ์ ์ด ํ์ํด์ yes ํ, ์ฌ์ฉํ ์ด๋ฉ์ผ ๊ณ์ ๊ณผ ํจ์ค์๋ ์ ๋ ฅ
3. ์๋ฃ ํ docker compose๋ฅผ ์คํํ๋ค.
docker compose up -d
4. localhost:9000 ๋๋ ์๋ฒ์ฃผ์:9000 ๋ก ์ ์ํ๋ค.
- sentry๋ 9000 port๊ฐ default
โ ํ๋ก ํธ ์ฐ๋ํ๊ธฐ
- sentry์ ๊ด๋ฆฌ์ ๊ณ์ ์ผ๋ก ๋ก๊ทธ์ธ ํ ํ๋ก์ ํธ๋ฅผ ์ถ๊ฐํ๋ค.
1-1. ํ๋ก ํธ ํ๋ก์ ํธ๋ next.js ๋ก next.js๋ฅผ ์ ํ ํ๋ค.
1-2. ๊ทธ ์ธ ํ๋ก์ ํธ ์ด๋ฆ๊ณผ ์๋ ์ฃผ๊ธฐ๋ฅผ ์ ํํ๋ค.
2. sentry ํ๋ก์ ํธ์ ํ๋ก ํธ๋ฅผ ์ฐ๋ํ๋ค.
2-1. ํ๋ก ํธ ํ๋ก์ ํธ์ ๋ค์ ์์กด์ฑ์ ์ถ๊ฐํ๋ค.
yarn add @sentry/nextjs
2-2. sentry wizard๋ฅผ ๋ค์ ๋ช ๋ น์ด๋ก ์คํํ๋ค.
npx @sentry/wizard@latest -i nextjs --org sentry --project [ํ๋ก์ ํธ ๋ช
]
Sentry Wizard Prompt ์ ๋ฆฌ
์ง๋ฌธ ์๋ต | ์ ํ ๋ด์ฉ | ๋น๊ณ |
๐ฆ You have uncommitted or untracked files in your repo: (๊ณ์ํ ๊น์?) | โ Yes | package.json ๋ฑ ์์ ์์ ์ด๋ฏ๋ก ํ์ธ |
โ๏ธ Are you using Sentry SaaS or self-hosted Sentry? | โ Self-hosted/on-premise/single-tenant | ์จํ๋ ๋ฏธ์ค ํ๊ฒฝ ์ ํ |
๐ Please enter the URL of your self-hosted Sentry instance. | โ http://์๋ฒ์ฃผ์:9000/ | ์ฌ๋ด ์๋ฒ URL ์ ๋ ฅ |
๐ The @sentry/nextjs package is already installed. Do you want to update it to the latest version? | โ Yes | SDK ์ต์ ๋ฒ์ ์ผ๋ก ์ ๋ฐ์ดํธ |
๐ซ Do you want to route Sentry requests through your Next.js server to avoid ad blockers? | โ No | ๋ธ๋ผ์ฐ์ ์์ ์ง์ ์ ์ก ์ ์ง |
๐ Do you want to enable Tracing to track the performance of your application? | โ Yes | ํผํฌ๋จผ์ค ํธ๋ ์ด์ฑ ํ์ฑํ |
๐ฅ Do you want to enable Session Replay...? | โ Yes | ์ฌ์ฉ์ ํ๋ ๋ฆฌํ๋ ์ด ๊ธฐ๋ฅ ํ์ฑํ |
๐ Do you want to create an example page ("/sentry-example-page")...? | โ Yes | ํ ์คํธ์ฉ ์ํ ํ์ด์ง ์์ฑ |
๐ ๏ธ Are you using a CI/CD tool to build and deploy your application? | โ Yes | CI ํ๊ฒฝ ์ฌ์ฉ ์ฌ๋ถ |
๐ Add the Sentry authentication token as an environment variable... | โ ๏ธ ๋์ค์ ์ถ๊ฐ (I'll do it later...) | .env.sentry-build-plugin ํ์ผ์ ํ ํฐ ์ ์ฅ๋จ |
๐จ Looks like you have Prettier... Do you want to run it on your files? | โ Yes | Prettier๋ก ์ฝ๋ ์๋ ์ ๋ ฌ |
๐ ์๋์ผ๋ก ์์ฑ๋ ํ์ผ๋ค
ํ์ผ | ์ค๋ช |
sentry.server.config.ts | ์๋ฒ ์ฌ์ด๋์ฉ Sentry ์ค์ |
sentry.edge.config.ts | ์ฃ์ง ๋ฐํ์์ฉ Sentry ์ค์ |
instrumentation.ts / instrumentation-client.ts | ์ฑ๋ฅ ์ถ์ ๋ฐ ๋ฆฌํ๋ ์ด ๊ด๋ จ ์ฝ๋ |
pages/_error.jsx | ์๋ฌ ๋ฐ์ด๋๋ฆฌ ํ์ด์ง ์ปค์คํฐ๋ง์ด์ง |
pages/sentry-example-page.js | ํ ์คํธ์ฉ ์ํ ํ์ด์ง |
pages/api/sentry-example-api.js | API ํ ์คํธ์ฉ ์ํ |
.env.sentry-build-plugin | ๋ก์ปฌ ํ ์คํธ์ฉ ์ธ์ฆ ํ ํฐ ํฌํจ |
.gitignore | .env.sentry-build-plugin ์๋ ์ถ๊ฐ๋จ |
๐ฅ trouble shooting
๐ฅ sentry ๊ด๋ฆฌ์ ๊ณ์ ์ผ๋ก ๋ก๊ทธ์ธ ์ CSRF ์ค๋ฅ๊ฐ ๋๋ ํ์
์์ธ
- system.url-prefix ์ค์ ๋๋ฝ ๋๋ ์ค๋ฅ
- Sentry๋ CSRF ํ ํฐ์ ๊ฒ์ฆํ ๋ ์์ฒญ ๋๋ฉ์ธ๊ณผ ์ค์ ๋ system.url-prefix๋ฅผ ๋น๊ตํฉ๋๋ค. ๋ง์ฝ ์ด ๊ฐ์ด ์๋ชป๋์ด ์์ผ๋ฉด CSRF ์ค๋ฅ๊ฐ ๋ฐ์ํ ์ ์์ต๋๋ค.
ํด๊ฒฐ ๋ฐฉ๋ฒ
- self-hosted/sentry/config.yml ํ์ผ์ ์ด๊ณ , ์๋์ ๊ฐ์ด system.url-prefix๋ฅผ ์ ํํ ๋๋ฉ์ธ์ผ๋ก ์ค์
# self-hosted/sentry/config.yml
# The URL prefix in which Sentry is accessible
system.url-prefix: [sentry ์๋ฒ์ฃผ์]
2. docker compose ์ข ๋ฃ ํ ์ฌ์คํ
docker compose down
docker compose up -d
๐ฅ wizard๊ฐ ์คํ๋์ง ์๋ ํ์
wizard๊ฐ ์คํ๋๋ค ๋ฉ์ถ๊ณ error logํ์ผ์ด ์์ฑ๋์๋ค.
// wizard-error-log ํ์ผ ์ผ๋ถ
warning "@sentry/nextjs > @sentry/opentelemetry@9.29.0" has unmet peer dependency "@opentelemetry/context-async-hooks@^1.30.1 || ^2.0.0".
warning "@sentry/nextjs > @sentry/opentelemetry@9.29.0" has unmet peer dependency "@opentelemetry/core@^1.30.1 || ^2.0.0".
warning "@sentry/nextjs > @sentry/opentelemetry@9.29.0" has unmet peer dependency "@opentelemetry/instrumentation@^0.57.1 || ^0.200.0".
warning "@sentry/nextjs > @sentry/opentelemetry@9.29.0" has unmet peer dependency "@opentelemetry/sdk-trace-base@^1.30.1 || ^2.0.0".
warning "@sentry/nextjs > @sentry/webpack-plugin@3.5.0" has unmet peer dependency "webpack@>=4.40.0".
error An unexpected error occurred: "EPERM: operation not permitted, copyfile 'C:\\Users\\luminous\\AppData\\Local\\Yarn\\Cache\\v6\\npm-@types-estree-1.0.6-628effeeae2064a1b4e79f78e81d87b7e5fc7b50-integrity\\node_modules\\@types\\estree\\flow.d.ts' -> 'D:\\project\\node_modules\\rollup\\node_modules\\@types\\estree\\flow.d.ts'".
์์ธ
ํ๋ก์ ํธ ์ถ๊ฐ ์ ์๋ด๋๋ ๋ฌธ๊ตฌ์์๋ wizard๋ฅผ ์คํํ๋ ๋ช ๋ น์ด๋ฅผ ์ฌ์ฉํ๋๋ก ์๋ด๋์ด ์์๋ค.
ํ์ง๋ง ์ค๋ฅ๊ฐ ๋ฐ์ํ๊ณ , ๊ณต์ ๋ฌธ์๋ฅผ ํ์ธํด๋ณด๋ sentry ๊ด๋ จ ์์กด์ฑ์ ์๋ด ์์ด๋ ๋ฐ๋ก ์ค์นํด์ผ ํ๋ค.
ํด๊ฒฐ ๋ฐฉ๋ฒ
yarn add @sentry/nextjs
ํด๋น ์์กด์ฑ์ ์ค์น ํ wizard ์คํ ์ ์ ์ ์คํ๋๋ค.
Reference
https://infiduk.github.io/2024/10/30/sentry.html
https://infiduk.github.io/2024/10/30/sentry.html
https://develop.sentry.dev/self-hosted/#getting-started
https://sig03.medium.com/sentry-self-hosted-์ค์น-๋ฐฉ๋ฒ-d6f3b57b71cf
https://devkingstar.tistory.com/183
https://pungwa.tistory.com/173
https://engineering.linecorp.com/ko/blog/log-collection-system-sentry-on-premise
https://techblog.woowahan.com/21604/
https://tech.codedream.co.kr/25
๋๊ธ