Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: expose an accessor for the FieldSet on Attributes #1331

Merged
merged 5 commits into from
Apr 15, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion tracing-core/src/span.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
//! Spans represent periods of time in the execution of a program.
use core::num::NonZeroU64;

use crate::field::FieldSet;
use crate::parent::Parent;
use crate::{field, Metadata};
use core::num::NonZeroU64;

/// Identifies a span within the context of a collector.
///
Expand Down Expand Up @@ -195,6 +197,21 @@ impl<'a> Attributes<'a> {
pub fn is_empty(&self) -> bool {
self.values.is_empty()
}

/// Returns the set of all [fields] defined by this span's [`Metadata`].
///
/// Note that the [`FieldSet`] returned by this method includes *all* the
/// fields declared by this span, not just those with values that are recorded
/// as part of this set of `Attributes`. Other fields with values not present in
/// this `Attributes`' value set may [record] values later.
///
/// [fields]: crate::field
/// [record]: Attributes::record()
/// [`Metadata`]: crate::metadata::Metadata
/// [`FieldSet`]: crate::field::FieldSet
pub fn fields(&self) -> &FieldSet {
self.values.field_set()
}
}

// ===== impl Record =====
Expand Down