mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-28 00:00:11 +02:00
trace: Add arguments struct to subscriber::Record (#955)
This branch changes the `Subscriber::record` method to take a new arguments struct, `span::Record`. The `field::Record` trait was renamed to `field::Visit` to prevent name conflicts. In addition, the `ValueSet::is_empty`, `ValueSet::contains`, and `ValueSet::record` methods were made crate-private, as they are exposed on the `Attributes` and `Record` types. Signed-off-by: Eliza Weisman <[email protected]>
This commit is contained in:
@@ -247,10 +247,10 @@
|
||||
//! #[macro_use]
|
||||
//! extern crate tokio_trace;
|
||||
//! # pub struct FooSubscriber;
|
||||
//! # use tokio_trace::{span::{Id, Attributes}, Metadata, field::ValueSet};
|
||||
//! # use tokio_trace::{span::{Id, Attributes, Record}, Metadata};
|
||||
//! # impl tokio_trace::Subscriber for FooSubscriber {
|
||||
//! # fn new_span(&self, _: &Attributes) -> Id { Id::from_u64(0) }
|
||||
//! # fn record(&self, _: &Id, _: &ValueSet) {}
|
||||
//! # fn record(&self, _: &Id, _: &Record) {}
|
||||
//! # fn event(&self, _: &tokio_trace::Event) {}
|
||||
//! # fn record_follows_from(&self, _: &Id, _: &Id) {}
|
||||
//! # fn enabled(&self, _: &Metadata) -> bool { false }
|
||||
|
||||
@@ -135,7 +135,7 @@
|
||||
//! the data for future use, record it in some manner, or discard it completely.
|
||||
//!
|
||||
//! [`Subscriber`]: ::Subscriber
|
||||
pub use tokio_trace_core::span::{Attributes, Id};
|
||||
pub use tokio_trace_core::span::{Attributes, Id, Record};
|
||||
|
||||
use std::{
|
||||
borrow::Borrow,
|
||||
@@ -324,7 +324,7 @@ impl<'a> Span<'a> {
|
||||
.is_some()
|
||||
}
|
||||
|
||||
/// Records that the field described by `field` has the value `value`.
|
||||
/// Visits that the field described by `field` has the value `value`.
|
||||
pub fn record<Q: ?Sized, V>(&mut self, field: &Q, value: &V) -> &mut Self
|
||||
where
|
||||
Q: field::AsField,
|
||||
@@ -343,7 +343,7 @@ impl<'a> Span<'a> {
|
||||
self
|
||||
}
|
||||
|
||||
/// Record all the fields in the span
|
||||
/// Visit all the fields in the span
|
||||
pub fn record_all(&mut self, values: &field::ValueSet) -> &mut Self {
|
||||
if let Some(ref mut inner) = self.inner {
|
||||
inner.record(&values);
|
||||
@@ -479,7 +479,7 @@ impl<'a> Inner<'a> {
|
||||
|
||||
fn record(&mut self, values: &field::ValueSet) {
|
||||
if values.callsite() == self.meta.callsite() {
|
||||
self.subscriber.record(&self.id, &values)
|
||||
self.subscriber.record(&self.id, &Record::new(values))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user