Skip to content

Commit 58b8306

Browse files
committed
ci: add unittest for attributes in tracing span
1 parent 6a579e0 commit 58b8306

File tree

1 file changed

+15
-2
lines changed
  • opentelemetry-appender-tracing/src

1 file changed

+15
-2
lines changed

opentelemetry-appender-tracing/src/layer.rs

+15-2
Original file line numberDiff line numberDiff line change
@@ -646,10 +646,10 @@ mod tests {
646646
let _guard = tracing::subscriber::set_default(subscriber);
647647

648648
// Act
649-
tracing::error_span!("outer-span").in_scope(|| {
649+
tracing::error_span!("outer-span", field1 = true).in_scope(|| {
650650
error!("first-event");
651651

652-
tracing::error_span!("inner-span").in_scope(|| {
652+
tracing::error_span!("inner-span", field2 = 233).in_scope(|| {
653653
error!("second-event");
654654
});
655655
});
@@ -675,6 +675,19 @@ mod tests {
675675
assert_eq!(trace_ctx1.trace_id, trace_id);
676676
assert_eq!(trace_ctx0.span_id, outer_span_id);
677677
assert_eq!(trace_ctx1.span_id, inner_span_id);
678+
679+
assert!(logs[0]
680+
.record
681+
.attributes_iter()
682+
.any(|attr| attr.0.as_str() == "field1"));
683+
assert!(logs[1]
684+
.record
685+
.attributes_iter()
686+
.all(|attr| attr.0.as_str() != "field1"));
687+
assert!(logs[1]
688+
.record
689+
.attributes_iter()
690+
.any(|attr| attr.0.as_str() == "field2"));
678691
}
679692

680693
#[test]

0 commit comments

Comments
 (0)