-
Notifications
You must be signed in to change notification settings - Fork 0
[Feat] Grafana 모니터링 스택 설정 추가 #4
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 8 commits
42d4ae6
c65e85f
e4c14d8
a9b81c4
0126650
75fce15
dc4b157
34e9783
da3c1a7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| package com.daedan.festabook.global.logging; | ||
|
|
||
| import org.aspectj.lang.annotation.Pointcut; | ||
|
|
||
| public final class LoggingPointcuts { | ||
|
|
||
| private LoggingPointcuts() { | ||
| } | ||
|
|
||
| @Pointcut(""" | ||
| execution(* com.daedan.festabook..*.*(..)) && | ||
| ( | ||
| within(@org.springframework.web.bind.annotation.RestController *) || | ||
| within(@org.springframework.stereotype.Service *) || | ||
| within(@com.daedan.festabook.global.logging.Loggable *) || | ||
| execution(* org.springframework.data.jpa.repository.JpaRepository+.*(..)) | ||
| ) | ||
| """) | ||
| public void applicationLayers() { | ||
soeun2537 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| package com.daedan.festabook.global.logging; | ||
|
|
||
| import io.opentelemetry.api.trace.Span; | ||
| import io.opentelemetry.api.trace.Tracer; | ||
| import io.opentelemetry.context.Scope; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.aspectj.lang.ProceedingJoinPoint; | ||
| import org.aspectj.lang.annotation.Around; | ||
| import org.aspectj.lang.annotation.Aspect; | ||
| import org.springframework.beans.factory.annotation.Value; | ||
| import org.springframework.context.annotation.Profile; | ||
| import org.springframework.core.Ordered; | ||
| import org.springframework.core.annotation.Order; | ||
| import org.springframework.stereotype.Component; | ||
|
|
||
| @Aspect | ||
| @Component | ||
| @Profile("prod | dev") | ||
| @RequiredArgsConstructor | ||
| @Order(Ordered.HIGHEST_PRECEDENCE) | ||
| public class TracingAspect { | ||
|
|
||
| private final Tracer tracer; | ||
|
|
||
| @Value("${env}") | ||
| private String env; | ||
|
||
|
|
||
| @Around("com.daedan.festabook.global.logging.LoggingPointcuts.applicationLayers()") | ||
| public Object trace(ProceedingJoinPoint joinPoint) throws Throwable { | ||
|
Contributor
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. 그 log에서 사용하는 traceId랑 trace에서 사용하는 traceId가 기존에 동일했는데 분리했을 때도 같은지 확인해봐야 할 것 같아요!
Member
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. 구두로 설명 드렸습니다! 같네요. |
||
| String className = joinPoint.getSignature().getDeclaringType().getSimpleName(); | ||
| String methodName = joinPoint.getSignature().getName(); | ||
|
|
||
| String spanName = className + "::" + methodName; | ||
| Span span = tracer.spanBuilder(spanName).startSpan(); | ||
| span.setAttribute("env", env); | ||
|
|
||
| try (Scope scope = span.makeCurrent()) { | ||
| return joinPoint.proceed(); | ||
| } finally { | ||
| span.end(); | ||
| } | ||
| } | ||
| } | ||
taek2222 marked this conversation as resolved.
Show resolved
Hide resolved
taek2222 marked this conversation as resolved.
Show resolved
Hide resolved
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| server: | ||
| tomcat: | ||
| mbeanregistry: | ||
| enabled: true | ||
|
|
||
| management: | ||
| server: | ||
| port: 9000 | ||
| endpoints: | ||
| web: | ||
| exposure: | ||
| include: prometheus, health | ||
| metrics: | ||
| tags: | ||
| application: ${spring.application.name} | ||
| prometheus: | ||
| metrics: | ||
| export: | ||
| enabled: true | ||
| tracing: | ||
| sampling: | ||
| probability: 1.0 | ||
| otlp: | ||
| tracing: | ||
| endpoint: "http://localhost:4317" | ||
| transport: grpc |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ | |
|
|
||
| <!-- DEV, PROD: JSON 형식으로 로그 파일 기록 --> | ||
| <springProfile name="prod | dev"> | ||
| <property name="LOG_FILE_PATH" value="/home/ubuntu/2025-festabook/spring-logs"/> | ||
| <property name="LOG_FILE_PATH" value="/var/log"/> | ||
|
Contributor
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. 잘 기억이 나지 않아서, 이거 변경한 이유만 간단하게 남겨주세요! 인지하고 있을게요
Member
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. 후유 의견으로, 기존 경로는 환경 의존성이 강해서, 서버 자체 환경에서도 표준적으로 수집이가능한 /var/log로 통일했었던 기억이 있습니다. |
||
|
|
||
| <appender name="JSON_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> | ||
| <file>${LOG_FILE_PATH}/application.json</file> | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.