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:
Eliza Weisman
2019-03-07 12:41:10 -08:00
committed by GitHub
parent 6fbef0a528
commit d88aba8d1c
12 changed files with 186 additions and 143 deletions
+2 -2
View File
@@ -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 }
+4 -4
View File
@@ -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))
}
}