Skip to content

Commit

Permalink
Bump OTel version to v0.23.0, break logging, implement a bit more obs…
Browse files Browse the repository at this point in the history
…erve

Signed-off-by: Caleb Schoepp <[email protected]>
  • Loading branch information
calebschoepp committed Sep 11, 2024
1 parent 69b77c9 commit 43dcddc
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 174 deletions.
121 changes: 26 additions & 95 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,12 @@ anyhow = "1.0.75"
conformance-tests = { git = "https://github.com/fermyon/conformance-tests", rev = "387b7f375df59e6254a7c29cf4a53507a9f46d32" }
http-body-util = "0.1.0"
hyper = { version = "1.0.0", features = ["full"] }
opentelemetry = { version = "0.22.0", features = ["metrics", "trace", "logs"] }
opentelemetry_sdk = { version = "0.22.1", features = ["rt-tokio", "logs_level_enabled"] }
opentelemetry = { version = "0.23.0", features = ["metrics", "trace", "logs"] }
opentelemetry_sdk = { version = "0.23.0", features = ["rt-tokio", "logs_level_enabled", "metrics"] }
reqwest = { version = "0.12", features = ["stream", "blocking"] }
test-environment = { git = "https://github.com/fermyon/conformance-tests", rev = "387b7f375df59e6254a7c29cf4a53507a9f46d32" }
tracing = { version = "0.1", features = ["log"] }
tracing-opentelemetry = { version = "0.23.0", default-features = false, features = ["metrics"] }
tracing-opentelemetry = { version = "0.24.0", default-features = false, features = ["metrics"] }

wasi-common-preview1 = { version = "22.0.0", package = "wasi-common", features = [
"tokio",
Expand Down
1 change: 0 additions & 1 deletion crates/factor-observe/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ indexmap = "2.2.6"
once_cell = "1"
opentelemetry = { workspace = true }
opentelemetry_sdk = { workspace = true }
opentelemetry-otlp = { version = "0.15.0", default-features=false, features = ["http-proto", "trace", "http", "reqwest-client", "metrics", "grpc-tonic"] }
serde = "1.0.188"
spin-app = { path = "../app" }
spin-core = { path = "../core" }
Expand Down
28 changes: 17 additions & 11 deletions crates/factor-observe/src/host.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use std::time::Duration;
use std::time::SystemTime;
use std::time::UNIX_EPOCH;

use anyhow::anyhow;
use anyhow::Result;
Expand All @@ -21,6 +19,7 @@ impl traces::Host for InstanceState {}
#[async_trait]
impl traces::HostSpan for InstanceState {
// TODO(Caleb): Make this implicit logic make more sense (the indexmap seems wrong)
// TODO(Caleb): Properly implement this
async fn start(
&mut self,
name: String,
Expand Down Expand Up @@ -122,9 +121,7 @@ impl traces::HostSpan for InstanceState {
.get_mut(resource.rep())
{
let timestamp = if let Some(timestamp) = timestamp {
UNIX_EPOCH
+ Duration::from_secs(timestamp.seconds)
+ Duration::from_nanos(timestamp.nanoseconds as u64)
timestamp.into()
} else {
SystemTime::now()
};
Expand All @@ -148,16 +145,21 @@ impl traces::HostSpan for InstanceState {
async fn add_link(
&mut self,
resource: Resource<traces::Span>,
_link: traces::Link,
link: traces::Link,
) -> Result<()> {
if let Some(_guest_span) = self
if let Some(guest_span) = self
.state
.write()
.unwrap()
.guest_spans
.get_mut(resource.rep())
{
todo!("update otel versions -> guest_span.inner.add_link(link.into());");
guest_span.inner.add_link(
// TODO(Caleb): Do I actually want to cause a trap in this case or should it be fallible?
link.span_context.try_into()?,
link.attributes.into_iter().map(Into::into).collect(),
);
Ok(())
} else {
Err(anyhow!("BUG: cannot find resource in table"))
}
Expand Down Expand Up @@ -200,7 +202,7 @@ impl traces::HostSpan for InstanceState {
async fn end(
&mut self,
resource: Resource<traces::Span>,
_timestamp: Option<traces::Datetime>,
timestamp: Option<traces::Datetime>,
) -> Result<()> {
if let Some(guest_span) = self
.state
Expand All @@ -209,7 +211,11 @@ impl traces::HostSpan for InstanceState {
.guest_spans
.get_mut(resource.rep())
{
guest_span.inner.end();
if let Some(timestamp) = timestamp {
guest_span.inner.end_with_timestamp(timestamp.into());
} else {
guest_span.inner.end();
}
Ok(())
} else {
Err(anyhow!("BUG: cannot find resource in table"))
Expand All @@ -223,6 +229,6 @@ impl traces::HostSpan for InstanceState {
}
}

// TODO(Caleb): Improve debug tracing in failure cases
// TODO(Caleb): Move the tests from integration.rs to here
// TODO(Caleb): Write tests somewhere for all the finicky type conversion stuff
// TODO(Caleb): Maybe introduce macro to reduce boilerplate of finding resource
5 changes: 3 additions & 2 deletions crates/telemetry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ edition = { workspace = true }
anyhow = { workspace = true }
http0 = { version = "0.2.9", package = "http" }
http1 = { version = "1.0.0", package = "http" }
once_cell = "1.19.0"
opentelemetry = { workspace = true }
opentelemetry-otlp = { version = "0.15.0", default-features = false, features = ["http-proto", "trace", "http", "reqwest-client", "metrics", "grpc-tonic", "logs"] }
opentelemetry-semantic-conventions = "0.14.0"
opentelemetry_sdk = { workspace = true }
opentelemetry-otlp = { version = "0.16.0", default-features = false, features = ["http-proto", "trace", "http", "reqwest-client", "metrics", "grpc-tonic", "logs"] }
opentelemetry-semantic-conventions = "0.14.0"
terminal = { path = "../terminal" }
tracing = { version = "0.1.37", features = ["log"] }
tracing-appender = "0.2.2"
Expand Down
Loading

0 comments on commit 43dcddc

Please sign in to comment.