mirror of
https://github.com/tokio-rs/tracing.git
synced 2025-10-04 00:04:39 +00:00
parent
0af3ea6465
commit
5f0f5cc97e
@ -258,7 +258,7 @@ where
|
|||||||
{
|
{
|
||||||
fn set_from(&self, bytes: Bytes) -> Result<(), String> {
|
fn set_from(&self, bytes: Bytes) -> Result<(), String> {
|
||||||
use std::str;
|
use std::str;
|
||||||
let body = str::from_utf8(&bytes.as_ref()).map_err(|e| format!("{}", e))?;
|
let body = str::from_utf8(bytes.as_ref()).map_err(|e| format!("{}", e))?;
|
||||||
trace!(request.body = ?body);
|
trace!(request.body = ?body);
|
||||||
let new_filter = body
|
let new_filter = body
|
||||||
.parse::<tracing_subscriber::filter::EnvFilter>()
|
.parse::<tracing_subscriber::filter::EnvFilter>()
|
||||||
|
@ -30,7 +30,7 @@ impl<T: Write + Send + Sync + 'static> Worker<T> {
|
|||||||
fn handle_recv(&mut self, result: &Result<Msg, RecvError>) -> io::Result<WorkerState> {
|
fn handle_recv(&mut self, result: &Result<Msg, RecvError>) -> io::Result<WorkerState> {
|
||||||
match result {
|
match result {
|
||||||
Ok(Msg::Line(msg)) => {
|
Ok(Msg::Line(msg)) => {
|
||||||
self.writer.write_all(&msg)?;
|
self.writer.write_all(msg)?;
|
||||||
Ok(WorkerState::Continue)
|
Ok(WorkerState::Continue)
|
||||||
}
|
}
|
||||||
Ok(Msg::Shutdown) => Ok(WorkerState::Shutdown),
|
Ok(Msg::Shutdown) => Ok(WorkerState::Shutdown),
|
||||||
@ -41,7 +41,7 @@ impl<T: Write + Send + Sync + 'static> Worker<T> {
|
|||||||
fn handle_try_recv(&mut self, result: &Result<Msg, TryRecvError>) -> io::Result<WorkerState> {
|
fn handle_try_recv(&mut self, result: &Result<Msg, TryRecvError>) -> io::Result<WorkerState> {
|
||||||
match result {
|
match result {
|
||||||
Ok(Msg::Line(msg)) => {
|
Ok(Msg::Line(msg)) => {
|
||||||
self.writer.write_all(&msg)?;
|
self.writer.write_all(msg)?;
|
||||||
Ok(WorkerState::Continue)
|
Ok(WorkerState::Continue)
|
||||||
}
|
}
|
||||||
Ok(Msg::Shutdown) => Ok(WorkerState::Shutdown),
|
Ok(Msg::Shutdown) => Ok(WorkerState::Shutdown),
|
||||||
|
@ -66,7 +66,7 @@ fn expr_field() {
|
|||||||
.only(),
|
.only(),
|
||||||
);
|
);
|
||||||
run_test(span, || {
|
run_test(span, || {
|
||||||
fn_expr_field(&"hello world");
|
fn_expr_field("hello world");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ fn two_expr_fields() {
|
|||||||
.only(),
|
.only(),
|
||||||
);
|
);
|
||||||
run_test(span, || {
|
run_test(span, || {
|
||||||
fn_two_expr_fields(&"hello world");
|
fn_two_expr_fields("hello world");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,12 +95,12 @@ fn clashy_expr_field() {
|
|||||||
.only(),
|
.only(),
|
||||||
);
|
);
|
||||||
run_test(span, || {
|
run_test(span, || {
|
||||||
fn_clashy_expr_field(&"hello world");
|
fn_clashy_expr_field("hello world");
|
||||||
});
|
});
|
||||||
|
|
||||||
let span = span::mock().with_field(mock("s").with_value(&"s").only());
|
let span = span::mock().with_field(mock("s").with_value(&"s").only());
|
||||||
run_test(span, || {
|
run_test(span, || {
|
||||||
fn_clashy_expr_field2(&"hello world");
|
fn_clashy_expr_field2("hello world");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -561,7 +561,7 @@ impl Dispatch {
|
|||||||
/// [`new_span`]: ../subscriber/trait.Subscriber.html#method.new_span
|
/// [`new_span`]: ../subscriber/trait.Subscriber.html#method.new_span
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn clone_span(&self, id: &span::Id) -> span::Id {
|
pub fn clone_span(&self, id: &span::Id) -> span::Id {
|
||||||
self.subscriber.clone_span(&id)
|
self.subscriber.clone_span(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Notifies the subscriber that a [span ID] has been dropped.
|
/// Notifies the subscriber that a [span ID] has been dropped.
|
||||||
@ -724,7 +724,7 @@ impl State {
|
|||||||
#[inline]
|
#[inline]
|
||||||
fn enter(&self) -> Option<Entered<'_>> {
|
fn enter(&self) -> Option<Entered<'_>> {
|
||||||
if self.can_enter.replace(false) {
|
if self.can_enter.replace(false) {
|
||||||
Some(Entered(&self))
|
Some(Entered(self))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
@ -401,7 +401,7 @@ impl crate::sealed::Sealed for str {}
|
|||||||
|
|
||||||
impl Value for str {
|
impl Value for str {
|
||||||
fn record(&self, key: &Field, visitor: &mut dyn Visit) {
|
fn record(&self, key: &Field, visitor: &mut dyn Visit) {
|
||||||
visitor.record_str(key, &self)
|
visitor.record_str(key, self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -300,7 +300,7 @@ impl Current {
|
|||||||
/// Borrows the `Metadata` of the current span, if one exists and is known.
|
/// Borrows the `Metadata` of the current span, if one exists and is known.
|
||||||
pub fn metadata(&self) -> Option<&'static Metadata<'static>> {
|
pub fn metadata(&self) -> Option<&'static Metadata<'static>> {
|
||||||
match self.inner {
|
match self.inner {
|
||||||
CurrentInner::Current { ref metadata, .. } => Some(*metadata),
|
CurrentInner::Current { metadata, .. } => Some(metadata),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -444,7 +444,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
let samples = self.time_since_last_event();
|
let samples = self.time_since_last_event();
|
||||||
let first = expect!(ctx.span(&id), "expected: span id exists in registry");
|
let first = expect!(ctx.span(id), "expected: span id exists in registry");
|
||||||
|
|
||||||
let mut stack = String::new();
|
let mut stack = String::new();
|
||||||
if !self.config.threads_collapsed {
|
if !self.config.threads_collapsed {
|
||||||
|
@ -252,7 +252,7 @@ impl Subscriber for TraceLogger {
|
|||||||
let parent = self.current_id();
|
let parent = self.current_id();
|
||||||
if self.settings.parent_fields {
|
if self.settings.parent_fields {
|
||||||
let mut next_parent = parent.as_ref();
|
let mut next_parent = parent.as_ref();
|
||||||
while let Some(ref parent) = next_parent.and_then(|p| spans.get(&p)) {
|
while let Some(parent) = next_parent.and_then(|p| spans.get(p)) {
|
||||||
write!(&mut fields, "{}", parent.fields).expect("write to string cannot fail");
|
write!(&mut fields, "{}", parent.fields).expect("write to string cannot fail");
|
||||||
next_parent = parent.parent.as_ref();
|
next_parent = parent.parent.as_ref();
|
||||||
}
|
}
|
||||||
@ -298,7 +298,7 @@ impl Subscriber for TraceLogger {
|
|||||||
let current_id = self.current_id();
|
let current_id = self.current_id();
|
||||||
let current_fields = current_id
|
let current_fields = current_id
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.and_then(|id| spans.get(&id))
|
.and_then(|id| spans.get(id))
|
||||||
.map(|span| span.fields.as_ref())
|
.map(|span| span.fields.as_ref())
|
||||||
.unwrap_or("");
|
.unwrap_or("");
|
||||||
if self.settings.log_ids {
|
if self.settings.log_ids {
|
||||||
|
@ -74,14 +74,14 @@ impl PreSampledTracer for Tracer {
|
|||||||
|
|
||||||
// Gather trace state
|
// Gather trace state
|
||||||
let (no_parent, trace_id, remote_parent, parent_trace_flags) =
|
let (no_parent, trace_id, remote_parent, parent_trace_flags) =
|
||||||
current_trace_state(&builder, &parent_cx, &provider);
|
current_trace_state(builder, parent_cx, &provider);
|
||||||
|
|
||||||
// Sample or defer to existing sampling decisions
|
// Sample or defer to existing sampling decisions
|
||||||
let (flags, trace_state) = if let Some(result) = &builder.sampling_result {
|
let (flags, trace_state) = if let Some(result) = &builder.sampling_result {
|
||||||
process_sampling_result(result, parent_trace_flags)
|
process_sampling_result(result, parent_trace_flags)
|
||||||
} else if no_parent || remote_parent {
|
} else if no_parent || remote_parent {
|
||||||
builder.sampling_result = Some(provider.config().sampler.should_sample(
|
builder.sampling_result = Some(provider.config().sampler.should_sample(
|
||||||
Some(&parent_cx),
|
Some(parent_cx),
|
||||||
trace_id,
|
trace_id,
|
||||||
&builder.name,
|
&builder.name,
|
||||||
builder.span_kind.as_ref().unwrap_or(&SpanKind::Internal),
|
builder.span_kind.as_ref().unwrap_or(&SpanKind::Internal),
|
||||||
|
@ -156,21 +156,21 @@ where
|
|||||||
impl<'a> crate::sealed::Sealed<RecordFieldsMarker> for Event<'a> {}
|
impl<'a> crate::sealed::Sealed<RecordFieldsMarker> for Event<'a> {}
|
||||||
impl<'a> RecordFields for Event<'a> {
|
impl<'a> RecordFields for Event<'a> {
|
||||||
fn record(&self, visitor: &mut dyn Visit) {
|
fn record(&self, visitor: &mut dyn Visit) {
|
||||||
Event::record(&self, visitor)
|
Event::record(self, visitor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> crate::sealed::Sealed<RecordFieldsMarker> for Attributes<'a> {}
|
impl<'a> crate::sealed::Sealed<RecordFieldsMarker> for Attributes<'a> {}
|
||||||
impl<'a> RecordFields for Attributes<'a> {
|
impl<'a> RecordFields for Attributes<'a> {
|
||||||
fn record(&self, visitor: &mut dyn Visit) {
|
fn record(&self, visitor: &mut dyn Visit) {
|
||||||
Attributes::record(&self, visitor)
|
Attributes::record(self, visitor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> crate::sealed::Sealed<RecordFieldsMarker> for Record<'a> {}
|
impl<'a> crate::sealed::Sealed<RecordFieldsMarker> for Record<'a> {}
|
||||||
impl<'a> RecordFields for Record<'a> {
|
impl<'a> RecordFields for Record<'a> {
|
||||||
fn record(&self, visitor: &mut dyn Visit) {
|
fn record(&self, visitor: &mut dyn Visit) {
|
||||||
Record::record(&self, visitor)
|
Record::record(self, visitor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ impl Match for Directive {
|
|||||||
fn cares_about(&self, meta: &Metadata<'_>) -> bool {
|
fn cares_about(&self, meta: &Metadata<'_>) -> bool {
|
||||||
// Does this directive have a target filter, and does it match the
|
// Does this directive have a target filter, and does it match the
|
||||||
// metadata's target?
|
// metadata's target?
|
||||||
if let Some(ref target) = self.target.as_ref() {
|
if let Some(target) = self.target.as_ref() {
|
||||||
if !meta.target().starts_with(&target[..]) {
|
if !meta.target().starts_with(&target[..]) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -561,7 +561,7 @@ impl Match for StaticDirective {
|
|||||||
fn cares_about(&self, meta: &Metadata<'_>) -> bool {
|
fn cares_about(&self, meta: &Metadata<'_>) -> bool {
|
||||||
// Does this directive have a target filter, and does it match the
|
// Does this directive have a target filter, and does it match the
|
||||||
// metadata's target?
|
// metadata's target?
|
||||||
if let Some(ref target) = self.target.as_ref() {
|
if let Some(target) = self.target.as_ref() {
|
||||||
if !meta.target().starts_with(&target[..]) {
|
if !meta.target().starts_with(&target[..]) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
8
tracing-subscriber/src/filter/env/mod.rs
vendored
8
tracing-subscriber/src/filter/env/mod.rs
vendored
@ -636,7 +636,7 @@ mod tests {
|
|||||||
Kind::SPAN,
|
Kind::SPAN,
|
||||||
);
|
);
|
||||||
|
|
||||||
let interest = filter.register_callsite(&META);
|
let interest = filter.register_callsite(META);
|
||||||
assert!(interest.is_never());
|
assert!(interest.is_never());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -654,7 +654,7 @@ mod tests {
|
|||||||
Kind::SPAN,
|
Kind::SPAN,
|
||||||
);
|
);
|
||||||
|
|
||||||
let interest = filter.register_callsite(&META);
|
let interest = filter.register_callsite(META);
|
||||||
assert!(interest.is_always());
|
assert!(interest.is_always());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -673,7 +673,7 @@ mod tests {
|
|||||||
Kind::SPAN,
|
Kind::SPAN,
|
||||||
);
|
);
|
||||||
|
|
||||||
let interest = filter.register_callsite(&META);
|
let interest = filter.register_callsite(META);
|
||||||
assert!(interest.is_always());
|
assert!(interest.is_always());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -692,7 +692,7 @@ mod tests {
|
|||||||
Kind::SPAN,
|
Kind::SPAN,
|
||||||
);
|
);
|
||||||
|
|
||||||
let interest = filter.register_callsite(&META);
|
let interest = filter.register_callsite(META);
|
||||||
assert!(interest.is_never());
|
assert!(interest.is_never());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ where
|
|||||||
// We should probably rework this to use a `serde_json::Value` or something
|
// We should probably rework this to use a `serde_json::Value` or something
|
||||||
// similar in a JSON-specific layer, but I'd (david)
|
// similar in a JSON-specific layer, but I'd (david)
|
||||||
// rather have a uglier fix now rather than shipping broken JSON.
|
// rather have a uglier fix now rather than shipping broken JSON.
|
||||||
match serde_json::from_str::<serde_json::Value>(&data) {
|
match serde_json::from_str::<serde_json::Value>(data) {
|
||||||
Ok(serde_json::Value::Object(fields)) => {
|
Ok(serde_json::Value::Object(fields)) => {
|
||||||
for field in fields {
|
for field in fields {
|
||||||
serializer.serialize_entry(&field.0, &field.1)?;
|
serializer.serialize_entry(&field.0, &field.1)?;
|
||||||
@ -429,25 +429,25 @@ impl<'a> field::Visit for JsonVisitor<'a> {
|
|||||||
/// Visit a signed 64-bit integer value.
|
/// Visit a signed 64-bit integer value.
|
||||||
fn record_i64(&mut self, field: &Field, value: i64) {
|
fn record_i64(&mut self, field: &Field, value: i64) {
|
||||||
self.values
|
self.values
|
||||||
.insert(&field.name(), serde_json::Value::from(value));
|
.insert(field.name(), serde_json::Value::from(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Visit an unsigned 64-bit integer value.
|
/// Visit an unsigned 64-bit integer value.
|
||||||
fn record_u64(&mut self, field: &Field, value: u64) {
|
fn record_u64(&mut self, field: &Field, value: u64) {
|
||||||
self.values
|
self.values
|
||||||
.insert(&field.name(), serde_json::Value::from(value));
|
.insert(field.name(), serde_json::Value::from(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Visit a boolean value.
|
/// Visit a boolean value.
|
||||||
fn record_bool(&mut self, field: &Field, value: bool) {
|
fn record_bool(&mut self, field: &Field, value: bool) {
|
||||||
self.values
|
self.values
|
||||||
.insert(&field.name(), serde_json::Value::from(value));
|
.insert(field.name(), serde_json::Value::from(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Visit a string value.
|
/// Visit a string value.
|
||||||
fn record_str(&mut self, field: &Field, value: &str) {
|
fn record_str(&mut self, field: &Field, value: &str) {
|
||||||
self.values
|
self.values
|
||||||
.insert(&field.name(), serde_json::Value::from(value));
|
.insert(field.name(), serde_json::Value::from(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn record_debug(&mut self, field: &Field, value: &dyn fmt::Debug) {
|
fn record_debug(&mut self, field: &Field, value: &dyn fmt::Debug) {
|
||||||
@ -487,7 +487,7 @@ impl<'a> io::Write for WriteAdaptor<'a> {
|
|||||||
std::str::from_utf8(buf).map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?;
|
std::str::from_utf8(buf).map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?;
|
||||||
|
|
||||||
self.fmt_write
|
self.fmt_write
|
||||||
.write_str(&s)
|
.write_str(s)
|
||||||
.map_err(|e| io::Error::new(io::ErrorKind::Other, e))?;
|
.map_err(|e| io::Error::new(io::ErrorKind::Other, e))?;
|
||||||
|
|
||||||
Ok(s.as_bytes().len())
|
Ok(s.as_bytes().len())
|
||||||
@ -771,7 +771,7 @@ mod test {
|
|||||||
.lines()
|
.lines()
|
||||||
.last()
|
.last()
|
||||||
.expect("expected at least one line to be written!");
|
.expect("expected at least one line to be written!");
|
||||||
match serde_json::from_str(&json) {
|
match serde_json::from_str(json) {
|
||||||
Ok(v) => v,
|
Ok(v) => v,
|
||||||
Err(e) => panic!(
|
Err(e) => panic!(
|
||||||
"assertion failed: JSON shouldn't be malformed\n error: {}\n json: {}",
|
"assertion failed: JSON shouldn't be malformed\n error: {}\n json: {}",
|
||||||
@ -786,7 +786,7 @@ mod test {
|
|||||||
buf: &'static Mutex<Vec<u8>>,
|
buf: &'static Mutex<Vec<u8>>,
|
||||||
producer: impl FnOnce() -> T,
|
producer: impl FnOnce() -> T,
|
||||||
) {
|
) {
|
||||||
let make_writer = MockMakeWriter::new(&buf);
|
let make_writer = MockMakeWriter::new(buf);
|
||||||
let subscriber = builder
|
let subscriber = builder
|
||||||
.with_writer(make_writer.clone())
|
.with_writer(make_writer.clone())
|
||||||
.with_timer(MockTime)
|
.with_timer(MockTime)
|
||||||
|
@ -636,7 +636,7 @@ where
|
|||||||
let fmt_ctx = {
|
let fmt_ctx = {
|
||||||
#[cfg(feature = "ansi")]
|
#[cfg(feature = "ansi")]
|
||||||
{
|
{
|
||||||
FmtCtx::new(&ctx, event.parent(), self.ansi)
|
FmtCtx::new(ctx, event.parent(), self.ansi)
|
||||||
}
|
}
|
||||||
#[cfg(not(feature = "ansi"))]
|
#[cfg(not(feature = "ansi"))]
|
||||||
{
|
{
|
||||||
@ -855,7 +855,7 @@ where
|
|||||||
|
|
||||||
let span = self
|
let span = self
|
||||||
.span
|
.span
|
||||||
.and_then(|id| self.ctx.ctx.span(&id))
|
.and_then(|id| self.ctx.ctx.span(id))
|
||||||
.or_else(|| self.ctx.ctx.lookup_current());
|
.or_else(|| self.ctx.ctx.lookup_current());
|
||||||
|
|
||||||
let scope = span.into_iter().flat_map(|span| span.scope().from_root());
|
let scope = span.into_iter().flat_map(|span| span.scope().from_root());
|
||||||
@ -925,7 +925,7 @@ where
|
|||||||
|
|
||||||
let span = self
|
let span = self
|
||||||
.span
|
.span
|
||||||
.and_then(|id| self.ctx.ctx.span(&id))
|
.and_then(|id| self.ctx.ctx.span(id))
|
||||||
.or_else(|| self.ctx.ctx.lookup_current());
|
.or_else(|| self.ctx.ctx.lookup_current());
|
||||||
|
|
||||||
let scope = span.into_iter().flat_map(|span| span.scope().from_root());
|
let scope = span.into_iter().flat_map(|span| span.scope().from_root());
|
||||||
|
@ -181,7 +181,7 @@ where
|
|||||||
};
|
};
|
||||||
let span = event
|
let span = event
|
||||||
.parent()
|
.parent()
|
||||||
.and_then(|id| ctx.span(&id))
|
.and_then(|id| ctx.span(id))
|
||||||
.or_else(|| ctx.lookup_current());
|
.or_else(|| ctx.lookup_current());
|
||||||
|
|
||||||
let scope = span.into_iter().flat_map(|span| span.scope());
|
let scope = span.into_iter().flat_map(|span| span.scope());
|
||||||
|
@ -1000,7 +1000,7 @@ where
|
|||||||
/// [`Context::enabled`]: #method.enabled
|
/// [`Context::enabled`]: #method.enabled
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn event(&self, event: &Event<'_>) {
|
pub fn event(&self, event: &Event<'_>) {
|
||||||
if let Some(ref subscriber) = self.subscriber {
|
if let Some(subscriber) = self.subscriber {
|
||||||
subscriber.event(event);
|
subscriber.event(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1159,7 +1159,7 @@ where
|
|||||||
let subscriber = self.subscriber.as_ref()?;
|
let subscriber = self.subscriber.as_ref()?;
|
||||||
let current = subscriber.current_span();
|
let current = subscriber.current_span();
|
||||||
let id = current.id()?;
|
let id = current.id()?;
|
||||||
let span = subscriber.span(&id);
|
let span = subscriber.span(id);
|
||||||
debug_assert!(
|
debug_assert!(
|
||||||
span.is_some(),
|
span.is_some(),
|
||||||
"the subscriber should have data for the current span ({:?})!",
|
"the subscriber should have data for the current span ({:?})!",
|
||||||
|
@ -103,7 +103,6 @@
|
|||||||
|
|
||||||
use tracing_core::span::Id;
|
use tracing_core::span::Id;
|
||||||
|
|
||||||
#[macro_use]
|
|
||||||
macro_rules! try_lock {
|
macro_rules! try_lock {
|
||||||
($lock:expr) => {
|
($lock:expr) => {
|
||||||
try_lock!($lock, else return)
|
try_lock!($lock, else return)
|
||||||
|
@ -124,7 +124,7 @@ pub trait LookupSpan<'a> {
|
|||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
{
|
{
|
||||||
let data = self.span_data(&id)?;
|
let data = self.span_data(id)?;
|
||||||
Some(SpanRef {
|
Some(SpanRef {
|
||||||
registry: self,
|
registry: self,
|
||||||
data,
|
data,
|
||||||
|
@ -151,7 +151,7 @@ impl Registry {
|
|||||||
});
|
});
|
||||||
CloseGuard {
|
CloseGuard {
|
||||||
id,
|
id,
|
||||||
registry: &self,
|
registry: self,
|
||||||
is_closing: false,
|
is_closing: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -234,7 +234,7 @@ impl Subscriber for Registry {
|
|||||||
|
|
||||||
fn clone_span(&self, id: &span::Id) -> span::Id {
|
fn clone_span(&self, id: &span::Id) -> span::Id {
|
||||||
let span = self
|
let span = self
|
||||||
.get(&id)
|
.get(id)
|
||||||
.unwrap_or_else(|| panic!(
|
.unwrap_or_else(|| panic!(
|
||||||
"tried to clone {:?}, but no span exists with that ID\n\
|
"tried to clone {:?}, but no span exists with that ID\n\
|
||||||
This may be caused by consuming a parent span (`parent: span`) rather than borrowing it (`parent: &span`).",
|
This may be caused by consuming a parent span (`parent: span`) rather than borrowing it (`parent: &span`).",
|
||||||
|
@ -39,18 +39,18 @@ mod parking_lot_impl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub(crate) fn read<'a>(&'a self) -> LockResult<RwLockReadGuard<'a, T>> {
|
pub(crate) fn read(&self) -> LockResult<RwLockReadGuard<'_, T>> {
|
||||||
Ok(self.inner.read())
|
Ok(self.inner.read())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
#[allow(dead_code)] // may be used later;
|
#[allow(dead_code)] // may be used later;
|
||||||
pub(crate) fn try_read<'a>(&'a self) -> TryLockResult<RwLockReadGuard<'a, T>> {
|
pub(crate) fn try_read(&self) -> TryLockResult<RwLockReadGuard<'_, T>> {
|
||||||
self.inner.try_read().ok_or(TryLockError::WouldBlock)
|
self.inner.try_read().ok_or(TryLockError::WouldBlock)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub(crate) fn write<'a>(&'a self) -> LockResult<RwLockWriteGuard<'a, T>> {
|
pub(crate) fn write(&self) -> LockResult<RwLockWriteGuard<'_, T>> {
|
||||||
Ok(self.inner.write())
|
Ok(self.inner.write())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1040,7 +1040,7 @@ pub mod __macro_support {
|
|||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn metadata(&self) -> &Metadata<'static> {
|
fn metadata(&self) -> &Metadata<'static> {
|
||||||
&self.meta
|
self.meta
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -907,7 +907,7 @@ impl Span {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if_log_enabled! { crate::Level::TRACE, {
|
if_log_enabled! { crate::Level::TRACE, {
|
||||||
if let Some(ref meta) = self.meta {
|
if let Some(meta) = self.meta {
|
||||||
self.log(ACTIVITY_LOG_TARGET, log::Level::Trace, format_args!("-> {}", meta.name()));
|
self.log(ACTIVITY_LOG_TARGET, log::Level::Trace, format_args!("-> {}", meta.name()));
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
@ -924,7 +924,7 @@ impl Span {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if_log_enabled! { crate::Level::TRACE, {
|
if_log_enabled! { crate::Level::TRACE, {
|
||||||
if let Some(ref _meta) = self.meta {
|
if let Some(_meta) = self.meta {
|
||||||
self.log(ACTIVITY_LOG_TARGET, log::Level::Trace, format_args!("<- {}", _meta.name()));
|
self.log(ACTIVITY_LOG_TARGET, log::Level::Trace, format_args!("<- {}", _meta.name()));
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
@ -1065,7 +1065,7 @@ impl Span {
|
|||||||
Q: field::AsField,
|
Q: field::AsField,
|
||||||
V: field::Value,
|
V: field::Value,
|
||||||
{
|
{
|
||||||
if let Some(ref meta) = self.meta {
|
if let Some(meta) = self.meta {
|
||||||
if let Some(field) = field.as_field(meta) {
|
if let Some(field) = field.as_field(meta) {
|
||||||
self.record_all(
|
self.record_all(
|
||||||
&meta
|
&meta
|
||||||
@ -1085,7 +1085,7 @@ impl Span {
|
|||||||
inner.record(&record);
|
inner.record(&record);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(ref _meta) = self.meta {
|
if let Some(_meta) = self.meta {
|
||||||
if_log_enabled! { *_meta.level(), {
|
if_log_enabled! { *_meta.level(), {
|
||||||
let target = if record.is_empty() {
|
let target = if record.is_empty() {
|
||||||
LIFECYCLE_LOG_TARGET
|
LIFECYCLE_LOG_TARGET
|
||||||
@ -1194,7 +1194,7 @@ impl Span {
|
|||||||
#[cfg(feature = "log")]
|
#[cfg(feature = "log")]
|
||||||
#[inline]
|
#[inline]
|
||||||
fn log(&self, target: &str, level: log::Level, message: fmt::Arguments<'_>) {
|
fn log(&self, target: &str, level: log::Level, message: fmt::Arguments<'_>) {
|
||||||
if let Some(ref meta) = self.meta {
|
if let Some(meta) = self.meta {
|
||||||
if level_to_log!(*meta.level()) <= log::max_level() {
|
if level_to_log!(*meta.level()) <= log::max_level() {
|
||||||
let logger = log::logger();
|
let logger = log::logger();
|
||||||
let log_meta = log::Metadata::builder().level(level).target(target).build();
|
let log_meta = log::Metadata::builder().level(level).target(target).build();
|
||||||
@ -1257,7 +1257,7 @@ impl Hash for Span {
|
|||||||
impl fmt::Debug for Span {
|
impl fmt::Debug for Span {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
let mut span = f.debug_struct("Span");
|
let mut span = f.debug_struct("Span");
|
||||||
if let Some(ref meta) = self.meta {
|
if let Some(meta) = self.meta {
|
||||||
span.field("name", &meta.name())
|
span.field("name", &meta.name())
|
||||||
.field("level", &meta.level())
|
.field("level", &meta.level())
|
||||||
.field("target", &meta.target());
|
.field("target", &meta.target());
|
||||||
@ -1327,7 +1327,7 @@ impl Drop for Span {
|
|||||||
subscriber.try_close(id.clone());
|
subscriber.try_close(id.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(ref _meta) = self.meta {
|
if let Some(_meta) = self.meta {
|
||||||
if_log_enabled! { crate::Level::TRACE, {
|
if_log_enabled! { crate::Level::TRACE, {
|
||||||
self.log(
|
self.log(
|
||||||
LIFECYCLE_LOG_TARGET,
|
LIFECYCLE_LOG_TARGET,
|
||||||
@ -1358,7 +1358,7 @@ impl Inner {
|
|||||||
/// returns `Ok(())` if the other span was added as a precedent of this
|
/// returns `Ok(())` if the other span was added as a precedent of this
|
||||||
/// span, or an error if this was not possible.
|
/// span, or an error if this was not possible.
|
||||||
fn follows_from(&self, from: &Id) {
|
fn follows_from(&self, from: &Id) {
|
||||||
self.subscriber.record_follows_from(&self.id, &from)
|
self.subscriber.record_follows_from(&self.id, from)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the span's ID.
|
/// Returns the span's ID.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user