Skip to content

Commit 43dcddc

Browse files
committed
Bump OTel version to v0.23.0, break logging, implement a bit more observe
Signed-off-by: Caleb Schoepp <[email protected]>
1 parent 69b77c9 commit 43dcddc

File tree

7 files changed

+110
-174
lines changed

7 files changed

+110
-174
lines changed

Cargo.lock

+26-95
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,12 @@ anyhow = "1.0.75"
128128
conformance-tests = { git = "https://github.com/fermyon/conformance-tests", rev = "387b7f375df59e6254a7c29cf4a53507a9f46d32" }
129129
http-body-util = "0.1.0"
130130
hyper = { version = "1.0.0", features = ["full"] }
131-
opentelemetry = { version = "0.22.0", features = ["metrics", "trace", "logs"] }
132-
opentelemetry_sdk = { version = "0.22.1", features = ["rt-tokio", "logs_level_enabled"] }
131+
opentelemetry = { version = "0.23.0", features = ["metrics", "trace", "logs"] }
132+
opentelemetry_sdk = { version = "0.23.0", features = ["rt-tokio", "logs_level_enabled", "metrics"] }
133133
reqwest = { version = "0.12", features = ["stream", "blocking"] }
134134
test-environment = { git = "https://github.com/fermyon/conformance-tests", rev = "387b7f375df59e6254a7c29cf4a53507a9f46d32" }
135135
tracing = { version = "0.1", features = ["log"] }
136-
tracing-opentelemetry = { version = "0.23.0", default-features = false, features = ["metrics"] }
136+
tracing-opentelemetry = { version = "0.24.0", default-features = false, features = ["metrics"] }
137137

138138
wasi-common-preview1 = { version = "22.0.0", package = "wasi-common", features = [
139139
"tokio",

crates/factor-observe/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ indexmap = "2.2.6"
1313
once_cell = "1"
1414
opentelemetry = { workspace = true }
1515
opentelemetry_sdk = { workspace = true }
16-
opentelemetry-otlp = { version = "0.15.0", default-features=false, features = ["http-proto", "trace", "http", "reqwest-client", "metrics", "grpc-tonic"] }
1716
serde = "1.0.188"
1817
spin-app = { path = "../app" }
1918
spin-core = { path = "../core" }

crates/factor-observe/src/host.rs

+17-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
use std::time::Duration;
21
use std::time::SystemTime;
3-
use std::time::UNIX_EPOCH;
42

53
use anyhow::anyhow;
64
use anyhow::Result;
@@ -21,6 +19,7 @@ impl traces::Host for InstanceState {}
2119
#[async_trait]
2220
impl traces::HostSpan for InstanceState {
2321
// TODO(Caleb): Make this implicit logic make more sense (the indexmap seems wrong)
22+
// TODO(Caleb): Properly implement this
2423
async fn start(
2524
&mut self,
2625
name: String,
@@ -122,9 +121,7 @@ impl traces::HostSpan for InstanceState {
122121
.get_mut(resource.rep())
123122
{
124123
let timestamp = if let Some(timestamp) = timestamp {
125-
UNIX_EPOCH
126-
+ Duration::from_secs(timestamp.seconds)
127-
+ Duration::from_nanos(timestamp.nanoseconds as u64)
124+
timestamp.into()
128125
} else {
129126
SystemTime::now()
130127
};
@@ -148,16 +145,21 @@ impl traces::HostSpan for InstanceState {
148145
async fn add_link(
149146
&mut self,
150147
resource: Resource<traces::Span>,
151-
_link: traces::Link,
148+
link: traces::Link,
152149
) -> Result<()> {
153-
if let Some(_guest_span) = self
150+
if let Some(guest_span) = self
154151
.state
155152
.write()
156153
.unwrap()
157154
.guest_spans
158155
.get_mut(resource.rep())
159156
{
160-
todo!("update otel versions -> guest_span.inner.add_link(link.into());");
157+
guest_span.inner.add_link(
158+
// TODO(Caleb): Do I actually want to cause a trap in this case or should it be fallible?
159+
link.span_context.try_into()?,
160+
link.attributes.into_iter().map(Into::into).collect(),
161+
);
162+
Ok(())
161163
} else {
162164
Err(anyhow!("BUG: cannot find resource in table"))
163165
}
@@ -200,7 +202,7 @@ impl traces::HostSpan for InstanceState {
200202
async fn end(
201203
&mut self,
202204
resource: Resource<traces::Span>,
203-
_timestamp: Option<traces::Datetime>,
205+
timestamp: Option<traces::Datetime>,
204206
) -> Result<()> {
205207
if let Some(guest_span) = self
206208
.state
@@ -209,7 +211,11 @@ impl traces::HostSpan for InstanceState {
209211
.guest_spans
210212
.get_mut(resource.rep())
211213
{
212-
guest_span.inner.end();
214+
if let Some(timestamp) = timestamp {
215+
guest_span.inner.end_with_timestamp(timestamp.into());
216+
} else {
217+
guest_span.inner.end();
218+
}
213219
Ok(())
214220
} else {
215221
Err(anyhow!("BUG: cannot find resource in table"))
@@ -223,6 +229,6 @@ impl traces::HostSpan for InstanceState {
223229
}
224230
}
225231

226-
// TODO(Caleb): Improve debug tracing in failure cases
227232
// TODO(Caleb): Move the tests from integration.rs to here
228233
// TODO(Caleb): Write tests somewhere for all the finicky type conversion stuff
234+
// TODO(Caleb): Maybe introduce macro to reduce boilerplate of finding resource

crates/telemetry/Cargo.toml

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ edition = { workspace = true }
88
anyhow = { workspace = true }
99
http0 = { version = "0.2.9", package = "http" }
1010
http1 = { version = "1.0.0", package = "http" }
11+
once_cell = "1.19.0"
1112
opentelemetry = { workspace = true }
12-
opentelemetry-otlp = { version = "0.15.0", default-features = false, features = ["http-proto", "trace", "http", "reqwest-client", "metrics", "grpc-tonic", "logs"] }
13-
opentelemetry-semantic-conventions = "0.14.0"
1413
opentelemetry_sdk = { workspace = true }
14+
opentelemetry-otlp = { version = "0.16.0", default-features = false, features = ["http-proto", "trace", "http", "reqwest-client", "metrics", "grpc-tonic", "logs"] }
15+
opentelemetry-semantic-conventions = "0.14.0"
1516
terminal = { path = "../terminal" }
1617
tracing = { version = "0.1.37", features = ["log"] }
1718
tracing-appender = "0.2.2"

0 commit comments

Comments
 (0)