1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//! Observability helpers for `tracing`, OpenTelemetry, and tokio-console.
//!
//! This module provides convenience functions for setting up structured
//! logging and distributed tracing in DDS applications.
//!
//! # Features
//!
//! - **`tracing`** -- enables `#[tracing::instrument]` spans on DDS operations.
//! - **`opentelemetry`** -- pulls in `tracing-subscriber` and provides
//! [`init_json_logging`], a JSON + `RUST_LOG` subscriber suitable as the base
//! layer for an OTLP pipeline.
//! - **`tokio-console`** -- exposes tokio tasks to the tokio-console debugger.
//!
//! This crate does **not** re-export `tracing-opentelemetry` or
//! `opentelemetry-otlp` — they are not dependencies of `cyclonedds`. Add them to
//! your own `Cargo.toml` and compose them with the subscriber below. (An earlier
//! version of this doc claimed the re-export; it never existed.)
//!
//! # OpenTelemetry Setup
//!
//! ```no_run
//! use cyclonedds::observability::init_json_logging;
//!
//! #[tokio::main]
//! async fn main() {
//! init_json_logging();
//! // Wire your OTLP exporter here with your own `opentelemetry-otlp` and
//! // `tracing-opentelemetry` dependencies.
//! // ... DDS code
//! }
//! ```
/// Initialize a `tracing-subscriber` with JSON formatting and env-filter.
///
/// Reads `RUST_LOG` for filter configuration.
/// Initialize tokio-console support.
///
/// Run with `TOKIO_CONSOLE_BIND=127.0.0.1:6669` to customize the listener address.
/// Initialize JSON logging + tokio-console when both features are enabled.