Skip to content

Commit 6636d94

Browse files
docs(stackable-telemetry): Add #![warn(missing_docs)] (#944)
* docs(stackable-telemetry): Add #![warn(missing_docs)] * chore: Apply suggestions Co-authored-by: Siegfried Weber <mail@siegfriedweber.net> * chore: Apply suggestion Co-authored-by: Siegfried Weber <mail@siegfriedweber.net> --------- Co-authored-by: Siegfried Weber <mail@siegfriedweber.net>
1 parent c07fd5d commit 6636d94

File tree

6 files changed

+67
-15
lines changed

6 files changed

+67
-15
lines changed

crates/stackable-telemetry/src/instrumentation/axum/mod.rs

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,20 +173,34 @@ where
173173
}
174174
}
175175

176+
/// Errors which can be encountered when extracting the server host from a [`Request`].
176177
#[derive(Debug, Snafu)]
177178
pub enum ServerHostError {
179+
/// Indicates that parsing the port of the server host from the [`Request`] as a `u16` failed.
178180
#[snafu(display("failed to parse port {port:?} as u16 from string"))]
179-
ParsePort { source: ParseIntError, port: String },
181+
ParsePort {
182+
#[allow(missing_docs)]
183+
source: ParseIntError,
180184

185+
// TODO (@Techassi): Make snafu re-emit this
186+
/// The original input which was attempted to be parsed.
187+
port: String,
188+
},
189+
190+
/// Indicates that the server host from the [`Request`] contains an invalid/unknown scheme.
181191
#[snafu(display("encountered invalid request scheme {scheme:?}"))]
182-
InvalidScheme { scheme: String },
192+
InvalidScheme {
193+
/// The original scheme.
194+
scheme: String,
195+
},
183196

197+
// TODO (@Techassi): Make snafu re-emit this
198+
/// Indicates that no method of extracting the server host from the [`Request`] succeeded.
184199
#[snafu(display("failed to extract any host information from request"))]
185200
ExtractHost,
186201
}
187202

