Skip to content

Commit 651b1e2

Browse files
asteurercalebschoepp
authored andcommitted
fix: update opentelemetry version
Signed-off-by: Andrew Steurer <[email protected]>
1 parent ba3ffb9 commit 651b1e2

File tree

13 files changed

+98
-49
lines changed

13 files changed

+98
-49
lines changed

Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ openssl = { version = "0.10" }
8383
anyhow = { workspace = true, features = ["backtrace"] }
8484
conformance = { path = "tests/conformance-tests" }
8585
conformance-tests = { workspace = true }
86-
fake-opentelemetry-collector = "0.21.1"
86+
fake-opentelemetry-collector = "0.26"
8787
hex = "0.4"
8888
http-body-util = { workspace = true }
8989
hyper = { workspace = true }
@@ -143,6 +143,9 @@ hyper-util = { version = "0.1", features = ["tokio"] }
143143
indexmap = "2"
144144
itertools = "0.14"
145145
lazy_static = "1.5"
146+
opentelemetry = "0.28"
147+
opentelemetry-otlp = "0.28"
148+
opentelemetry_sdk = "0.28"
146149
path-absolutize = "3"
147150
quote = "1"
148151
rand = "0.9"
@@ -169,6 +172,7 @@ toml = "0.8"
169172
toml_edit = "0.22"
170173
tower-service = "0.3.3"
171174
tracing = { version = "0.1.41", features = ["log"] }
175+
tracing-opentelemetry = "0.29"
172176
url = "2"
173177
walkdir = "2"
174178
wasm-encoder = "0.236.1"

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
@@ -93,6 +93,7 @@ impl HttpExecutor for WasiHttpExecutor<'_> {
9393
HandlerType::Wagi(_) => unreachable!("should have used WagiExecutor instead"),
9494
};
9595

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

crates/world/src/conversions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ mod otel {
562562
use wasi::clocks0_2_0::wall_clock;
563563
use wasi::otel::tracing as wasi_otel;
564564

565-
impl From<wasi_otel::SpanData> for opentelemetry_sdk::export::trace::SpanData {
565+
impl From<wasi_otel::SpanData> for opentelemetry_sdk::trace::SpanData {
566566
fn from(value: wasi_otel::SpanData) -> Self {
567567
let mut span_events = SpanEvents::default();
568568
span_events.events = value.events.into_iter().map(Into::into).collect();

0 commit comments

Comments
 (0)