Skip to content

Commit

Permalink
merge: #1295
Browse files Browse the repository at this point in the history
1295: build(deps): update Rust dependencies (2022-W39) r=fnichol a=fnichol

Some notable changes:

- Upgrade to latest tracing/openteletetry dependencies:
  - opentelemetry 0.18.0
  - opentelemetry-otlp 0.11.0
  - opentelemetry-semantic-conventions 0.10.0
  - tracing-opentelemetry 0.18.0
- Due to updates in opentelemetry-api dropping some Display trait
  implementations some changes had to be made to preserve the string
  representations (in one case static strings is used, and in another
  case a wrapping unit type is used to ship a similar Display impl)
- The `protoc` (i.e. Protobuf compiler) is now required on build/ci/development
  systems due to updates with the tonic Rust crate

References: open-telemetry/opentelemetry-rust#758
References: tokio-rs/tracing#1218

Co-authored-by: Fletcher Nichol <fletcher@systeminit.com>
  • Loading branch information
si-bors-ng[bot] and fnichol committed Sep 21, 2022
2 parents fa08f34 + 55641ba commit 42dec07
Show file tree
Hide file tree
Showing 12 changed files with 285 additions and 184 deletions.
305 changes: 171 additions & 134 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bin/pinga/Dockerfile
Expand Up @@ -8,7 +8,7 @@ FROM rust:$RUST_VERSION as cache
ARG RUST_VERSION
ARG BIN=pinga

RUN apt-get update && apt-get install -y lld
RUN apt-get update && apt-get install -y lld protobuf-compiler
WORKDIR /usr/src
COPY . .

Expand Down
2 changes: 1 addition & 1 deletion bin/sdf/Dockerfile
Expand Up @@ -8,7 +8,7 @@ FROM rust:$RUST_VERSION as cache
ARG RUST_VERSION
ARG BIN=sdf

RUN apt-get update && apt-get install -y lld
RUN apt-get update && apt-get install -y lld protobuf-compiler
WORKDIR /usr/src
COPY . .

Expand Down
2 changes: 1 addition & 1 deletion bin/veritech/Dockerfile
Expand Up @@ -11,7 +11,7 @@ FROM rust:$RUST_VERSION as cache
ARG RUST_VERSION
ARG BIN=veritech

RUN apt-get update && apt-get install -y lld
RUN apt-get update && apt-get install -y lld protobuf-compiler
WORKDIR /usr/src
COPY . .

