pub struct TracingIntegrationBuilder { /* private fields */ }Expand description
Builder for creating tracing-integrated logging setup
ImplementationsΒ§
SourceΒ§impl TracingIntegrationBuilder
impl TracingIntegrationBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Examples found in repository?
examples/tracing_and_kv_demo.rs (line 32)
15fn main() -> Result<(), Box<dyn std::error::Error>> {
16 println!("π Tracing Integration and Structured Fields Demo");
17 println!("================================================\n");
18
19 // 0) Initialize standard Rust logging (log::*) via the singleton manager.
20 // This keeps the example safe (no stack-pointer logger installation).
21 let mut manager = ObservabilityManager::new(ObservabilityConfig {
22 level: "debug".to_string(),
23 format: "compact".to_string(),
24 structured: true,
25 context_enrichment: true,
26 default_context: Default::default(),
27 })?;
28 manager.initialize()?;
29
30 // 1. Set up tracing integration
31 println!("π§ Setting up tracing integration...");
32 let tracing_subscriber = TracingIntegrationBuilder::new()
33 .with_processor_chain(observability_core::domain::build_enhanced_processor_chain())
34 .with_transport(Arc::new(WasmStdoutAdapter::with_compact_formatter()))
35 .with_level_filter(observability_core::traits::LogLevel::Debug)
36 .build()?;
37
38 // Set as global tracing subscriber
39 tracing::subscriber::set_global_default(tracing_subscriber)
40 .map_err(|e| format!("Failed to set tracing subscriber: {}", e))?;
41
42 println!("β
Tracing integration active\n");
43
44 // 2. Demo tracing events
45 println!("π Testing tracing events:");
46 println!("-------------------------");
47
48 let span = span!(Level::INFO, "demo_operation", operation_id = "op-123");
49 let _enter = span.enter();
50
51 info!(target: "demo", user_id = "user-456", session = "sess-789", "Operation started");
52 debug!(items = 42, size = 1024, "Processing data");
53
54 // Nested span
55 {
56 let nested_span = span!(Level::DEBUG, "data_processing", batch_id = "batch-001");
57 let _nested_enter = nested_span.enter();
58
59 info!(records = 100, duration_ms = 250, "Processing batch");
60 debug!(errors = 0, warnings = 2, "Validation complete");
61 }
62
63 info!(
64 status = "success",
65 total_time_ms = 500,
66 "Operation completed"
67 );
68
69 if false {
70 error!(
71 error_code = 500,
72 details = "Connection timeout",
73 "This would be an error"
74 );
75 }
76
77 println!("β
Tracing events logged with structured fields and span context\n");
78
79 // 3. Demo structured fields with standard log macros
80 println!("π Testing structured fields with standard log macros:");
81 println!("-----------------------------------------------------");
82
83 // Standard log messages.
84 // (KV-style structured fields are supported by the core pipeline, but we keep this example
85 // syntax conservative to compile across toolchains.)
86 log::info!("User login successful");
87 log::debug!("Database query executed");
88 log::warn!("High memory usage detected");
89
90 println!("β
Standard log macros processed through LogKvExtractor\n");
91
92 // 4. Demo mixed usage
93 println!("π Testing mixed tracing and log usage:");
94 println!("---------------------------------------");
95
96 let mixed_span = span!(Level::INFO, "mixed_operation", request_id = "req-999");
97 let _mixed_enter = mixed_span.enter();
98
99 // Tracing event
100 info!(
101 endpoint = "/api/users",
102 method = "GET",
103 "Processing request"
104 );
105
106 // Standard log messages
107 log::info!("Authentication successful");
108
109 // Tracing debug
110 debug!(cache_key = "user:123", hit = true, "Cache lookup");
111
112 // Standard log debug
113 log::debug!("Response prepared");
114
115 info!(
116 status = "success",
117 response_time_ms = 89,
118 "Request completed"
119 );
120
121 println!("β
Mixed tracing and log usage working together\n");
122
123 println!("π Demo completed successfully!");
124 println!("\nπ‘ Key Features Demonstrated:");
125 println!(" β¨ Tracing events β structured logs with span context");
126 println!(" π log::info!(\"msg\"; \"key\" => value) β automatic kv extraction");
127 println!(" π Unified processing through hexagonal architecture");
128 println!(" π Enhanced processor chain with metadata enrichment");
129 println!(" π― Both tracing and log work together seamlessly");
130
131 Ok(())
132}Sourcepub fn with_processor_chain(self, chain: ProcessorChain) -> Self
pub fn with_processor_chain(self, chain: ProcessorChain) -> Self
Examples found in repository?
examples/tracing_and_kv_demo.rs (line 33)
15fn main() -> Result<(), Box<dyn std::error::Error>> {
16 println!("π Tracing Integration and Structured Fields Demo");
17 println!("================================================\n");
18
19 // 0) Initialize standard Rust logging (log::*) via the singleton manager.
20 // This keeps the example safe (no stack-pointer logger installation).
21 let mut manager = ObservabilityManager::new(ObservabilityConfig {
22 level: "debug".to_string(),
23 format: "compact".to_string(),
24 structured: true,
25 context_enrichment: true,
26 default_context: Default::default(),
27 })?;
28 manager.initialize()?;
29
30 // 1. Set up tracing integration
31 println!("π§ Setting up tracing integration...");
32 let tracing_subscriber = TracingIntegrationBuilder::new()
33 .with_processor_chain(observability_core::domain::build_enhanced_processor_chain())
34 .with_transport(Arc::new(WasmStdoutAdapter::with_compact_formatter()))
35 .with_level_filter(observability_core::traits::LogLevel::Debug)
36 .build()?;
37
38 // Set as global tracing subscriber
39 tracing::subscriber::set_global_default(tracing_subscriber)
40 .map_err(|e| format!("Failed to set tracing subscriber: {}", e))?;
41
42 println!("β
Tracing integration active\n");
43
44 // 2. Demo tracing events
45 println!("π Testing tracing events:");
46 println!("-------------------------");
47
48 let span = span!(Level::INFO, "demo_operation", operation_id = "op-123");
49 let _enter = span.enter();
50
51 info!(target: "demo", user_id = "user-456", session = "sess-789", "Operation started");
52 debug!(items = 42, size = 1024, "Processing data");
53
54 // Nested span
55 {
56 let nested_span = span!(Level::DEBUG, "data_processing", batch_id = "batch-001");
57 let _nested_enter = nested_span.enter();
58
59 info!(records = 100, duration_ms = 250, "Processing batch");
60 debug!(errors = 0, warnings = 2, "Validation complete");
61 }
62
63 info!(
64 status = "success",
65 total_time_ms = 500,
66 "Operation completed"
67 );
68
69 if false {
70 error!(
71 error_code = 500,
72 details = "Connection timeout",
73 "This would be an error"
74 );
75 }
76
77 println!("β
Tracing events logged with structured fields and span context\n");
78
79 // 3. Demo structured fields with standard log macros
80 println!("π Testing structured fields with standard log macros:");
81 println!("-----------------------------------------------------");
82
83 // Standard log messages.
84 // (KV-style structured fields are supported by the core pipeline, but we keep this example
85 // syntax conservative to compile across toolchains.)
86 log::info!("User login successful");
87 log::debug!("Database query executed");
88 log::warn!("High memory usage detected");
89
90 println!("β
Standard log macros processed through LogKvExtractor\n");
91
92 // 4. Demo mixed usage
93 println!("π Testing mixed tracing and log usage:");
94 println!("---------------------------------------");
95
96 let mixed_span = span!(Level::INFO, "mixed_operation", request_id = "req-999");
97 let _mixed_enter = mixed_span.enter();
98
99 // Tracing event
100 info!(
101 endpoint = "/api/users",
102 method = "GET",
103 "Processing request"
104 );
105
106 // Standard log messages
107 log::info!("Authentication successful");
108
109 // Tracing debug
110 debug!(cache_key = "user:123", hit = true, "Cache lookup");
111
112 // Standard log debug
113 log::debug!("Response prepared");
114
115 info!(
116 status = "success",
117 response_time_ms = 89,
118 "Request completed"
119 );
120
121 println!("β
Mixed tracing and log usage working together\n");
122
123 println!("π Demo completed successfully!");
124 println!("\nπ‘ Key Features Demonstrated:");
125 println!(" β¨ Tracing events β structured logs with span context");
126 println!(" π log::info!(\"msg\"; \"key\" => value) β automatic kv extraction");
127 println!(" π Unified processing through hexagonal architecture");
128 println!(" π Enhanced processor chain with metadata enrichment");
129 println!(" π― Both tracing and log work together seamlessly");
130
131 Ok(())
132}Sourcepub fn with_transport(self, transport: Arc<dyn TransportPort>) -> Self
pub fn with_transport(self, transport: Arc<dyn TransportPort>) -> Self
Examples found in repository?
examples/tracing_and_kv_demo.rs (line 34)
15fn main() -> Result<(), Box<dyn std::error::Error>> {
16 println!("π Tracing Integration and Structured Fields Demo");
17 println!("================================================\n");
18
19 // 0) Initialize standard Rust logging (log::*) via the singleton manager.
20 // This keeps the example safe (no stack-pointer logger installation).
21 let mut manager = ObservabilityManager::new(ObservabilityConfig {
22 level: "debug".to_string(),
23 format: "compact".to_string(),
24 structured: true,
25 context_enrichment: true,
26 default_context: Default::default(),
27 })?;
28 manager.initialize()?;
29
30 // 1. Set up tracing integration
31 println!("π§ Setting up tracing integration...");
32 let tracing_subscriber = TracingIntegrationBuilder::new()
33 .with_processor_chain(observability_core::domain::build_enhanced_processor_chain())
34 .with_transport(Arc::new(WasmStdoutAdapter::with_compact_formatter()))
35 .with_level_filter(observability_core::traits::LogLevel::Debug)
36 .build()?;
37
38 // Set as global tracing subscriber
39 tracing::subscriber::set_global_default(tracing_subscriber)
40 .map_err(|e| format!("Failed to set tracing subscriber: {}", e))?;
41
42 println!("β
Tracing integration active\n");
43
44 // 2. Demo tracing events
45 println!("π Testing tracing events:");
46 println!("-------------------------");
47
48 let span = span!(Level::INFO, "demo_operation", operation_id = "op-123");
49 let _enter = span.enter();
50
51 info!(target: "demo", user_id = "user-456", session = "sess-789", "Operation started");
52 debug!(items = 42, size = 1024, "Processing data");
53
54 // Nested span
55 {
56 let nested_span = span!(Level::DEBUG, "data_processing", batch_id = "batch-001");
57 let _nested_enter = nested_span.enter();
58
59 info!(records = 100, duration_ms = 250, "Processing batch");
60 debug!(errors = 0, warnings = 2, "Validation complete");
61 }
62
63 info!(
64 status = "success",
65 total_time_ms = 500,
66 "Operation completed"
67 );
68
69 if false {
70 error!(
71 error_code = 500,
72 details = "Connection timeout",
73 "This would be an error"
74 );
75 }
76
77 println!("β
Tracing events logged with structured fields and span context\n");
78
79 // 3. Demo structured fields with standard log macros
80 println!("π Testing structured fields with standard log macros:");
81 println!("-----------------------------------------------------");
82
83 // Standard log messages.
84 // (KV-style structured fields are supported by the core pipeline, but we keep this example
85 // syntax conservative to compile across toolchains.)
86 log::info!("User login successful");
87 log::debug!("Database query executed");
88 log::warn!("High memory usage detected");
89
90 println!("β
Standard log macros processed through LogKvExtractor\n");
91
92 // 4. Demo mixed usage
93 println!("π Testing mixed tracing and log usage:");
94 println!("---------------------------------------");
95
96 let mixed_span = span!(Level::INFO, "mixed_operation", request_id = "req-999");
97 let _mixed_enter = mixed_span.enter();
98
99 // Tracing event
100 info!(
101 endpoint = "/api/users",
102 method = "GET",
103 "Processing request"
104 );
105
106 // Standard log messages
107 log::info!("Authentication successful");
108
109 // Tracing debug
110 debug!(cache_key = "user:123", hit = true, "Cache lookup");
111
112 // Standard log debug
113 log::debug!("Response prepared");
114
115 info!(
116 status = "success",
117 response_time_ms = 89,
118 "Request completed"
119 );
120
121 println!("β
Mixed tracing and log usage working together\n");
122
123 println!("π Demo completed successfully!");
124 println!("\nπ‘ Key Features Demonstrated:");
125 println!(" β¨ Tracing events β structured logs with span context");
126 println!(" π log::info!(\"msg\"; \"key\" => value) β automatic kv extraction");
127 println!(" π Unified processing through hexagonal architecture");
128 println!(" π Enhanced processor chain with metadata enrichment");
129 println!(" π― Both tracing and log work together seamlessly");
130
131 Ok(())
132}Sourcepub fn with_level_filter(self, level: LogLevel) -> Self
pub fn with_level_filter(self, level: LogLevel) -> Self
Examples found in repository?
examples/tracing_and_kv_demo.rs (line 35)
15fn main() -> Result<(), Box<dyn std::error::Error>> {
16 println!("π Tracing Integration and Structured Fields Demo");
17 println!("================================================\n");
18
19 // 0) Initialize standard Rust logging (log::*) via the singleton manager.
20 // This keeps the example safe (no stack-pointer logger installation).
21 let mut manager = ObservabilityManager::new(ObservabilityConfig {
22 level: "debug".to_string(),
23 format: "compact".to_string(),
24 structured: true,
25 context_enrichment: true,
26 default_context: Default::default(),
27 })?;
28 manager.initialize()?;
29
30 // 1. Set up tracing integration
31 println!("π§ Setting up tracing integration...");
32 let tracing_subscriber = TracingIntegrationBuilder::new()
33 .with_processor_chain(observability_core::domain::build_enhanced_processor_chain())
34 .with_transport(Arc::new(WasmStdoutAdapter::with_compact_formatter()))
35 .with_level_filter(observability_core::traits::LogLevel::Debug)
36 .build()?;
37
38 // Set as global tracing subscriber
39 tracing::subscriber::set_global_default(tracing_subscriber)
40 .map_err(|e| format!("Failed to set tracing subscriber: {}", e))?;
41
42 println!("β
Tracing integration active\n");
43
44 // 2. Demo tracing events
45 println!("π Testing tracing events:");
46 println!("-------------------------");
47
48 let span = span!(Level::INFO, "demo_operation", operation_id = "op-123");
49 let _enter = span.enter();
50
51 info!(target: "demo", user_id = "user-456", session = "sess-789", "Operation started");
52 debug!(items = 42, size = 1024, "Processing data");
53
54 // Nested span
55 {
56 let nested_span = span!(Level::DEBUG, "data_processing", batch_id = "batch-001");
57 let _nested_enter = nested_span.enter();
58
59 info!(records = 100, duration_ms = 250, "Processing batch");
60 debug!(errors = 0, warnings = 2, "Validation complete");
61 }
62
63 info!(
64 status = "success",
65 total_time_ms = 500,
66 "Operation completed"
67 );
68
69 if false {
70 error!(
71 error_code = 500,
72 details = "Connection timeout",
73 "This would be an error"
74 );
75 }
76
77 println!("β
Tracing events logged with structured fields and span context\n");
78
79 // 3. Demo structured fields with standard log macros
80 println!("π Testing structured fields with standard log macros:");
81 println!("-----------------------------------------------------");
82
83 // Standard log messages.
84 // (KV-style structured fields are supported by the core pipeline, but we keep this example
85 // syntax conservative to compile across toolchains.)
86 log::info!("User login successful");
87 log::debug!("Database query executed");
88 log::warn!("High memory usage detected");
89
90 println!("β
Standard log macros processed through LogKvExtractor\n");
91
92 // 4. Demo mixed usage
93 println!("π Testing mixed tracing and log usage:");
94 println!("---------------------------------------");
95
96 let mixed_span = span!(Level::INFO, "mixed_operation", request_id = "req-999");
97 let _mixed_enter = mixed_span.enter();
98
99 // Tracing event
100 info!(
101 endpoint = "/api/users",
102 method = "GET",
103 "Processing request"
104 );
105
106 // Standard log messages
107 log::info!("Authentication successful");
108
109 // Tracing debug
110 debug!(cache_key = "user:123", hit = true, "Cache lookup");
111
112 // Standard log debug
113 log::debug!("Response prepared");
114
115 info!(
116 status = "success",
117 response_time_ms = 89,
118 "Request completed"
119 );
120
121 println!("β
Mixed tracing and log usage working together\n");
122
123 println!("π Demo completed successfully!");
124 println!("\nπ‘ Key Features Demonstrated:");
125 println!(" β¨ Tracing events β structured logs with span context");
126 println!(" π log::info!(\"msg\"; \"key\" => value) β automatic kv extraction");
127 println!(" π Unified processing through hexagonal architecture");
128 println!(" π Enhanced processor chain with metadata enrichment");
129 println!(" π― Both tracing and log work together seamlessly");
130
131 Ok(())
132}Sourcepub fn build(self) -> ObservabilityResult<TracingSubscriberAdapter>
pub fn build(self) -> ObservabilityResult<TracingSubscriberAdapter>
Examples found in repository?
examples/tracing_and_kv_demo.rs (line 36)
15fn main() -> Result<(), Box<dyn std::error::Error>> {
16 println!("π Tracing Integration and Structured Fields Demo");
17 println!("================================================\n");
18
19 // 0) Initialize standard Rust logging (log::*) via the singleton manager.
20 // This keeps the example safe (no stack-pointer logger installation).
21 let mut manager = ObservabilityManager::new(ObservabilityConfig {
22 level: "debug".to_string(),
23 format: "compact".to_string(),
24 structured: true,
25 context_enrichment: true,
26 default_context: Default::default(),
27 })?;
28 manager.initialize()?;
29
30 // 1. Set up tracing integration
31 println!("π§ Setting up tracing integration...");
32 let tracing_subscriber = TracingIntegrationBuilder::new()
33 .with_processor_chain(observability_core::domain::build_enhanced_processor_chain())
34 .with_transport(Arc::new(WasmStdoutAdapter::with_compact_formatter()))
35 .with_level_filter(observability_core::traits::LogLevel::Debug)
36 .build()?;
37
38 // Set as global tracing subscriber
39 tracing::subscriber::set_global_default(tracing_subscriber)
40 .map_err(|e| format!("Failed to set tracing subscriber: {}", e))?;
41
42 println!("β
Tracing integration active\n");
43
44 // 2. Demo tracing events
45 println!("π Testing tracing events:");
46 println!("-------------------------");
47
48 let span = span!(Level::INFO, "demo_operation", operation_id = "op-123");
49 let _enter = span.enter();
50
51 info!(target: "demo", user_id = "user-456", session = "sess-789", "Operation started");
52 debug!(items = 42, size = 1024, "Processing data");
53
54 // Nested span
55 {
56 let nested_span = span!(Level::DEBUG, "data_processing", batch_id = "batch-001");
57 let _nested_enter = nested_span.enter();
58
59 info!(records = 100, duration_ms = 250, "Processing batch");
60 debug!(errors = 0, warnings = 2, "Validation complete");
61 }
62
63 info!(
64 status = "success",
65 total_time_ms = 500,
66 "Operation completed"
67 );
68
69 if false {
70 error!(
71 error_code = 500,
72 details = "Connection timeout",
73 "This would be an error"
74 );
75 }
76
77 println!("β
Tracing events logged with structured fields and span context\n");
78
79 // 3. Demo structured fields with standard log macros
80 println!("π Testing structured fields with standard log macros:");
81 println!("-----------------------------------------------------");
82
83 // Standard log messages.
84 // (KV-style structured fields are supported by the core pipeline, but we keep this example
85 // syntax conservative to compile across toolchains.)
86 log::info!("User login successful");
87 log::debug!("Database query executed");
88 log::warn!("High memory usage detected");
89
90 println!("β
Standard log macros processed through LogKvExtractor\n");
91
92 // 4. Demo mixed usage
93 println!("π Testing mixed tracing and log usage:");
94 println!("---------------------------------------");
95
96 let mixed_span = span!(Level::INFO, "mixed_operation", request_id = "req-999");
97 let _mixed_enter = mixed_span.enter();
98
99 // Tracing event
100 info!(
101 endpoint = "/api/users",
102 method = "GET",
103 "Processing request"
104 );
105
106 // Standard log messages
107 log::info!("Authentication successful");
108
109 // Tracing debug
110 debug!(cache_key = "user:123", hit = true, "Cache lookup");
111
112 // Standard log debug
113 log::debug!("Response prepared");
114
115 info!(
116 status = "success",
117 response_time_ms = 89,
118 "Request completed"
119 );
120
121 println!("β
Mixed tracing and log usage working together\n");
122
123 println!("π Demo completed successfully!");
124 println!("\nπ‘ Key Features Demonstrated:");
125 println!(" β¨ Tracing events β structured logs with span context");
126 println!(" π log::info!(\"msg\"; \"key\" => value) β automatic kv extraction");
127 println!(" π Unified processing through hexagonal architecture");
128 println!(" π Enhanced processor chain with metadata enrichment");
129 println!(" π― Both tracing and log work together seamlessly");
130
131 Ok(())
132}Trait ImplementationsΒ§
Auto Trait ImplementationsΒ§
impl Freeze for TracingIntegrationBuilder
impl !RefUnwindSafe for TracingIntegrationBuilder
impl Send for TracingIntegrationBuilder
impl Sync for TracingIntegrationBuilder
impl Unpin for TracingIntegrationBuilder
impl UnsafeUnpin for TracingIntegrationBuilder
impl !UnwindSafe for TracingIntegrationBuilder
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