Skip to content

Commit f780d91

Browse files
authored
feat: exclude status code if unset (#382)
1 parent 8353ee2 commit f780d91

File tree

1 file changed

+10
-9
lines changed
  • opentelemetry-zipkin/src/exporter/model

1 file changed

+10
-9
lines changed

opentelemetry-zipkin/src/exporter/model/mod.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,13 @@ impl Into<annotation::Annotation> for Event {
3434
}
3535
}
3636

37-
/// Converts StatusCode to str
38-
fn from_statuscode_to_str(status_code: StatusCode) -> &'static str {
37+
/// Converts StatusCode to Option<&'static str>
38+
/// `Unset` status code is unused.
39+
fn from_statuscode_to_str(status_code: StatusCode) -> Option<&'static str> {
3940
match status_code {
40-
StatusCode::Ok => "OK",
41-
StatusCode::Unset => "UNSET",
42-
StatusCode::Error => "ERROR",
41+
StatusCode::Ok => Some("OK"),
42+
StatusCode::Unset => None,
43+
StatusCode::Error => Some("ERROR"),
4344
}
4445
}
4546

@@ -90,10 +91,10 @@ pub(crate) fn into_zipkin_span(local_endpoint: Endpoint, span_data: trace::SpanD
9091
),
9192
);
9293

93-
tags.insert(
94-
"otel.status_code".into(),
95-
from_statuscode_to_str(span_data.status_code).into(),
96-
);
94+
if let Some(status_code) = from_statuscode_to_str(span_data.status_code) {
95+
tags.insert("otel.status_code".into(), status_code.into());
96+
}
97+
9798
tags.insert("otel.status_description".into(), span_data.status_message);
9899

99100
span::Span::builder()

0 commit comments

Comments
 (0)