Join us Sept 17 at .local NYC! Use code WEB50 to save 50% on tickets. Learn more >
MongoDB Event
Docs Menu
Docs Home
/ / /
Rust 드라이버
/ /

명령 모니터링

이 가이드에서는 Rust 드라이버를 사용하여 드라이버가 MongoDB deployment로 보내는 명령의 결과를 모니터링하는 방법을 보여줍니다.

애플리케이션의 명령 이벤트에 대한 정보를 사용하거나 명령을 모니터링하여 드라이버가 명령을 실행하는 방법에 대해 자세히 알아볼 수 있습니다.

이 가이드에는 다음 섹션이 포함되어 있습니다.

  • 이벤트 설명 은 운전자 가 생성할 수 있는 명령 이벤트를 설명합니다.

  • 이벤트 구독 예제 는 명령 이벤트 를 구독 하는 방법을 보여주는 샘플 코드를 제공합니다.

  • 예시 이벤트 문서에서는 각 명령 이벤트의 샘플을 제공합니다.

  • 추가 정보에서 이 가이드에 언급된 유형 및 메소드에 대한 리소스 및 API 문서 링크를 찾을 수 있습니다.

다음 명령 모니터링 이벤트 중 하나 이상을 구독할 수 있습니다.

이벤트 이름
설명

명령이 시작될 때 생성됩니다.

명령이 성공하면 생성됩니다.

명령이 성공하지 못했을 때 생성됩니다.

애플리케이션에서 하나 이상의 명령 이벤트를 구독하여 액세스할 수 있습니다. 다음 예제에서는 MongoDB deployment에 연결하고 CommandStartedEvent 이벤트 유형을 구독합니다.

struct CommandStartHandler;
impl CommandEventHandler for CommandStartHandler {
fn handle_command_started_event(&self, event: CommandStartedEvent) {
eprintln!("Command started: {:?}", event);
}
}
let handler: Arc<dyn CommandEventHandler> = Arc::new(CommandStartHandler);
client_options.command_event_handler = Some(handler);
let client = Client::with_options(client_options)?;
// ... perform actions with the client to generate events

다음 섹션에서는 각 유형의 명령 모니터링 이벤트에 대한 샘플 출력을 보여줍니다.

CommandStartedEvent {
request_id: 12,
db: "testdb",
command_name: "find",
connection: ...,
command: ...,
service_id: ...
}
CommandSucceededEvent {
duration: ...,
reply: ...,
command_name: "find",
request_id: 12,
connection: ...,
service_id: ...,
}
CommandFailedEvent {
duration: ...,
command_name: "find",
failure: ...,
request_id: 12,
connection: ...,
service_id: ...,
}

MongoDB 배포 모니터링에 대해 자세히 알아보려면 MongoDB를 모니터링하는 방법 문서를 참조하세요.

MongoDB 작업 수행에 학습 보려면 CRUD 작업 가이드를 참조하세요.

이 가이드에서 사용되는 메서드 또는 유형에 대해 자세히 알아보려면 다음 API 문서를 참조하세요.

돌아가기

클러스터 모니터링

이 페이지의 내용