188-
/// This trait provides various helper functions to extract data from a
189-
/// HTTP [`Request`].
203+
/// This trait provides various helper functions to extract data from a HTTP [`Request`].
190204
pub trait RequestExt {
191205
/// Returns the client socket address, if available.
192206
fn client_socket_address(&self) -> Option<SocketAddr>;
@@ -429,7 +443,7 @@ impl SpanExt for Span {
429443
// Therefore, we have to made a decision about linking the two traces.
430444
// These are the options:
431445
// 1. Link to the trace id supplied in the incoming request, or
432-
// 2. Link to the current trace id, then set the parent contex based on
446+
// 2. Link to the current trace id, then set the parent context based on
433447
// trace information supplied in the incoming request.
434448
//
435449
// Neither is ideal, as it means there are (at least) two traces to look

crates/stackable-telemetry/src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
//! This crate contains various Tracing, Logging, and OpenTelemtry primitives to
2-
//! easily instrument code.
1+
#![warn(missing_docs)]
2+
3+
//! This crate contains various Tracing, Logging, and OpenTelemetry primitives to easily instrument
4+
//! code.
35
pub mod instrumentation;
46
pub mod tracing;
57

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

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,36 @@ pub mod settings;
2525

2626
type Result<T, E = Error> = std::result::Result<T, E>;
2727

28+
/// Errors which can be encountered when initialising [`Tracing`].
2829
#[derive(Debug, Snafu)]
2930
pub enum Error {
31+
/// Indicates that [`Tracing`] failed to install the OpenTelemetry trace exporter.
3032
#[snafu(display("unable to install opentelemetry trace exporter"))]
3133
InstallOtelTraceExporter {
34+
#[allow(missing_docs)]
3235
source: opentelemetry::trace::TraceError,
3336
},
3437

38+
/// Indicates that [`Tracing`] failed to install the OpenTelemetry log exporter.
3539
#[snafu(display("unable to install opentelemetry log exporter"))]
3640
InstallOtelLogExporter {
41+
#[allow(missing_docs)]
3742
source: opentelemetry::logs::LogError,
3843
},
3944

40-
#[snafu(display("unable to set the global default subscriber"))]
41-
SetGlobalDefaultSubscriber { source: SetGlobalDefaultError },
42-
45+
/// Indicates that [`Tracing`] failed to install the rolling file appender.
4346
#[snafu(display("failed to initialize rolling file appender"))]
44-
InitRollingFileAppender { source: InitError },
47+
InitRollingFileAppender {
48+
#[allow(missing_docs)]
49+
source: InitError,
50+
},
51+
52+
/// Indicates that [`Tracing`] failed to set the global default subscriber.
53+
#[snafu(display("unable to set the global default subscriber"))]
54+
SetGlobalDefaultSubscriber {
55+
#[allow(missing_docs)]
56+
source: SetGlobalDefaultError,
57+
},
4558
}
4659

4760
/// Easily initialize a set of pre-configured [`Subscriber`][1] layers.
@@ -225,6 +238,7 @@ pub struct Tracing {
225238
}
226239

227240
impl Tracing {
241+
/// Creates and returns a [`TracingBuilder`].
228242
pub fn builder() -> TracingBuilder<builder_state::PreServiceName> {
229243
TracingBuilder::default()
230244
}

crates/stackable-telemetry/src/tracing/settings/console_log.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ use tracing::level_filters::LevelFilter;
66

77
use super::{Settings, SettingsBuilder};
88

9-
/// Configure specific settings for the Console Log subscriber.
9+
/// Configure specific settings for the console log subscriber.
1010
#[derive(Debug, Default, PartialEq)]
1111
pub struct ConsoleLogSettings {
12-
/// Common subscriber settings that apply to the Console Log Subscriber.
12+
/// Common subscriber settings that apply to the console log subscriber.
1313
pub common_settings: Settings,
1414

15-
/// Console Subscriber log event output format.
15+
/// Console subscriber log event output format.
1616
pub log_format: Format,
1717
}
1818

@@ -24,7 +24,7 @@ impl Deref for ConsoleLogSettings {
2424
}
2525
}
2626

27-
/// Console Subscriber log event output formats.
27+
/// Console subscriber log event output formats.
2828
///
2929
/// Currently, only [Plain][Format::Plain] is supported.
3030
#[derive(Debug, Default, PartialEq)]
@@ -52,11 +52,13 @@ pub struct ConsoleLogSettingsBuilder {
5252
}
5353

5454
impl ConsoleLogSettingsBuilder {
55+
/// Overrides the default log [`Format`].
5556
pub fn with_log_format(mut self, format: Format) -> Self {
5657
self.log_format = format;
5758
self
5859
}
5960

61+
/// Consumes `self` and builds [`ConsoleLogSettings`].
6062
pub fn build(self) -> ConsoleLogSettings {
6163
ConsoleLogSettings {
6264
common_settings: self.common_settings,

crates/stackable-telemetry/src/tracing/settings/otlp_log.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ use tracing::level_filters::LevelFilter;
66

77
use super::{Settings, SettingsBuilder};
88

9+
/// Configure specific settings for the OpenTelemetry log subscriber.
910
#[derive(Debug, Default, PartialEq)]
1011
pub struct OtlpLogSettings {
12+
/// Common subscriber settings that apply to the OpenTelemetry log subscriber.
1113
pub common_settings: Settings,
1214
}
1315

@@ -19,11 +21,19 @@ impl Deref for OtlpLogSettings {
1921
}
2022
}
2123

24+
/// For building [`OtlpLogSettings`].
25+
///
26+
/// <div class="warning">
27+
///
28+
/// Do not use directly, instead use the [`Settings::builder`] associated function.
29+
///
30+
/// </div>
2231
pub struct OtlpLogSettingsBuilder {
2332
pub(crate) common_settings: Settings,
2433
}
2534

2635
impl OtlpLogSettingsBuilder {
36+
/// Consumes `self` and builds [`OtlpLogSettings`].
2737
pub fn build(self) -> OtlpLogSettings {
2838
OtlpLogSettings {
2939
common_settings: self.common_settings,

crates/stackable-telemetry/src/tracing/settings/otlp_trace.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ use tracing::level_filters::LevelFilter;
66

77
use super::{Settings, SettingsBuilder};
88

9+
/// Configure specific settings for the OpenTelemetry trace subscriber.
910
#[derive(Debug, Default, PartialEq)]
1011
pub struct OtlpTraceSettings {
12+
/// Common subscriber settings that apply to the OpenTelemetry trace subscriber.
1113
pub common_settings: Settings,
1214
}
1315

@@ -19,11 +21,19 @@ impl Deref for OtlpTraceSettings {
1921
}
2022
}
2123

24+
/// For building [`OtlpTraceSettings`].
25+
///
26+
/// <div class="warning">
27+
///
28+
/// Do not use directly, instead use the [`Settings::builder`] associated function.
29+
///
30+
/// </div>
2231
pub struct OtlpTraceSettingsBuilder {
2332
pub(crate) common_settings: Settings,
2433
}
2534

2635
impl OtlpTraceSettingsBuilder {
36+
/// Consumes `self` and builds [`OtlpTraceSettings`].
2737
pub fn build(self) -> OtlpTraceSettings {
2838
OtlpTraceSettings {
2939
common_settings: self.common_settings,

0 commit comments

Comments
 (0)