Skip to content

Commit f064001

Browse files
committed
Switch from Fault to Blame
Signed-off-by: Ryan Levick <[email protected]>
1 parent 69d0738 commit f064001

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

crates/factor-key-value/src/host.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use super::{Cas, SwapError};
22
use anyhow::{Context, Result};
33
use spin_core::{async_trait, wasmtime::component::Resource};
44
use spin_resource_table::Table;
5-
use spin_telemetry::traces::{self, Fault};
5+
use spin_telemetry::traces::{self, Blame};
66
use spin_world::v2::key_value;
77
use spin_world::wasi::keyvalue as wasi_keyvalue;
88
use std::{collections::HashSet, sync::Arc};
@@ -72,7 +72,7 @@ impl KeyValueDispatch {
7272
pub fn get_store<T: 'static>(&self, store: Resource<T>) -> anyhow::Result<&Arc<dyn Store>> {
7373
let res = self.stores.get(store.rep()).context("invalid store");
7474
if let Err(err) = &res {
75-
traces::mark_as_error(err, Some(Fault::Host));
75+
traces::mark_as_error(err, Some(Blame::Host));
7676
}
7777
res
7878
}
@@ -187,11 +187,11 @@ impl key_value::HostStore for KeyValueDispatch {
187187

188188
/// Make sure that infrastructure related errors are tracked in the current span.
189189
fn track_error_on_span(err: Error) -> Error {
190-
let fault = match err {
191-
Error::NoSuchStore | Error::AccessDenied => Fault::Guest,
192-
Error::StoreTableFull | Error::Other(_) => Fault::Host,
190+
let blame = match err {
191+
Error::NoSuchStore | Error::AccessDenied => Blame::Guest,
192+
Error::StoreTableFull | Error::Other(_) => Blame::Host,
193193
};
194-
traces::mark_as_error(&err, Some(fault));
194+
traces::mark_as_error(&err, Some(blame));
195195
err
196196
}
197197

crates/factor-variables/src/host.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use spin_factors::anyhow;
2-
use spin_telemetry::traces::{self, Fault};
2+
use spin_telemetry::traces::{self, Blame};
33
use spin_world::{v1, v2::variables, wasi::config as wasi_config};
44
use tracing::instrument;
55

@@ -76,11 +76,11 @@ impl wasi_config::store::Host for InstanceState {
7676
/// Convert a `spin_expressions::Error` to a `variables::Error`, setting the current span's status and fault attribute.
7777
fn expressions_to_variables_err(err: spin_expressions::Error) -> variables::Error {
7878
use spin_expressions::Error;
79-
let fault = match err {
80-
Error::InvalidName(_) | Error::InvalidTemplate(_) | Error::Undefined(_) => Fault::Guest,
81-
Error::Provider(_) => Fault::Host,
79+
let blame = match err {
80+
Error::InvalidName(_) | Error::InvalidTemplate(_) | Error::Undefined(_) => Blame::Guest,
81+
Error::Provider(_) => Blame::Host,
8282
};
83-
traces::mark_as_error(&err, Some(fault));
83+
traces::mark_as_error(&err, Some(blame));
8484
match err {
8585
Error::InvalidName(msg) => variables::Error::InvalidName(msg),
8686
Error::Undefined(msg) => variables::Error::Undefined(msg),

crates/telemetry/src/traces.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,27 +67,27 @@ pub(crate) fn otel_tracing_layer<S: Subscriber + for<'span> LookupSpan<'span>>(
6767
///
6868
/// This can be used to filter errors in telemetry or logging systems.
6969
#[derive(Debug)]
70-
pub enum Fault {
70+
pub enum Blame {
7171
/// The error is most likely caused by the guest.
7272
Guest,
7373
/// The error might have been caused by the host.
7474
Host,
7575
}
7676

77-
impl Fault {
77+
impl Blame {
7878
fn as_str(&self) -> &'static str {
7979
match self {
80-
Fault::Guest => "guest",
81-
Fault::Host => "host",
80+
Blame::Guest => "guest",
81+
Blame::Host => "host",
8282
}
8383
}
8484
}
8585

86-
/// Marks the current span as an error with the given error message and optional fault type.
87-
pub fn mark_as_error<E: std::fmt::Display>(err: &E, fault: Option<Fault>) {
86+
/// Marks the current span as an error with the given error message and optional blame.
87+
pub fn mark_as_error<E: std::fmt::Display>(err: &E, blame: Option<Blame>) {
8888
let current_span = tracing::Span::current();
8989
current_span.set_status(opentelemetry::trace::Status::error(err.to_string()));
90-
if let Some(fault) = fault {
91-
current_span.set_attribute("error.fault", fault.as_str());
90+
if let Some(blame) = blame {
91+
current_span.set_attribute("error.blame", blame.as_str());
9292
}
9393
}

0 commit comments

Comments
 (0)