Skip to content

Commit a082da9

Browse files
RemiBardondavidB
authored andcommitted
feat: Add support for Layer::with_thread_ids
1 parent 31c9456 commit a082da9

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

init-tracing-opentelemetry/src/config.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ pub struct FeatureSet {
189189
pub line_numbers: bool,
190190
/// Include thread names in output
191191
pub thread_names: bool,
192+
/// Include thread IDs in output
193+
pub thread_ids: bool,
192194
/// Use uptime timer instead of wall clock
193195
pub uptime_timer: bool,
194196
/// Configure span event logging
@@ -203,6 +205,7 @@ impl Default for FeatureSet {
203205
file_names: true,
204206
line_numbers: cfg!(debug_assertions),
205207
thread_names: cfg!(debug_assertions),
208+
thread_ids: false,
206209
uptime_timer: true,
207210
span_events: if cfg!(debug_assertions) {
208211
Some(FmtSpan::NEW | FmtSpan::CLOSE)
@@ -388,6 +391,13 @@ impl TracingConfig {
388391
self
389392
}
390393

394+
/// Enable or disable thread IDs in output
395+
#[must_use]
396+
pub fn with_thread_ids(mut self, enabled: bool) -> Self {
397+
self.features.thread_ids = enabled;
398+
self
399+
}
400+
391401
/// Configure span event logging
392402
#[must_use]
393403
pub fn with_span_events(mut self, events: FmtSpan) -> Self {

init-tracing-opentelemetry/src/formats.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ impl LayerBuilder for PrettyLayerBuilder {
5050
layer = layer.with_thread_names(true);
5151
}
5252

53+
// Configure thread IDs
54+
if config.features.thread_ids {
55+
layer = layer.with_thread_ids(true);
56+
}
57+
5358
// Configure span events
5459
if let Some(span_events) = &config.features.span_events {
5560
layer = layer.with_span_events(span_events.clone());
@@ -106,6 +111,11 @@ impl LayerBuilder for JsonLayerBuilder {
106111
layer = layer.with_thread_names(true);
107112
}
108113

114+
// Configure thread IDs
115+
if config.features.thread_ids {
116+
layer = layer.with_thread_ids(true);
117+
}
118+
109119
// Configure span events (typically disabled in production JSON)
110120
if let Some(span_events) = &config.features.span_events {
111121
layer = layer.with_span_events(span_events.clone());
@@ -161,6 +171,11 @@ impl LayerBuilder for FullLayerBuilder {
161171
layer = layer.with_thread_names(true);
162172
}
163173

174+
// Configure thread IDs
175+
if config.features.thread_ids {
176+
layer = layer.with_thread_ids(true);
177+
}
178+
164179
// Configure span events
165180
if let Some(span_events) = &config.features.span_events {
166181
layer = layer.with_span_events(span_events.clone());
@@ -217,6 +232,11 @@ impl LayerBuilder for CompactLayerBuilder {
217232
layer = layer.with_thread_names(true);
218233
}
219234

235+
// Configure thread IDs
236+
if config.features.thread_ids {
237+
layer = layer.with_thread_ids(true);
238+
}
239+
220240
// Configure span events
221241
if let Some(span_events) = &config.features.span_events {
222242
layer = layer.with_span_events(span_events.clone());

0 commit comments

Comments
 (0)