Skip to content

Commit

Permalink
api: move SpanKind display format impl to jaeger (#758)
Browse files Browse the repository at this point in the history
This format implementation is jaeger specific and not defined in the
otel spec.
  • Loading branch information
jtescher committed Mar 12, 2022
1 parent 45a0626 commit 2330d43
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
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

0 comments on commit 2330d43

Please sign in to comment.