Functions CLI로 디버깅
Functions CLI로 디버깅 (Debug with Functions CLI)
Pulsar Functions CLI로 함수의 정보, 상태, 통계를 확인하고 함수를 트리거하며 디버깅할 수 있어요. 이 문서에서는 get, list, status, stats, trigger 하위 명령을 하나씩 살펴볼게요.
출처: 문서
본문
Pulsar Functions CLI로 다음 하위 명령으로 Pulsar Functions를 디버깅할 수 있어요:
get
함수에 대한 정보를 가져오려면 다음과 같이 --fqfn을 지정할 수 있어요.
./bin/pulsar-admin functions get public/default/ExclamationFunctio6
또는 다음과 같이 --name, --namespace, --tenant를 지정할 수 있어요.
./bin/pulsar-admin functions get \
--tenant public \
--namespace default \
--name ExclamationFunctio6
아래에서 볼 수 있듯이 get 명령은 ExclamationFunctio6 함수의 입력, 출력, 런타임 및 기타 정보를 보여줘요.
{
"tenant": "public",
"namespace": "default",
"name": "ExclamationFunctio6",
"className": "org.example.test.ExclamationFunction",
"inputSpecs": {
"persistent://public/default/my-topic-1": {
"isRegexPattern": false
}
},
"output": "persistent://public/default/test-1",
"processingGuarantees": "ATLEAST_ONCE",
"retainOrdering": false,
"userConfig": {},
"runtime": "JAVA",
"autoAck": true,
"parallelism": 1
}
list
특정 테넌트와 네임스페이스 아래에서 실행 중인 모든 Pulsar Functions를 나열하려면:
bin/pulsar-admin functions list \
--tenant public \
--namespace default
아래에서 볼 수 있듯이 list 명령은 public 테넌트와 default 네임스페이스 아래에서 실행 중인 세 개의 함수를 반환해요.
ExclamationFunctio1
ExclamationFunctio2
ExclamationFunctio3
status
함수의 현재 상태를 확인하려면:
./bin/pulsar-admin functions status \
--tenant public \
--namespace default \
--name ExclamationFunctio6
아래에서 볼 수 있듯이 status 명령은 인스턴스 수, 실행 중인 인스턴스, ExclamationFunctio6 함수 아래 실행 중인 인스턴스, 수신 메시지, 성공적으로 처리된 메시지, 시스템 예외, 평균 지연 시간 등을 보여줘요.
{
"numInstances" : 1,
"numRunning" : 1,
"instances" : [ {
"instanceId" : 0,
"status" : {
"running" : true,
"error" : "",
"numRestarts" : 0,
"numReceived" : 1,
"numSuccessfullyProcessed" : 1,
"numUserExceptions" : 0,
"latestUserExceptions" : [ ],
"numSystemExceptions" : 0,
"latestSystemExceptions" : [ ],
"averageLatency" : 0.8385,
"lastInvocationTime" : 1557734137987,
"workerId" : "c-standalone-fw-23ccc88ef29b-8080"
}
} ]
}
stats
함수의 현재 통계를 가져오려면:
bin/pulsar-admin functions stats \
--tenant public \
--namespace default \
--name ExclamationFunctio6
출력은 다음과 같아요:
{
"receivedTotal" : 1,
"processedSuccessfullyTotal" : 1,
"systemExceptionsTotal" : 0,
"userExceptionsTotal" : 0,
"avgProcessLatency" : 0.8385,
"1min" : {
"receivedTotal" : 0,
"processedSuccessfullyTotal" : 0,
"systemExceptionsTotal" : 0,
"userExceptionsTotal" : 0,
"avgProcessLatency" : null
},
"lastInvocation" : 1557734137987,
"instances" : [ {
"instanceId" : 0,
"metrics" : {
"receivedTotal" : 1,
"processedSuccessfullyTotal" : 1,
"systemExceptionsTotal" : 0,
"userExceptionsTotal" : 0,
"avgProcessLatency" : 0.8385,
"1min" : {
"receivedTotal" : 0,
"processedSuccessfullyTotal" : 0,
"systemExceptionsTotal" : 0,
"userExceptionsTotal" : 0,
"avgProcessLatency" : null
},
"lastInvocation" : 1557734137987,
"userMetrics" : { }
}
} ]
}
trigger
지정된 함수를 제공된 값으로 트리거하려면:
./bin/pulsar-admin functions trigger \
--tenant public \
--namespace default \
--name ExclamationFunctio6 \
--topic persistent://public/default/my-topic-1 \
--trigger-value "hello pulsar functions"
이 명령은 함수의 실행 과정을 시뮬레이션하고 검증해요. 아래에서 볼 수 있듯이 trigger 명령은 다음 결과를 반환해요:
This is my function!
참고
--topic옵션을 사용할 때는 전체 토픽 이름을 지정해야 해요. 그렇지 않으면 다음 오류가 발생해요.
Function in trigger function has unidentified topic
Reason: Function in trigger function has unidentified topic
더 알아보기 (Learn more)
- Pulsar Functions 디버깅 개요 — 다른 디버깅 방법을 확인해요.
- pulsar-admin CLI 참조 — functions 명령을 자세히 다뤄요.
- Functions 배포 — 함수를 실제로 배포해요.