Java - Pinpoint-Agent 로컬 구축

JunMyung Lee·2024년 4월 30일
0

자바

목록 보기
6/7

로컬에 핀포인트를 따로 구축하지 않고, agent만을 설치하여 IntelliJ의 프로젝트와 핀포인트 서버를 연결하도록 한다

핀포인트 서버는 도커환경으로 돌아다니는 코드도 많고, 또한 권장 리소스가 16G이므로 따로 명시하지 않는다

Pinpoint agent 설치하기

wget https://github.com/pinpoint-apm/pinpoint/releases/download/v2.2.0/pinpoint-agent-2.2.0.tar.gz

Pinpoint 설정 변경하기

핀포인트에는 전체 설정인 pinpoint-root.config와 profile에 해당하는 pinpoint.config 두가지 파일이 존재한다. 두 파일에서 중복되는 부분은 프로파일의 컨피그가 우선이 되는것 같다.

Pinpoint 커스텀 프로파일 생성 주석

# Pinpoint agent configuration
#
# Profiles
#  - -Dpinpoint.profiler.profiles.active=release or local
#  - Modify `pinpoint.profiler.profiles.active=release` in $PINPOINT_AGENT_DIR/pinpoint-root.config
# Custom Profile
#  - 1. Create a custom profile in $PINPOINT_HOME/profiles/MyProfile
#    - Add pinpoint.config & log4j2.xml
#  - 2. -Dpinpoint.profiler.profiles.active=MyProfile
# Support external property
#  - -Dpinpoint.config=$MY_CONFIG_PATH/pinpoint.config

주석과 같이 커스텀 프로파일을 직접 생성하지 않으면 기본적으로 제공하는 설정은 local과 release다.
여기서 핀포인트 서버는 외부에 존재하므로 기본 값이 release로 설정되는것 같다.
직접 로컬호스트에 핀포인트 서버를 구축할 수가 없으므로 추측만 가능하다.

vi pinpoint-root.config / profiles/release/pinpoint.config


###########################################################
# gRPC Configuration                                      #
###########################################################
profiler.transport.grpc.collector.ip=[핀포인트 서버 IP]

###########################################################
# Thrift Configuration                                    #
###########################################################
profiler.collector.ip=[핀포인트 서버 IP]

# 1 out of n transactions will be sampled where n is the rate. (1: 100%, 20: 5%)
profiler.sampling.rate=1
  • 컬렉터의 설정을 localhost → 핀포인트 서버 주소값으로 변경한다.
  • profiler.sampling.rate 20 → 1 로 변경한다.

profiler.sampling.rate 값은 화면에 노출할 예시 결과를 지정한다. 기본값인 20은 5%의 확률로 값이 노출되며, 20번의 요청을 해야 1건의 요청값이 화면에 새겨진다는 뜻이다. 해당 값을 1로 지정하여 모든 값을 화면에 노출하도록 한다.

IntelliJ edit configuration VM Option

-javaagent:/Users/liam/data/workspace/pinpoint-agent-2.2.0/pinpoint-bootstrap-2.2.0.jar
-Dpinpoint.agentId=api-localhost
-Dpinpoint.applicationName=local-app-name
-Dserver.port=8080
-XX:+DisableExplicitGC
-XX:+UseG1GC
  • javaagent: 다운로드 받은 핀포인트의 부트 jar를 연결한다
  • agentId: application의 ID값
  • applicationName: 실행하려는 앱 이름. 해당 이름이 서버 UI에서 선택 가능한 이름으로 표기된다.
  • DisableExplicitGC, UseG1GC: GC관련 옵션으로 해당 옵션이 아닌 기본값으로 하면 지속적인 관련 예외가 발생한다.

설정 후 실행시 콘솔 로그

0개의 댓글