Expand Down
4 changes: 2 additions & 2 deletions lib/dal/src/func/backend.rs
Expand Up @@ -195,7 +195,7 @@ pub trait FuncDispatch: std::fmt::Debug {
skip_all,
level = "debug",
fields(
otel.kind = % SpanKind::Client,
otel.kind = %FormattedSpanKind(SpanKind::Client),
otel.status_code = Empty,
otel.status_message = Empty,
si.func.result = Empty
Expand Down Expand Up @@ -260,7 +260,7 @@ pub trait FuncBackend {
skip_all,
level = "debug",
fields(
otel.kind = % SpanKind::Client,
otel.kind = %FormattedSpanKind(SpanKind::Client),
otel.status_code = Empty,
otel.status_message = Empty,
si.func.result = Empty
Expand Down
28 changes: 14 additions & 14 deletions lib/si-data/src/nats.rs
Expand Up @@ -112,7 +112,7 @@ impl Client {
messaging.system = Empty,
messaging.url = Empty,
net.transport = Empty,
otel.kind = %SpanKind::Client,
otel.kind = %FormattedSpanKind(SpanKind::Client),
otel.status_code = Empty,
otel.status_message = Empty,
)
Expand Down Expand Up @@ -176,7 +176,7 @@ impl Client {
messaging.url = %self.metadata.messaging_url,
messaging.subject = Empty,
net.transport = %self.metadata.net_transport,
otel.kind = %SpanKind::Client,
otel.kind = %FormattedSpanKind(SpanKind::Client),
otel.name = Empty,
otel.status_code = Empty,
otel.status_message = Empty,
Expand Down Expand Up @@ -222,7 +222,7 @@ impl Client {
messaging.system = %self.metadata.messaging_system,
messaging.url = %self.metadata.messaging_url,
net.transport = %self.metadata.net_transport,
otel.kind = %SpanKind::Client,
otel.kind = %FormattedSpanKind(SpanKind::Client),
otel.name = Empty,
otel.status_code = Empty,
otel.status_message = Empty,
Expand Down Expand Up @@ -289,7 +289,7 @@ impl Client {
messaging.system = %self.metadata.messaging_system,
messaging.url = %self.metadata.messaging_url,
net.transport = %self.metadata.net_transport,
otel.kind = %SpanKind::Producer,
otel.kind = %FormattedSpanKind(SpanKind::Producer),
otel.name = Empty,
otel.status_code = Empty,
otel.status_message = Empty,
Expand Down Expand Up @@ -359,7 +359,7 @@ impl Client {
messaging.system = %self.metadata.messaging_system,
messaging.url = %self.metadata.messaging_url,
net.transport = %self.metadata.net_transport,
otel.kind = %SpanKind::Client,
otel.kind = %FormattedSpanKind(SpanKind::Client),
otel.name = Empty,
otel.status_code = Empty,
otel.status_message = Empty,
Expand Down Expand Up @@ -413,7 +413,7 @@ impl Client {
messaging.system = %self.metadata.messaging_system,
messaging.url = %self.metadata.messaging_url,
net.transport = %self.metadata.net_transport,
otel.kind = %SpanKind::Client,
otel.kind = %FormattedSpanKind(SpanKind::Client),
otel.name = Empty,
otel.status_code = Empty,
otel.status_message = Empty,
Expand Down Expand Up @@ -465,7 +465,7 @@ impl Client {
messaging.system = %self.metadata.messaging_system,
messaging.url = %self.metadata.messaging_url,
net.transport = %self.metadata.net_transport,
otel.kind = %SpanKind::Client,
otel.kind = %FormattedSpanKind(SpanKind::Client),
otel.name = Empty,
otel.status_code = Empty,
otel.status_message = Empty,
Expand Down Expand Up @@ -501,7 +501,7 @@ impl Client {
messaging.system = %self.metadata.messaging_system,
messaging.url = %self.metadata.messaging_url,
net.transport = %self.metadata.net_transport,
otel.kind = %SpanKind::Client,
otel.kind = %FormattedSpanKind(SpanKind::Client),
otel.name = %format!("{} receive", &sub_span_subject),
otel.status_code = Empty,
otel.status_message = Empty,
Expand Down Expand Up @@ -540,7 +540,7 @@ impl Client {
messaging.system = %self.metadata.messaging_system,
messaging.url = %self.metadata.messaging_url,
net.transport = %self.metadata.net_transport,
otel.kind = %SpanKind::Client,
otel.kind = %FormattedSpanKind(SpanKind::Client),
otel.status_code = Empty,
otel.status_message = Empty,
)
Expand Down Expand Up @@ -581,7 +581,7 @@ impl Client {
messaging.system = %self.metadata.messaging_system,
messaging.url = %self.metadata.messaging_url,
net.transport = %self.metadata.net_transport,
otel.kind = %SpanKind::Client,
otel.kind = %FormattedSpanKind(SpanKind::Client),
otel.status_code = Empty,
otel.status_message = Empty,
)
Expand Down Expand Up @@ -622,7 +622,7 @@ impl Client {
messaging.system = %self.metadata.messaging_system,
messaging.url = %self.metadata.messaging_url,
net.transport = %self.metadata.net_transport,
otel.kind = %SpanKind::Client,
otel.kind = %FormattedSpanKind(SpanKind::Client),
otel.status_code = Empty,
otel.status_message = Empty,
)
Expand Down Expand Up @@ -661,7 +661,7 @@ impl Client {
messaging.system = %self.metadata.messaging_system,
messaging.url = %self.metadata.messaging_url,
net.transport = %self.metadata.net_transport,
otel.kind = %SpanKind::Client,
otel.kind = %FormattedSpanKind(SpanKind::Client),
otel.status_code = Empty,
otel.status_message = Empty,
)
Expand Down Expand Up @@ -746,7 +746,7 @@ impl Client {
messaging.system = %self.metadata.messaging_system,
messaging.url = %self.metadata.messaging_url,
net.transport = %self.metadata.net_transport,
otel.kind = %SpanKind::Client,
otel.kind = %FormattedSpanKind(SpanKind::Client),
otel.status_code = Empty,
otel.status_message = Empty,
)
Expand Down Expand Up @@ -799,7 +799,7 @@ impl Client {
messaging.system = %self.metadata.messaging_system,
messaging.url = %self.metadata.messaging_url,
net.transport = %self.metadata.net_transport,
otel.kind = %SpanKind::Producer,
otel.kind = %FormattedSpanKind(SpanKind::Producer),
otel.name = Empty,
otel.status_code = Empty,
otel.status_message = Empty,
Expand Down
8 changes: 4 additions & 4 deletions lib/si-data/src/nats/message.rs
Expand Up @@ -69,7 +69,7 @@ impl Message {
messaging.system = %self.metadata.messaging_system,
messaging.url = %self.metadata.messaging_url,
net.transport = %self.metadata.net_transport,
otel.kind = %SpanKind::Producer,
otel.kind = %FormattedSpanKind(SpanKind::Producer),
otel.name = Empty,
otel.status_code = Empty,
otel.status_message = Empty,
Expand Down Expand Up @@ -112,7 +112,7 @@ impl Message {
messaging.system = %self.metadata.messaging_system,
messaging.url = %self.metadata.messaging_url,
net.transport = %self.metadata.net_transport,
otel.kind = %SpanKind::Producer,
otel.kind = %FormattedSpanKind(SpanKind::Producer),
otel.name = Empty,
otel.status_code = Empty,
otel.status_message = Empty,
Expand Down Expand Up @@ -153,7 +153,7 @@ impl Message {
messaging.system = %self.metadata.messaging_system,
messaging.url = %self.metadata.messaging_url,
net.transport = %self.metadata.net_transport,
otel.kind = %SpanKind::Producer,
otel.kind = %FormattedSpanKind(SpanKind::Producer),
otel.name = Empty,
otel.status_code = Empty,
otel.status_message = Empty,
Expand Down Expand Up @@ -195,7 +195,7 @@ impl Message {
messaging.system = %self.metadata.messaging_system,
messaging.url = %self.metadata.messaging_url,
net.transport = %self.metadata.net_transport,
otel.kind = %SpanKind::Producer,
otel.kind = %FormattedSpanKind(SpanKind::Producer),
otel.name = Empty,
otel.status_code = Empty,
otel.status_message = Empty,
Expand Down
8 changes: 4 additions & 4 deletions lib/si-data/src/nats/subscription.rs
Expand Up @@ -48,7 +48,7 @@ impl Subscription {
messaging_destination_kind: "topic",
messaging_operation: "process",
messaging_subject: subject.clone(),
process_otel_kind: SpanKind::Consumer.to_string(),
process_otel_kind: FormattedSpanKind(SpanKind::Consumer).to_string(),
process_otel_name: format!("{} process", subject),
};

Expand Down Expand Up @@ -85,7 +85,7 @@ impl Subscription {
messaging.system = %self.metadata.messaging_system(),
messaging.url = %self.metadata.messaging_url(),
net.transport = %self.metadata.net_transport(),
otel.kind = %SpanKind::Client,
otel.kind = %FormattedSpanKind(SpanKind::Client),
otel.status_code = Empty,
otel.status_message = Empty,
)
Expand Down Expand Up @@ -126,7 +126,7 @@ impl Subscription {
messaging.system = %self.metadata.messaging_system(),
messaging.url = %self.metadata.messaging_url(),
net.transport = %self.metadata.net_transport(),
otel.kind = %SpanKind::Client,
otel.kind = %FormattedSpanKind(SpanKind::Client),
otel.status_code = Empty,
otel.status_message = Empty,
)
Expand Down Expand Up @@ -184,7 +184,7 @@ impl Subscription {
messaging.system = %self.metadata.messaging_system(),
messaging.url = %self.metadata.messaging_url(),
net.transport = %self.metadata.net_transport(),
otel.kind = %SpanKind::Client,
otel.kind = %FormattedSpanKind(SpanKind::Client),
otel.status_code = Empty,
otel.status_message = Empty,
)
Expand Down
10 changes: 5 additions & 5 deletions lib/telemetry-rs/Cargo.toml
Expand Up @@ -22,17 +22,17 @@ library = [
]

[dependencies]
opentelemetry = { version = "0.17.0", features = ["rt-tokio", "trace"] }
opentelemetry = { version = "0.18.0", features = ["rt-tokio", "trace"] }
thiserror = { version = "1.0" }
tokio = { version = "1.12.0", features = ["rt", "sync"] }
tokio = { version = "1.12.0", features = ["rt", "signal", "sync"] }
tracing = { version = "0.1" }

# library only
async-trait = { version = "0.1.51", optional = true }

# application only
derive_builder = { version = "0.11.2", optional = true }
opentelemetry-otlp = { version = "0.10.0", optional = true }
opentelemetry-semantic-conventions = { version = "0.9.0", optional = true }
tracing-opentelemetry = { version = "0.17.2", optional = true }
opentelemetry-otlp = { version = "0.11.0", optional = true }
opentelemetry-semantic-conventions = { version = "0.10.0", optional = true }
tracing-opentelemetry = { version = "0.18.0", optional = true }
tracing-subscriber = { version = "0.3.11", optional = true, features = ['env-filter', 'std'] }
28 changes: 18 additions & 10 deletions lib/telemetry-rs/src/library.rs
@@ -1,4 +1,4 @@
use std::{borrow::Cow, env, result::Result};
use std::{borrow::Cow, env, fmt, result::Result};

use async_trait::async_trait;
use thiserror::Error;
Expand All @@ -7,13 +7,27 @@ use tokio::sync::mpsc;
pub use opentelemetry::trace::SpanKind;

pub mod prelude {
pub use super::{SpanExt, SpanKind};
pub use super::{FormattedSpanKind, SpanExt, SpanKind};
pub use tracing::{
self, debug, debug_span, error, event, field::Empty, info, info_span, instrument, span,
trace, trace_span, warn, Instrument, Level, Span,
};
}

pub struct FormattedSpanKind(pub SpanKind);

impl fmt::Display for FormattedSpanKind {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self.0 {
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"),
}
}
}

pub trait SpanExt {
fn record_ok(&self);
fn record_err<E>(&self, err: E) -> E
Expand All @@ -23,20 +37,14 @@ pub trait SpanExt {

impl SpanExt for tracing::Span {
fn record_ok(&self) {
self.record(
"otel.status_code",
&opentelemetry::trace::StatusCode::Ok.as_str(),
);
self.record("otel.status_code", "OK");
}

fn record_err<E>(&self, err: E) -> E
where
E: std::error::Error,
{
self.record(
"otel.status_code",
&opentelemetry::trace::StatusCode::Error.as_str(),
);
self.record("otel.status_code", "ERROR");
self.record("otel.status_message", &err.to_string().as_str());
err
}
Expand Down
2 changes: 1 addition & 1 deletion mk/rust.mk
Expand Up @@ -25,7 +25,7 @@ default--check-lint:
## check-doc: Checks all documentation for the Rust crate
default--check-doc:
$(call header,$@)
env RUSTDOCFLAGS="-Dwarnings" cargo doc --all
env RUSTDOCFLAGS="-Dwarnings" cargo doc --all-features --no-deps
.PHONY: default--check-doc

## check-format: Checks all code formatting for the Rust crate
Expand Down

0 comments on commit 42dec07

Please sign in to comment.