mirror of
https://github.com/kjuulh/dagger-rs.git
synced 2024-11-25 16:32:42 +01:00
feat: add tracing logger
This commit is contained in:
parent
91097868dc
commit
f670989a46
14
Cargo.lock
generated
14
Cargo.lock
generated
@ -1172,6 +1172,7 @@ dependencies = [
|
||||
"opentelemetry-semantic-conventions",
|
||||
"thiserror",
|
||||
"thrift",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1217,6 +1218,8 @@ dependencies = [
|
||||
"percent-encoding",
|
||||
"rand",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
"tokio-stream",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1813,6 +1816,17 @@ dependencies = [
|
||||
"webpki",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-stream"
|
||||
version = "0.1.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"pin-project-lite",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-util"
|
||||
version = "0.7.8"
|
||||
|
@ -29,7 +29,8 @@ tracing-subscriber = { version = "0.3.17", features = [
|
||||
tracing-opentelemetry = { version = "0.18.0" }
|
||||
opentelemetry = { version = "0.18.0", default-features = false, features = [
|
||||
"trace",
|
||||
"rt-tokio",
|
||||
] }
|
||||
opentelemetry-jaeger = "0.17.0"
|
||||
opentelemetry-jaeger = { version = "0.17.0", features = ["rt-tokio"] }
|
||||
|
||||
thiserror = "1.0.40"
|
||||
|
@ -7,14 +7,20 @@ use dagger_core::engine::Engine as DaggerEngine;
|
||||
|
||||
use crate::errors::ConnectError;
|
||||
use crate::gen::Query;
|
||||
use crate::logging::StdLogger;
|
||||
use crate::logging::{StdLogger, TracingLogger};
|
||||
use crate::querybuilder::query;
|
||||
|
||||
pub type DaggerConn = Arc<Query>;
|
||||
|
||||
pub async fn connect() -> Result<DaggerConn, ConnectError> {
|
||||
let cfg = if cfg!(feature = "otel") {
|
||||
let cfg = Config::new(None, None, None, None, Some(Arc::new(StdLogger::default())));
|
||||
let cfg = Config::new(
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
Some(Arc::new(TracingLogger::default())),
|
||||
);
|
||||
|
||||
#[cfg(feature = "otel")]
|
||||
crate::logging::otel_logging().map_err(ConnectError::FailedToInstallOtelTracer)?;
|
||||
|
@ -61,13 +61,13 @@ impl Default for TracingLogger {
|
||||
|
||||
impl Logger for TracingLogger {
|
||||
fn stdout(&self, output: &str) -> eyre::Result<()> {
|
||||
tracing::info!(output = output, "dagger-sdk");
|
||||
tracing::info!(output = output, "dagger_sdk");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn stderr(&self, output: &str) -> eyre::Result<()> {
|
||||
tracing::warn!(output = output, "dagger-sdk");
|
||||
tracing::warn!(output = output, "dagger_sdk");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user