Skip to content

Commit e683b00

Browse files
committed
attributes: added missing RecordTypes for instrument (tokio-rs#2781)
When using a function annotated with `#[instrument]` it parses the parameters of the function and records them either using `Value` or using `std::fmt::Debug`. There were a few types that implement `Value` but were missing the RecordTypes array. Added them + a unit test for a single one. Fixed: tokio-rs#2775
1 parent a690747 commit e683b00

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

tracing-attributes/src/expand.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,10 +422,13 @@ impl RecordType {
422422
"i32",
423423
"u64",
424424
"i64",
425+
"u128",
426+
"i128",
425427
"f32",
426428
"f64",
427429
"usize",
428430
"isize",
431+
"String",
429432
"NonZeroU8",
430433
"NonZeroI8",
431434
"NonZeroU16",
@@ -434,6 +437,8 @@ impl RecordType {
434437
"NonZeroI32",
435438
"NonZeroU64",
436439
"NonZeroI64",
440+
"NonZeroU128",
441+
"NonZeroI128",
437442
"NonZeroUsize",
438443
"NonZeroIsize",
439444
"Wrapping",

tracing-attributes/tests/instrument.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ fn override_everything() {
5151
#[test]
5252
fn fields() {
5353
#[instrument(target = "my_target", level = "debug")]
54-
fn my_fn(arg1: usize, arg2: bool) {}
54+
fn my_fn(arg1: usize, arg2: bool, arg3: String) {}
5555

5656
let span = expect::span()
5757
.named("my_fn")
@@ -68,6 +68,7 @@ fn fields() {
6868
expect::field("arg1")
6969
.with_value(&2usize)
7070
.and(expect::field("arg2").with_value(&false))
71+
.and(expect::field("arg3").with_value(&"Cool".to_string()))
7172
.only(),
7273
),
7374
)
@@ -79,6 +80,7 @@ fn fields() {
7980
expect::field("arg1")
8081
.with_value(&3usize)
8182
.and(expect::field("arg2").with_value(&true))
83+
.and(expect::field("arg3").with_value(&"Still Cool".to_string()))
8284
.only(),
8385
),
8486
)
@@ -89,8 +91,8 @@ fn fields() {
8991
.run_with_handle();
9092

9193
with_default(subscriber, || {
92-
my_fn(2, false);
93-
my_fn(3, true);
94+
my_fn(2, false, "Cool".to_string());
95+
my_fn(3, true, "Still Cool".to_string());
9496
});
9597

9698
handle.assert_finished();

0 commit comments

Comments
 (0)