Skip to content

Commit 2330d43

Browse files
authored
api: move SpanKind display format impl to jaeger (#758)
This format implementation is jaeger specific and not defined in the otel spec.
1 parent 45a0626 commit 2330d43

File tree

2 files changed

+11
-14
lines changed
  • opentelemetry-api/src/trace
  • opentelemetry-jaeger/src/exporter

2 files changed

+11
-14
lines changed

opentelemetry-api/src/trace/span.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use crate::{trace::SpanContext, KeyValue};
22
use std::borrow::Cow;
33
use std::error::Error;
4-
use std::fmt;
54
use std::time::SystemTime;
65

76
/// The interface for a single operation within a trace.
@@ -226,18 +225,6 @@ pub enum SpanKind {
226225
Internal,
227226
}
228227

229-
impl fmt::Display for SpanKind {
230-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
231-
match self {
232-
SpanKind::Client => write!(f, "client"),
233-
SpanKind::Server => write!(f, "server"),
234-
SpanKind::Producer => write!(f, "producer"),
235-
SpanKind::Consumer => write!(f, "consumer"),
236-
SpanKind::Internal => write!(f, "internal"),
237-
}
238-
}
239-
}
240-
241228
/// The code representation of the status of a [`Span`].
242229
///
243230
/// These values form a total order: Ok > Error > Unset. This means that setting

opentelemetry-jaeger/src/exporter/mod.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ fn build_span_tags(
764764
}
765765

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

770770
if status_code != StatusCode::Unset {
@@ -792,6 +792,16 @@ fn build_span_tags(
792792
tags
793793
}
794794

795+
fn format_span_kind(kind: SpanKind) -> &'static str {
796+
match kind {
797+
SpanKind::Client => "client",
798+
SpanKind::Server => "server",
799+
SpanKind::Producer => "producer",
800+
SpanKind::Consumer => "consumer",
801+
SpanKind::Internal => "internal",
802+
}
803+
}
804+
795805
const ERROR: &str = "error";
796806
const SPAN_KIND: &str = "span.kind";
797807
const OTEL_STATUS_CODE: &str = "otel.status_code";

0 commit comments

Comments
 (0)