opentelemetry_stdout/
lib.rs

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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//! Export telemetry signals to stdout.
//! <div class="warning">This exporter is designed for debugging and learning purposes. It is not
//! recommended for use in production environments. The output format might not be
//! exhaustive and is subject to change at any time.
//! </div>
//!
//! # Feature Flags
//! The following feature flags can enable exporters for different telemetry signals:
//!
//! * `trace`: Includes the trace exporters.
//! * `metrics`: Includes the metrics exporters.
//! * `logs`: Includes the logs exporters.
//!
//! The following feature flags generate additional code and types:
//! * `populate-logs-event-name`: Enables sending `LogRecord::event_name` as an attribute
//!    with the key `name`
//!
//! # Examples
//!
//! ```no_run
//! # #[cfg(all(feature = "metrics", feature = "trace", feature = "logs"))]
//! {
//! use opentelemetry::metrics::MeterProvider;
//! use opentelemetry::trace::{Span, Tracer, TracerProvider as _};
//! use opentelemetry::{Context, KeyValue};
//!
//! use opentelemetry_sdk::metrics::{SdkMeterProvider, PeriodicReader};
//! use opentelemetry_sdk::runtime;
//! use opentelemetry_sdk::trace::TracerProvider;
//!
//! use opentelemetry_sdk::logs::LoggerProvider;
//!
//! fn init_trace() -> TracerProvider {
//!     let exporter = opentelemetry_stdout::SpanExporter::default();
//!     TracerProvider::builder()
//!         .with_simple_exporter(exporter)
//!         .build()
//! }
//!
//! fn init_metrics() -> SdkMeterProvider {
//!     let exporter = opentelemetry_stdout::MetricsExporter::default();
//!     let reader = PeriodicReader::builder(exporter, runtime::Tokio).build();
//!     SdkMeterProvider::builder().with_reader(reader).build()
//! }
//!
//! fn init_logs() -> LoggerProvider {
//!     let exporter = opentelemetry_stdout::LogExporter::default();
//!     LoggerProvider::builder()
//!         .with_simple_exporter(exporter)
//!         .build()
//! }
//!
//! let tracer_provider = init_trace();
//! let meter_provider = init_metrics();
//! let logger_provider = init_logs();
//!
//! // recorded traces, metrics and logs will now be sent to stdout:
//!
//! # }
//! ```
#![warn(missing_debug_implementations, missing_docs)]
#![cfg_attr(
    docsrs,
    feature(doc_cfg, doc_auto_cfg),
    deny(rustdoc::broken_intra_doc_links)
)]

pub(crate) mod common;

#[cfg(feature = "metrics")]
mod metrics;
#[cfg_attr(docsrs, doc(cfg(feature = "metrics")))]
#[cfg(feature = "metrics")]
pub use metrics::*;

#[cfg(feature = "trace")]
mod trace;
#[cfg_attr(docsrs, doc(cfg(feature = "trace")))]
#[cfg(feature = "trace")]
pub use trace::*;

#[cfg(feature = "logs")]
mod logs;
#[cfg_attr(docsrs, doc(cfg(feature = "logs")))]
#[cfg(feature = "logs")]
pub use logs::*;