-
Notifications
You must be signed in to change notification settings - Fork 0
Feat#15 prometheus,k6 #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
62ea8a4
b3cf1c1
bb96369
1c3e4fd
bcfe8c6
576a012
7fde0ae
7c0776f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| version: '3.8' | ||
| services: | ||
| promethus: | ||
| image: prom/prometheus:latest | ||
| container_name: prometheus | ||
| volumes: | ||
| - ./prometheus.yml:/etc/prometheus/prometheus.yml | ||
| command: | ||
| - '--config.file=/etc/prometheus/prometheus.yml' | ||
| ports: | ||
| - "9090:9090" | ||
| networks: | ||
| - monitoring-network | ||
| grafana: | ||
| image: grafana/grafana:latest | ||
| container_name: grafana | ||
| ports: | ||
| - "3001:3000" | ||
| networks: | ||
| - monitoring-network | ||
| k6: | ||
| image: grafana/k6 | ||
| volumes: | ||
| - ./scripts:/scripts | ||
| entrypoint: "" | ||
| command: ["k6", "run", "/scripts/myscript.js"] | ||
|
|
||
| networks: | ||
| monitoring-network: | ||
| driver: bridge |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| global: | ||
| scrape_interval: 15s | ||
|
|
||
| scrape_configs: | ||
| - job_name: prometheus | ||
| metrics_path: '/actuator/prometheus' | ||
| static_configs: | ||
| - targets: ['host.docker.internal:8080'] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| import http from 'k6/http'; | ||
| import { check } from 'k6'; | ||
|
|
||
| function getRandomPageId(min, max) { | ||
| return Math.floor(Math.random() * (max - min + 1)) + min; | ||
| } | ||
|
|
||
| export let options = { | ||
| scenarios: { | ||
| constant_request_rate: { | ||
| executor: 'ramping-arrival-rate', | ||
| startRate: 167, // 초당 약 167개의 요청으로 시작 | ||
| timeUnit: '1s', | ||
| preAllocatedVus: 50, // 사전 할당된 VU 수 | ||
| maxVUs: 100, // 최대 VU 수 | ||
| stages: [ | ||
| { duration: '1m', target: 167}, | ||
| ] | ||
| } | ||
| } | ||
| } | ||
|
|
||
| export default function () { | ||
| const pageId = getRandomPageId(0,1); | ||
| const params = { | ||
| headers: { | ||
| 'Content-Type': 'application/json', | ||
| }, | ||
| }; | ||
|
|
||
| let response = http.get('http://host.docker.internal:8080/api/posts/' + pageId, params); | ||
|
|
||
| check(response, { | ||
| 'status is 200': (r) => r.status === 200, | ||
| }) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,9 +33,11 @@ public String getPassword() { | |
|
|
||
| @Override | ||
| public String getUsername() { | ||
| return user.getEmail(); | ||
| return user.getName(); | ||
| } | ||
|
Comment on lines
35
to
37
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainJWT/인증 컨텍스트 간 'username' 의미가 바뀌면서 JWTFilter와 불일치(버그 가능성) 이제 getUsername()이 name을 반환합니다. 그런데 JWTFilter는 여전히 토큰의 username 클레임을 User.email에 주입하고 있어, 인증 컨텍스트의 User.email이 사용자 이름으로 채워집니다. 이메일을 사용하는 로직(예: 권한 조회, 레포지토리 연동 등)에서 혼선/버그가 발생할 수 있습니다. JWTFilter에서 email은 getUserEmail(token)으로, name은 getUsername(token)으로 분리해 매핑하도록 수정이 필요합니다. 아래와 같이 JWTFilter의 사용자 재구성 로직을 정리하는 것을 권장합니다(참고용 코드): // JWTFilter.java 내부 예시
String email = jwtUtil.getUserEmail(token);
String displayName = jwtUtil.getUsername(token);
String role = jwtUtil.getRole(token);
Long userId = jwtUtil.getUserId(token);
User user = User.builder()
.id(userId)
.email(email)
.name(displayName) // 필요 시 name 세팅
.role(role)
.build();토큰 클레임-도메인 매핑이 일관되게 적용되는지 점검해 주세요. 빠르게 확인하려면 다음 스크립트로 JWTFilter의 사용처를 찾아보세요. 🏁 Script executed: #!/bin/bash
# JWTFilter에서 username/email 클레임 사용 위치 점검
rg -n -C3 'JWTFilter' backend/src/main/java
rg -n -C2 'getUsername\s*\(' backend/src/main/java/org/juniortown/backend/user/jwt
rg -n -C2 'getUserEmail\s*\(' backend/src/main/java/org/juniortown/backend/user/jwtLength of output: 5390 🏁 Script executed: #!/bin/bash
set -euo pipefail
files=(
backend/src/main/java/org/juniortown/backend/user/jwt/JWTFilter.java
backend/src/main/java/org/juniortown/backend/user/jwt/JWTUtil.java
backend/src/main/java/org/juniortown/backend/user/jwt/LoginFilter.java
backend/src/main/java/org/juniortown/backend/user/dto/CustomUserDetails.java
)
for f in "${files[@]}"; do
echo "===== $f ====="
sed -n '1,240p' "$f" || true
echo
doneLength of output: 10063 JWTFilter: 토큰 클레임 → 도메인 필드 매핑 불일치 — 수정 필요 검증 결과 JWTFilter가 토큰의 "username" 클레임(jwtUtil.getUsername)을 User.email로 설정하고 있어 인증 컨텍스트에서 username/email의 의미가 섞여 있습니다. LoginFilter는 토큰 생성 시 email과 username을 각각 넣고 있으므로, JWTFilter에서 email은 getUserEmail(token)으로, 표시명(이름)은 getUsername(token)으로 분리 매핑해야 합니다. 수정 대상(요약)
권장 수정 예시 (JWTFilter 내부): String email = jwtUtil.getUserEmail(token);
String displayName = jwtUtil.getUsername(token);
String role = jwtUtil.getRole(token);
Long userId = jwtUtil.getUserId(token);
User user = User.builder()
.id(userId)
.email(email)
.name(displayName)
.role(role)
.build();토큰 클레임 ↔ 도메인 필드 매핑이 전체 코드(LoginFilter/JWTFilter/CustomUserDetails/토큰 생성/검증)에 걸쳐 일관된지 점검해 주세요. 🤖 Prompt for AI Agents
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 스프링 시큐리티 부분 너무 기억이 안나서 대충 코드를 짰네 부끄럽구먼유 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Doncham 전혀 부끄러워할 필요 없습니다! Spring Security는 복잡한 프레임워크라 세부사항을 기억하기 어려운 게 당연해요. 😊 JWT 토큰 클레임 매핑 부분만 정리해주시면 될 것 같습니다. 제가 찾은 JWTFilter 수정이 필요한 부분을 도와드릴까요? 아니면 나중에 시간 될 때 천천히 정리하셔도 괜찮습니다. 중요한 건 기능이 잘 동작한다는 점이니까요! 👍 |
||
|
|
||
| public String getUserEmail() {return user.getEmail();} | ||
|
|
||
| public Long getUserId() { | ||
| return user.getId(); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
중요: /api/posts/\d+ 전부 permitAll은 DELETE/PATCH까지 무방비 — GET으로 한정 필요
현재 정규식 매처는 HTTP 메서드 제약이 없어 삭제·수정 등 민감 요청도 인증 없이 통과할 수 있습니다. GET만 허용하도록 제한하세요.
또는 별도 import를 추가하고 간결히 표기할 수 있습니다:
🤖 Prompt for AI Agents