Skip to content

Conversation

@lowhung
Copy link
Owner

@lowhung lowhung commented Dec 24, 2025

Summary

Adds optional tracing integration for structured logging and debugging of SDK operations.

Changes

  • Add tracing feature flag to buswatch-sdk
  • Add structured logs at appropriate levels:
    • TRACE: record_read/record_write operations (with module, topic, count fields)
    • DEBUG: Module registration, snapshot collection
    • INFO: Background emission start/stop
    • WARN: Emission failures
  • Zero overhead when feature is disabled (conditional compilation)

Usage

[dependencies]
buswatch-sdk = { version = "0.1", features = ["tracing"] }
use tracing_subscriber;

fn main() {
    tracing_subscriber::fmt::init();
    
    let instrumentor = buswatch_sdk::Instrumentor::new();
    let handle = instrumentor.register("my-service"); // DEBUG log
    handle.record_read("events", 10); // TRACE log
}

Control verbosity:

RUST_LOG=buswatch_sdk=debug cargo run

Testing

  • All 42 SDK tests pass with tracing feature enabled
  • All tests pass without feature (conditional compilation verified)

Closes #22

- Add optional 'tracing' feature flag
- Add TRACE level logs for record_read/record_write operations
- Add DEBUG level logs for module registration and snapshot collection
- Add INFO/WARN level logs for background emission lifecycle
- Zero overhead when feature is disabled (conditional compilation)

Closes #22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(sdk): Add tracing integration for structured logging

2 participants