tracing-opentelemetry icon indicating copy to clipboard operation
tracing-opentelemetry copied to clipboard

Implement Display for SpanKind

Open ghost opened this issue 2 years ago • 2 comments

Feature Request

Motivation

The documentation has the following paragraph under 'Semantic Conventions'

OpenTelemetry defines conventional names for attributes of common operations. These names can be assigned directly as fields, e.g. trace_span!("request", "otel.kind" = %SpanKind::Client, "url.full" = ..), and they will be passed through to your configured OpenTelemetry exporter. You can find the full list of the operations and their expected field names in the semantic conventions spec.

However, that doesn't seem to actually be possible currently because SpanKind doesn't implement Display. Please let me know if I'm missing something obvious though.

Proposal

Implement Display for SpanKind according to the open telemetry semantic conventions.

Alternatives

Update docs to use hardcoded otel.kind value or alternate, instead of SpanKind directly.

ghost avatar Oct 02 '23 02:10 ghost

Just noticed that SpanKind is part of the core opentelemetry crate and not this one. I guess my question now is, is there another SpanKind that the docs are referring to? Or is there another way to get this compiling that I'm missing?

ghost avatar Oct 02 '23 02:10 ghost

You can just use strings directly, e.g. trace_span!("request", "otel.kind" = "client", "url.full" = ..). The docs should really be updated to show that usage as the otel spec doesn't define a display format for span kind.

jtescher avatar Oct 02 '23 14:10 jtescher