Skip to content

Commit 5fe969d

Browse files
committed
docs: Add clap specific example for TelemetryOptions
1 parent 602f3ca commit 5fe969d

File tree

1 file changed

+26
-2
lines changed
  • crates/stackable-telemetry/src/tracing

1 file changed

+26
-2
lines changed

crates/stackable-telemetry/src/tracing/mod.rs

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
99
use std::path::PathBuf;
1010

11+
#[cfg_attr(feature = "clap", cfg(doc))]
12+
use clap;
1113
use opentelemetry::trace::TracerProvider;
1214
use opentelemetry_appender_tracing::layer::OpenTelemetryTracingBridge;
1315
use opentelemetry_otlp::{LogExporter, SpanExporter};
@@ -117,6 +119,9 @@ pub enum Error {
117119
/// }
118120
/// ```
119121
///
122+
/// Also see the documentation for [`TelemetryOptions`] which details how it can be used as CLI
123+
/// arguments via [`clap`].
124+
///
120125
/// ## Builders
121126
///
122127
/// When choosing the builder, there are two different styles to configure individual subscribers:
@@ -305,8 +310,8 @@ impl Tracing {
305310
/// | ---------------- | ------------------------------------------ | ------------- |
306311
/// | Console logs | [`CONSOLE_LOG`](Self::CONSOLE_LOG_ENV_VAR) | `INFO` |
307312
/// | File logs | [`FILE_LOG`](Self::FILE_LOG_ENV_VAR) | `INFO` |
308-
/// | OTLP logs | [`OTLP_LOG`](Self::OTLP_LOG_ENV_VAR) | `INFO` |
309-
/// | OTLP traces | [`OTLP_TRACE`](Self::OTLP_TRACE_ENV_VAR) | `INFO` |
313+
/// | OTLP logs | [`OTLP_LOG`](Self::OTLP_LOG_ENV_VAR) | `INFO` |
314+
/// | OTLP traces | [`OTLP_TRACE`](Self::OTLP_TRACE_ENV_VAR) | `INFO` |
310315
///
311316
/// ### Default Values
312317
///
@@ -696,6 +701,25 @@ fn env_filter_builder(env_var: &str, default_directive: impl Into<Directive>) ->
696701
///
697702
/// Additionally, this struct can be used as operator CLI arguments. This functionality is only
698703
/// available if the feature `clap` is enabled.
704+
///
705+
#[cfg_attr(
706+
feature = "clap",
707+
doc = r#"
708+
```
709+
# use stackable_telemetry::tracing::TelemetryOptions;
710+
use clap::Parser;
711+
712+
#[derive(Parser)]
713+
struct Cli {
714+
#[arg(short, long)]
715+
namespace: String,
716+
717+
#[clap(flatten)]
718+
telemetry_arguments: TelemetryOptions,
719+
}
720+
```
721+
"#
722+
)]
699723
#[cfg_attr(feature = "clap", derive(clap::Args, PartialEq, Eq))]
700724
#[derive(Debug, Default)]
701725
pub struct TelemetryOptions {

0 commit comments

Comments
 (0)