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

Remove StatusCode::as_str #741

Merged
merged 1 commit into from Feb 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 0 additions & 11 deletions opentelemetry-api/src/trace/span.rs
Expand Up @@ -260,14 +260,3 @@ pub enum StatusCode {
/// The operation contains an error.
Error,
}

impl StatusCode {
/// Return a static str that represent the status code
pub fn as_str(&self) -> &'static str {
match self {
StatusCode::Unset => "",
StatusCode::Ok => "OK",
StatusCode::Error => "ERROR",
}
}
}
14 changes: 7 additions & 7 deletions opentelemetry-jaeger/src/exporter/mod.rs
Expand Up @@ -773,11 +773,11 @@ fn build_span_tags(
tags.push(Key::new(ERROR).bool(true).into());
}
if !user_overrides.status_code {
tags.push(
Key::new(OTEL_STATUS_CODE)
.string::<&'static str>(status_code.as_str())
.into(),
);
if status_code == StatusCode::Ok {
tags.push(KeyValue::new(OTEL_STATUS_CODE, "OK").into());
} else if status_code == StatusCode::Error {
tags.push(KeyValue::new(OTEL_STATUS_CODE, "ERROR").into());
}
}
// set status message if there is one
if !status_description.is_empty() && !user_overrides.status_description {
Expand Down Expand Up @@ -1057,7 +1057,7 @@ mod tests {
let user_status_description = "Something bad happened";
attributes.insert(KeyValue::new("error", user_error));
attributes.insert(KeyValue::new(SPAN_KIND, user_kind));
attributes.insert(KeyValue::new(OTEL_STATUS_CODE, user_status_code.as_str()));
attributes.insert(KeyValue::new(OTEL_STATUS_CODE, "ERROR"));
attributes.insert(KeyValue::new(
OTEL_STATUS_DESCRIPTION,
user_status_description,
Expand All @@ -1075,7 +1075,7 @@ mod tests {
.filter(|tag| tag.key.as_str() == "error")
.all(|tag| tag.v_bool.unwrap()));
assert_tag_contains(tags.clone(), SPAN_KIND, user_kind);
assert_tag_contains(tags.clone(), OTEL_STATUS_CODE, user_status_code.as_str());
assert_tag_contains(tags.clone(), OTEL_STATUS_CODE, "ERROR");
assert_tag_contains(tags, OTEL_STATUS_DESCRIPTION, user_status_description);
}

Expand Down