tracing_cloudwatch/
client.rs

1#[cfg(any(feature = "rusoto", feature = "rusoto_rustls"))]
2mod rusoto;
3
4#[cfg(feature = "awssdk")]
5mod awssdk;
6
7use async_trait::async_trait;
8
9use crate::{dispatch::LogEvent, export::LogDestination};
10
11/// Trait that abstracts API call using the SDK.
12#[async_trait]
13pub trait CloudWatchClient {
14    async fn put_logs(&self, dest: LogDestination, logs: Vec<LogEvent>)
15        -> Result<(), PutLogsError>;
16}
17
18#[derive(Debug, thiserror::Error)]
19pub enum PutLogsError {
20    #[error("{message}")]
21    LogDestinationNotFound { message: String },
22    #[error(transparent)]
23    Other(#[from] anyhow::Error),
24}
25
26pub struct NoopClient {}
27
28#[async_trait]
29impl CloudWatchClient for NoopClient {
30    async fn put_logs(&self, _: LogDestination, _: Vec<LogEvent>) -> Result<(), PutLogsError> {
31        Ok(())
32    }
33}
34
35impl NoopClient {
36    pub fn new() -> Self {
37        Self {}
38    }
39}