Skip to content

Commit

Permalink
Merge branch 'master' into greater-than-32
Browse files Browse the repository at this point in the history
  • Loading branch information
eopb authored Jul 12, 2023
2 parents 4c9e98b + 27f688e commit e6dbe96
Show file tree
Hide file tree
Showing 16 changed files with 1,260 additions and 276 deletions.
4 changes: 2 additions & 2 deletions tracing-attributes/src/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ pub(crate) fn gen_function<'a, B: ToTokens + 'a>(
// exactly that way for it to do its magic.
let fake_return_edge = quote_spanned! {return_span=>
#[allow(
unreachable_code, clippy::diverging_sub_expression, clippy::let_unit_value,
clippy::unreachable, clippy::let_with_type_underscore
unknown_lints, unreachable_code, clippy::diverging_sub_expression,
clippy::let_unit_value, clippy::unreachable, clippy::let_with_type_underscore
)]
if false {
let __tracing_attr_fake_return: #return_type =
Expand Down
17 changes: 15 additions & 2 deletions tracing-core/src/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//! # `Value`s and `Collect`s
//!
//! Collectors consume `Value`s as fields attached to [span]s or [`Event`]s.
//! The set of field keys on a given span or is defined on its [`Metadata`].
//! The set of field keys on a given span or event is defined on its [`Metadata`].
//! When a span is created, it provides [`Attributes`] to the collector's
//! [`new_span`] method, containing any fields whose values were provided when
//! the span was created; and may call the collector's [`record`] method
Expand Down Expand Up @@ -877,6 +877,19 @@ impl<'a> ValueSet<'a> {
}
}

/// Returns the number of fields in this `ValueSet` that would be visited
/// by a given [visitor] to the [`ValueSet::record()`] method.
///
/// [visitor]: Visit
/// [`ValueSet::record()`]: ValueSet::record()
pub fn len(&self) -> usize {
let my_callsite = self.callsite();
self.values
.iter()
.filter(|(field, _)| field.callsite() == my_callsite)
.count()
}

/// Returns `true` if this `ValueSet` contains a value for the given `Field`.
pub(crate) fn contains(&self, field: &Field) -> bool {
field.callsite() == self.callsite()
Expand All @@ -887,7 +900,7 @@ impl<'a> ValueSet<'a> {
}

/// Returns true if this `ValueSet` contains _no_ values.
pub(crate) fn is_empty(&self) -> bool {
pub fn is_empty(&self) -> bool {
let my_callsite = self.callsite();
self.values
.iter()
Expand Down
6 changes: 3 additions & 3 deletions tracing-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,9 @@ macro_rules! metadata {
$name,
$target,
$level,
Some(file!()),
Some(line!()),
Some(module_path!()),
::core::option::Option::Some(file!()),
::core::option::Option::Some(line!()),
::core::option::Option::Some(module_path!()),
$crate::field::FieldSet::new($fields, $crate::identify_callsite!($callsite)),
$kind,
)
Expand Down
8 changes: 8 additions & 0 deletions tracing-core/src/span.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,14 @@ impl<'a> Record<'a> {
self.values.record(visitor)
}

/// Returns the number of fields that would be visited from this `Record`
/// when [`Record::record()`] is called
///
/// [`Record::record()`]: Record::record()
pub fn len(&self) -> usize {
self.values.len()
}

/// Returns `true` if this `Record` contains a value for the given `Field`.
pub fn contains(&self, field: &field::Field) -> bool {
self.values.contains(field)
Expand Down
6 changes: 3 additions & 3 deletions tracing-log/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,9 @@ macro_rules! log_cs {
"log event",
"log",
$level,
None,
None,
None,
::core::option::Option::None,
::core::option::Option::None,
::core::option::Option::None,
field::FieldSet::new(FIELD_NAMES, identify_callsite!(&$cs)),
Kind::EVENT,
);
Expand Down
Loading

0 comments on commit e6dbe96

Please sign in to comment.