-
Notifications
You must be signed in to change notification settings - Fork 289
WASI OTel #3346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
WASI OTel #3346
Conversation
Signed-off-by: Caleb Schoepp <caleb.schoepp@fermyon.com> fix: update opentelemetry version Signed-off-by: Andrew Steurer <94206073+asteurer@users.noreply.github.com> Fix out of date Cargo.lock from bad rebase Signed-off-by: Caleb Schoepp <caleb.schoepp@fermyon.com> feat(factor-otel): adding metrics Signed-off-by: Andrew Steurer <94206073+asteurer@users.noreply.github.com> feat(factor-otel): refactoring otel conversions Signed-off-by: Andrew Steurer <94206073+asteurer@users.noreply.github.com> fix(telemetry): update BatchLogProcessor to be async Signed-off-by: Andrew Steurer <94206073+asteurer@users.noreply.github.com> feat(factor-otel): refactoring WIT and updating conversions Signed-off-by: Andrew Steurer <94206073+asteurer@users.noreply.github.com> fix(factor-otel): updating WIT Signed-off-by: Andrew Steurer <94206073+asteurer@users.noreply.github.com> feat(factor-otel): updating WIT and conversions Signed-off-by: Andrew Steurer <94206073+asteurer@users.noreply.github.com> feat(factor-otel): small refactors Signed-off-by: Andrew Steurer <94206073+asteurer@users.noreply.github.com> fix(factor-otel): rebasing wasi-otel branch on main Signed-off-by: Andrew Steurer <94206073+asteurer@users.noreply.github.com>
|
@lann I think you would likely be the most relevant reviewer for this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was mostly just a shallow pass here with a few surface-level comments.
Looking at how this code is working, I think there may be a viable approach that wouldn't require changes to the outbound factors. I only have a minute right now but briefly:
- Use a task-local to manage state through the host-guest-host burger
- Use an otel span processor that uses that task-local to conditionally reparent spans
| pub(crate) state: Option<Arc<RwLock<State>>>, | ||
| } | ||
|
|
||
| impl OtelContext { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is already https://docs.rs/opentelemetry/latest/opentelemetry/context/struct.Context.html; maybe OtelState or OtelFactorState or SpinOtel or something?
| /// | ||
| /// Note that this is overridden if OTEL_SDK_DISABLED is set and not empty. | ||
| pub(crate) fn otel_tracing_enabled() -> bool { | ||
| pub fn otel_tracing_enabled() -> bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It isn't immediately obvious why these visibility changes are necessary?
| .span_id | ||
| .as_bytes() | ||
| .try_into() | ||
| .expect("Span ID is longer than 8 bytes"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this expect (and the one below) actually impossible?
| HandlerType::Wagi(_) => unreachable!("should have used WagiExecutor instead"), | ||
| }; | ||
|
|
||
| let span = tracing::debug_span!("execute_wasi"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this intentional here?
| } | ||
| } | ||
|
|
||
| mod otel { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My immediate hot take is that we should break this out into a separate wasi-otel crate. We've been discussing removing this spin-world crate entirely and I think these conversion impls are a good example of why we'd rather split up these import bindings.
Overview
This is an implementation of WASI OTel which gives guest applications the ability to export traces and metrics (and eventually logs) with OpenTelemetry SDKs.
We see two options for adding this to Spin:
To help ease adoption, we would prefer to pass a flag to spin up, but we know there was some previous work around this with WASI P3 so we're happy to defer to that process.
Some additional notes:
Cargo.toml, you will notice that certain experimental features are being enabled for theopentelemetry-sdkdependency, and that we are usingreqwest-clientinstead ofreqwest-blocking-clientin theopentelemetrydependency. These are all to prevent runtime errors that come from the default OpenTelemetry dependency configurations conflicting with Spin's async runtime.wasi-otelis a phase 0 proposal but we are presenting it to the WASI subgroup this month in the hopes of moving it to phase 1.Usage
To try the features added in this PR, do the following: