Skip to content

Commit 356a453

Browse files
committed
fix: update opentelemetry version
Signed-off-by: Andrew Steurer <[email protected]>
1 parent 2ee0064 commit 356a453

File tree

14 files changed

+1579
-1435
lines changed

14 files changed

+1579
-1435
lines changed

Cargo.lock

Lines changed: 1481 additions & 1386 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ openssl = { version = "0.10" }
8181
anyhow = { workspace = true, features = ["backtrace"] }
8282
conformance = { path = "tests/conformance-tests" }
8383
conformance-tests = { workspace = true }
84-
fake-opentelemetry-collector = "0.21.1"
84+
fake-opentelemetry-collector = "0.26"
8585
hex = "0.4"
8686
http-body-util = { workspace = true }
8787
hyper = { workspace = true }
@@ -141,6 +141,9 @@ hyper-util = { version = "0.1", features = ["tokio"] }
141141
indexmap = "2"
142142
itertools = "0.14"
143143
lazy_static = "1.5"
144+
opentelemetry = "0.28"
145+
opentelemetry-otlp = "0.28"
146+
opentelemetry_sdk = "0.28"
144147
path-absolutize = "3"
145148
quote = "1"
146149
rand = "0.9"
@@ -166,6 +169,7 @@ tokio-rustls = { version = "0.26", default-features = false, features = ["loggin
166169
toml = "0.8"
167170
toml_edit = "0.22"
168171
tracing = { version = "0.1.41", features = ["log"] }
172+
tracing-opentelemetry = "0.29"
169173
url = "2"
170174
walkdir = "2"
171175
wasm-encoder = "0.235"

crates/factor-otel/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ anyhow = { workspace = true }
99
indexmap = "2.2.6"
1010
opentelemetry = { workspace = true }
1111
opentelemetry_sdk = { workspace = true }
12-
opentelemetry-otlp = { version = "0.27", features = ["http-proto", "http", "reqwest-client"] }
12+
opentelemetry-otlp = { workspace = true, features = ["http-proto", "http", "reqwest-client"] }
1313
spin-core = { path = "../core" }
1414
spin-factors = { path = "../factors" }
1515
spin-resource-table = { path = "../table" }

crates/factor-otel/src/lib.rs

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ mod host;
22

33
use std::{
44
sync::{Arc, RwLock},
5-
time::Duration,
65
};
76

87
use anyhow::bail;
@@ -13,28 +12,24 @@ use opentelemetry::{
1312
};
1413
use opentelemetry_sdk::{
1514
resource::{EnvResourceDetector, TelemetryResourceDetector},
16-
runtime::Tokio,
1715
trace::{BatchSpanProcessor, SpanProcessor},
1816
Resource,
1917
};
20-
use spin_factors::{Factor, PrepareContext, RuntimeFactors, SelfInstanceBuilder};
18+
use spin_factors::{Factor, FactorData, PrepareContext, RuntimeFactors, SelfInstanceBuilder};
2119
use spin_telemetry::{detector::SpinResourceDetector, env::OtlpProtocol};
2220
use tracing_opentelemetry::OpenTelemetrySpanExt;
2321

2422
pub struct OtelFactor {
25-
processor: Arc<BatchSpanProcessor<Tokio>>,
23+
processor: Arc<BatchSpanProcessor>,
2624
}
2725

2826
impl Factor for OtelFactor {
2927
type RuntimeConfig = ();
3028
type AppState = ();
3129
type InstanceBuilder = InstanceState;
3230

33-
fn init<T: Send + 'static>(
34-
&mut self,
35-
mut ctx: spin_factors::InitContext<T, Self>,
36-
) -> anyhow::Result<()> {
37-
ctx.link_bindings(spin_world::wasi::otel::tracing::add_to_linker)?;
31+
fn init(&mut self, ctx: &mut impl spin_factors::InitContext<Self>) -> anyhow::Result<()> {
32+
ctx.link_bindings(spin_world::wasi::otel::tracing::add_to_linker::<_, FactorData<Self>>)?;
3833
Ok(())
3934
}
4035

@@ -71,25 +66,24 @@ impl OtelFactor {
7166
.build()?,
7267
OtlpProtocol::HttpJson => bail!("http/json OTLP protocol is not supported"),
7368
};
74-
let mut processor = opentelemetry_sdk::trace::BatchSpanProcessor::builder(
75-
exporter,
76-
opentelemetry_sdk::runtime::Tokio,
77-
)
78-
.build();
69+
70+
let mut processor = opentelemetry_sdk::trace::BatchSpanProcessor::builder(exporter).build();
71+
7972
// This is a hack b/c we know the version of this crate will be the same as the version of Spin
8073
let spin_version = env!("CARGO_PKG_VERSION").to_string();
81-
processor.set_resource(&Resource::from_detectors(
82-
Duration::from_secs(5),
83-
vec![
74+
75+
let detectors: &[Box<dyn opentelemetry_sdk::resource::ResourceDetector>; 3] = &[
8476
// Set service.name from env OTEL_SERVICE_NAME > env OTEL_RESOURCE_ATTRIBUTES > spin
8577
// Set service.version from Spin metadata
8678
Box::new(SpinResourceDetector::new(spin_version)),
8779
// Sets fields from env OTEL_RESOURCE_ATTRIBUTES
8880
Box::new(EnvResourceDetector::new()),
8981
// Sets telemetry.sdk{name, language, version}
9082
Box::new(TelemetryResourceDetector),
91-
],
92-
));
83+
];
84+
85+
processor.set_resource(&Resource::builder().with_detectors(detectors).build());
86+
9387
Ok(Self {
9488
processor: Arc::new(processor),
9589
})
@@ -98,7 +92,7 @@ impl OtelFactor {
9892

9993
pub struct InstanceState {
10094
pub(crate) state: Arc<RwLock<State>>,
101-
pub(crate) processor: Arc<BatchSpanProcessor<Tokio>>,
95+
pub(crate) processor: Arc<BatchSpanProcessor>,
10296
}
10397

10498
impl SelfInstanceBuilder for InstanceState {}

crates/factor-outbound-mqtt/src/host.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use anyhow::Result;
44
use spin_core::{async_trait, wasmtime::component::Resource};
55
use spin_factor_outbound_networking::config::allowed_hosts::OutboundAllowedHosts;
66
use spin_world::v2::mqtt::{self as v2, Connection, Error, Qos};
7+
use spin_factor_otel::OtelContext;
78
use tracing::{instrument, Level};
89

910
use crate::ClientCreator;

crates/factor-outbound-mysql/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ use spin_factor_otel::OtelContext;
77
use spin_factor_outbound_networking::{
88
config::allowed_hosts::OutboundAllowedHosts, OutboundNetworkingFactor,
99
};
10-
use spin_factor_outbound_networking::{OutboundAllowedHosts, OutboundNetworkingFactor};
1110
use spin_factors::{Factor, FactorData, InitContext, RuntimeFactors, SelfInstanceBuilder};
12-
use spin_factors::{Factor, InitContext, RuntimeFactors, SelfInstanceBuilder};
1311
use spin_world::v1::mysql as v1;
1412
use spin_world::v2::mysql::{self as v2};
1513

crates/factor-outbound-redis/src/host.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use redis::{aio::MultiplexedConnection, AsyncCommands, FromRedisValue, Value};
33
use spin_core::wasmtime::component::Resource;
44
use spin_factor_outbound_networking::config::allowed_hosts::OutboundAllowedHosts;
55
use spin_factor_otel::OtelContext;
6-
use spin_factor_outbound_networking::OutboundAllowedHosts;
76
use spin_world::v1::{redis as v1, redis_types};
87
use spin_world::v2::redis::{
98
self as v2, Connection as RedisConnection, Error, RedisParameter, RedisResult,

crates/factor-sqlite/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use host::InstanceState;
99
use async_trait::async_trait;
1010
use spin_factors::{anyhow, Factor, FactorData};
1111
use spin_factor_otel::OtelContext;
12-
use spin_factors::{anyhow, Factor};
1312
use spin_locked_app::MetadataKey;
1413
use spin_world::spin::sqlite::sqlite as v3;
1514
use spin_world::v1::sqlite as v1;

crates/telemetry/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ http0 = { version = "0.2.9", package = "http" }
1010
http1 = { version = "1.0.0", package = "http" }
1111
opentelemetry = { version = "0.28", features = ["metrics", "trace", "logs"] }
1212
opentelemetry-appender-tracing = "0.28"
13-
opentelemetry-otlp = { version = "0.28", features = ["grpc-tonic"] }
14-
opentelemetry_sdk = { version = "0.28", features = ["rt-tokio", "spec_unstable_logs_enabled", "metrics"] }
13+
opentelemetry-otlp = { workspace = true, features = ["grpc-tonic"] }
14+
opentelemetry_sdk = { workspace = true, features = ["rt-tokio", "spec_unstable_logs_enabled", "metrics"] }
1515
terminal = { path = "../terminal" }
1616
tracing = { workspace = true }
17-
tracing-opentelemetry = { version = "0.29", default-features = false, features = ["metrics"] }
17+
tracing-opentelemetry = { workspace = true, default-features = false, features = ["metrics"] }
1818
tracing-subscriber = { version = "0.3", default-features = false, features = ["smallvec", "fmt", "ansi", "std", "env-filter", "json", "registry"] }
1919

2020
[features]

crates/trigger-http/src/wasi.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ impl HttpExecutor for WasiHttpExecutor<'_> {
9494
HandlerType::Wagi(_) => unreachable!("should have used WagiExecutor instead"),
9595
};
9696

97+
let span = tracing::debug_span!("execute_wasi");
9798
let handle = task::spawn(
9899
async move {
99100
let result = match handler {

0 commit comments

Comments
 (0)