Skip to content

fix(logger): gate OTLP/syslog/tokio stack for wasm32 targets#22

Open
p0wline wants to merge 5 commits into
developfrom
fix/logger-wasm32-compat
Open

fix(logger): gate OTLP/syslog/tokio stack for wasm32 targets#22
p0wline wants to merge 5 commits into
developfrom
fix/logger-wasm32-compat

Conversation

@p0wline

@p0wline p0wline commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Problem

opentelemetry-otlp (with grpc-tonic) pulls tonictokio (with the net feature) → mio, which does not compile for wasm32-unknown-unknown. This caused cosmian_kms_client_wasm builds to fail whenever cosmian_logger was a dependency.

Fix

All OTLP, syslog, and file-appender stacks are now restricted to cfg(not(target_arch = "wasm32")):

  • Cargo.toml: OTLP/syslog deps moved to [target.'cfg(not(target_arch = "wasm32"))'.dependencies]
  • src/error.rs: OTLP error variants gated
  • src/types.rs: TelemetryGuards, LoggingGuards (with SDK fields) gated; wasm32 gets a no-op LoggingGuards stub
  • src/lib.rs: all OTLP/syslog/file-appender code gated; wasm32 gets a no-op tracing_init()

On wasm32, tracing_init() is a no-op stub — downstream code should install a wasm-compatible subscriber (e.g. tracing_wasm) if log output is needed.

Verification

cargo build -p cosmian_logger                                    # native ✓
cargo build -p cosmian_logger --target wasm32-unknown-unknown    # wasm32 ✓
cargo clippy -p cosmian_logger --all-targets -- -D warnings      # zero warnings ✓

Bumps version 0.8.00.8.1.

opentelemetry-otlp (grpc-tonic) pulls tonic -> tokio (net) -> mio,
which does not compile for wasm32-unknown-unknown.

All OTLP, syslog, and file-appender stacks are now restricted to
cfg(not(target_arch = "wasm32")). On wasm32, tracing_init() is a
no-op stub and LoggingGuards is an empty struct.

Bumps version 0.8.0 -> 0.8.1.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes wasm32-unknown-unknown build failures caused by opentelemetry-otlp (grpc-tonic → tokio/net → mio) by gating OTLP/syslog/file-appender logging functionality to non-wasm32 targets and providing no-op stubs on wasm32.

Changes:

  • Move OTLP/syslog-related dependencies under target.'cfg(not(target_arch = "wasm32"))'.dependencies to avoid pulling tokio/mio on wasm32.
  • Gate OTLP-related types/APIs and logging initialization logic to non-wasm targets, and provide a wasm32 no-op tracing_init() plus a stub LoggingGuards.
  • Bump workspace version 0.8.00.8.1 (and update Cargo.lock).

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
crate/logger/src/types.rs Adds cfg-gating for OTLP guard types and introduces a wasm32 LoggingGuards no-op stub.
crate/logger/src/lib.rs Gates OTLP/syslog/file-appender initialization to non-wasm and adds a wasm32 no-op tracing_init().
crate/logger/src/error.rs Gates OTLP-specific error variants to non-wasm targets.
crate/logger/Cargo.toml Moves OTLP/syslog deps to non-wasm target deps; adjusts dependency placement.
Cargo.toml Bumps workspace version to 0.8.1.
Cargo.lock Updates locked crate versions to 0.8.1.
Comments suppressed due to low confidence (1)

crate/logger/Cargo.toml:44

  • The tracing_example no longer has required-features, so it will be considered by --all-targets builds/lints for wasm32 even though it uses #[tokio::main] and sets TracingConfig::log_to_syslog (which is absent on wasm32 with the current cfg). This can reintroduce wasm32 build failures in CI when someone runs cargo clippy --all-targets --target wasm32-unknown-unknown. Gate the example behind a feature again (and define the feature) to keep default/wasm builds working.
[[example]]
name = "tracing_example"


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread crate/logger/src/types.rs Outdated
p0wline and others added 2 commits June 30, 2026 16:44
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
time >= 0.3.36 removed the deprecated Parseable trait used by
cookie-0.16.2 (pulled by actix-web 4.x). Pin time to 0.3.35 in
the lockfile until actix-web migrates to cookie >= 0.18.
p0wline added a commit to Cosmian/kms that referenced this pull request Jun 30, 2026
…to 0.8.1

- Integrate k8s-plugin-e2e job directly into test_all.yml alongside
  all other test types (test-nix, hsm, windows). The job is gated
  on internal PRs only (requires ghcr.io pull access).
- Remove the now-redundant standalone k8s-plugin-e2e.yml workflow.
- Bump cosmian_logger workspace dep 0.8.0 -> 0.8.1 (anticipates
  Cosmian/http_client_server#22 which gates OTLP/tonic/mio behind
  cfg(not(target_arch = "wasm32")), fixing the WASM build).
p0wline added 2 commits June 30, 2026 17:37
…e pin

time is a version-constraint-only dep (not used in code) to keep
actix-web 4.x -> cookie 0.16.2 compilable. The affected parse
functions are not called with untrusted input in this codebase.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants