pub struct GCloudLayerConfig<M: LogMapper = DefaultLogMapper> { /* private fields */ }
Expand description
Configuration for setting up Google Cloud logging with tracing
.
GCloudLayerConfig
holds everything needed to build a tracing_stackdriver
layer
that sends logs to Google Cloud Logging. It supports custom log mappers, batching,
and uses service account credentials for authentication.
Use .build_layer()
to produce a ready-to-use tracing
layer.
Implementations§
Source§impl<M: LogMapper> GCloudLayerConfig<M>
impl<M: LogMapper> GCloudLayerConfig<M>
Sourcepub fn build_layer(
self,
) -> Result<(Layer<Registry, impl Fn() -> GoogleWriterHandle>, GoogleWriterRuntime<M>), LoggerError>
pub fn build_layer( self, ) -> Result<(Layer<Registry, impl Fn() -> GoogleWriterHandle>, GoogleWriterRuntime<M>), LoggerError>
Builds a tracing_stackdriver
layer using this config.
Creates a GoogleLogger
from the provided log name and credentials,
then wraps it in a GoogleWriter
for async batching. Returns a
tracing_stackdriver
layer that can be added to a subscriber.
§Example
use tracing_gcloud_layer::DefaultGCloudLayerConfigBuilder;
use tracing_subscriber::prelude::*;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let svc_account_bytes = std::fs::read("svc-account.json")?;
let (layer, runtime) = DefaultGCloudLayerConfigBuilder::default()
.log_name("my-service")
.logger_credential(svc_account_bytes)
.build()?
.build_layer()?;
tracing_subscriber::registry().with(layer).init();
runtime.shutdown().await;
Ok(())
}
Trait Implementations§
Source§impl<M: Clone + LogMapper> Clone for GCloudLayerConfig<M>
impl<M: Clone + LogMapper> Clone for GCloudLayerConfig<M>
Source§fn clone(&self) -> GCloudLayerConfig<M>
fn clone(&self) -> GCloudLayerConfig<M>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl<M> Freeze for GCloudLayerConfig<M>where
M: Freeze,
impl<M> RefUnwindSafe for GCloudLayerConfig<M>where
M: RefUnwindSafe,
impl<M> Send for GCloudLayerConfig<M>
impl<M> Sync for GCloudLayerConfig<M>
impl<M> Unpin for GCloudLayerConfig<M>where
M: Unpin,
impl<M> UnwindSafe for GCloudLayerConfig<M>where
M: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more