You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
메트릭 등록 - Timer
Timer는 시간을 측정하는 메트릭 측정 도구이다.
카운터와 유사한데, Timer를 통해 실행 시간을 함께 측정할 수 있다.
Timer.builder(name)를 통해서 타이머를 생성함. Name에는 메트릭 이름을 지정함
tag를 사용했는데, 프로메테우스에서 필터할 수 있는 레이블로 사용됨
주문과 취소는 메트릭 이름은 같고 tag를 통해서 구분하도록 했음
register(registry): 만든 타이머를 MeterRegistry에 등록함. 이렇게 등록해야 실제 동작함
타이머를 사용할 때는 timer.record()를 사용하면 됨. 그 안에 시간을 측정할 내용을 함수로 포함하면 됨
프로메테우스로 다음 접두사가 붙으면서 3가지 메트릭을 제공함
평균 실행 시간도 계산은 다음과 같음
seconds_sum / seconds_count = 평균 실행시간
메트릭 등록 - Timed
@timed라는 애노테이션을 통해 AOP를 적용할 수 있음
@timed(”my.order”)
타입이나 메소드중에 적용할 수 있음. 타입에 적용하면 해당 타입의 모든 public 메소드에 타이머가 적용됨
메트릭 등록 - 게이지
게이지는 임의로 오르내릴 수 있는 단일 숫자 값을 나타내는 메트릭
값의 현재 상태를 보는데 사용
값이 증가하거나 감소할 수 있음
ie. CPU 사용량, 메모리 사용량 등
카운터와 게이지를 구분할 때는 값이 감소할 수 있는가를 고민해보면 도움이 된다.
my.stock 이라는 이름으로 게이지를 등록했다.
게이지를 만들 때 함수를 전달했는데, 이 함수는 외부에서 메트릭을 확인할 때 마다 호출된다. 이 함수의 반환 값이 게이지의 값이다.
Beta Was this translation helpful? Give feedback.
All reactions