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

api: move SpanKind display format impl to jaeger #758

Merged
merged 1 commit into from Mar 12, 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
13 changes: 0 additions & 13 deletions opentelemetry-api/src/trace/span.rs
@@ -1,7 +1,6 @@
use crate::{trace::SpanContext, KeyValue};
use std::borrow::Cow;
use std::error::Error;
use std::fmt;
use std::time::SystemTime;

/// The interface for a single operation within a trace.
Expand Down Expand Up @@ -226,18 +225,6 @@ pub enum SpanKind {
Internal,
}

impl fmt::Display for SpanKind {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
SpanKind::Client => write!(f, "client"),
SpanKind::Server => write!(f, "server"),
SpanKind::Producer => write!(f, "producer"),
SpanKind::Consumer => write!(f, "consumer"),
SpanKind::Internal => write!(f, "internal"),
}
}
}

/// The code representation of the status of a [`Span`].
///
/// These values form a total order: Ok > Error > Unset. This means that setting
Expand Down
12 changes: 11 additions & 1 deletion opentelemetry-jaeger/src/exporter/mod.rs
Expand Up @@ -764,7 +764,7 @@ fn build_span_tags(
}

if !user_overrides.span_kind && kind != SpanKind::Internal {
tags.push(Key::new(SPAN_KIND).string(kind.to_string()).into());
tags.push(Key::new(SPAN_KIND).string(format_span_kind(kind)).into());
}

if status_code != StatusCode::Unset {
Expand Down Expand Up @@ -792,6 +792,16 @@ fn build_span_tags(
tags
}

fn format_span_kind(kind: SpanKind) -> &'static str {
match kind {
SpanKind::Client => "client",
SpanKind::Server => "server",
SpanKind::Producer => "producer",
SpanKind::Consumer => "consumer",
SpanKind::Internal => "internal",
}
}

const ERROR: &str = "error";
const SPAN_KIND: &str = "span.kind";
const OTEL_STATUS_CODE: &str = "otel.status_code";
Expand Down