Skip to content

opentelemetry: clarify otel.kind field usage in docs #1218

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

Merged
merged 1 commit into from
Jan 30, 2021
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions tracing-opentelemetry/src/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,7 @@ impl Timings {
#[cfg(test)]
mod tests {
use super::*;
use opentelemetry::trace::SpanKind;
use std::sync::{Arc, Mutex};
use std::time::SystemTime;
use tracing_subscriber::prelude::*;
Expand Down Expand Up @@ -657,7 +658,7 @@ mod tests {
let subscriber = tracing_subscriber::registry().with(layer().with_tracer(tracer.clone()));

tracing::collect::with_default(subscriber, || {
tracing::debug_span!("request", otel.kind = "Server");
tracing::debug_span!("request", otel.kind = %SpanKind::Server);
});

let recorded_kind = tracer.0.lock().unwrap().as_ref().unwrap().span_kind.clone();
Expand All @@ -679,7 +680,7 @@ mod tests {
let _g = existing_cx.attach();

tracing::collect::with_default(subscriber, || {
tracing::debug_span!("request", otel.kind = "Server");
tracing::debug_span!("request", otel.kind = %SpanKind::Server);
});

let recorded_trace_id = tracer
Expand Down
9 changes: 3 additions & 6 deletions tracing-opentelemetry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,15 @@
//! * `otel.name`: Override the span name sent to OpenTelemetry exporters.
//! Setting this field is useful if you want to display non-static information
//! in your span name.
//! * `otel.kind`: Set the span kind to one of the supported OpenTelemetry
//! [span kinds]. The value should be a string of any of the supported values:
//! `SERVER`, `CLIENT`, `PRODUCER`, `CONSUMER` or `INTERNAL`. Other values are
//! silently ignored.
//! * `otel.kind`: Set the span kind to one of the supported OpenTelemetry [span kinds].
//!
//! [span kinds]: https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/api.md#spankind
//! [span kinds]: https://docs.rs/opentelemetry/latest/opentelemetry/trace/enum.SpanKind.html
//!
//! ### 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" = "client", "http.url" = ..)`, and they
//! `trace_span!("request", "otel.kind" = %SpanKind::Client, "http.url" = ..)`, and they
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit/TIOLI: it might be worth changing this example so that it's formatted as Rust code? but we can do that later.

//! 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.
Expand Down