Skip to content

refactor!: prepare the tracing API for later tracing versions - #132

Draft
Frando wants to merge 1 commit into
Frando/opentelemetry-cratefrom
Frando/tracing-api-prep
Draft

Frando wants to merge 1 commit into
Frando/opentelemetry-cratefrom
Frando/tracing-api-prep

Conversation

@Frando

@Frando Frando commented Oct 5, 2026

Copy link
Copy Markdown
Member

Based on #129.

tracing 0.1 types are in the public API of irpc. tracing 0.2 is stalled and has no release date, so irpc 1.0 ships with tracing 0.1. This PR prepares the API so that a minor release can add support for a later tracing version under a new feature, for example tracing-02, while the current features stay unversioned.

  • WithChannels is #[non_exhaustive], so a new field, for example a tracing 0.2 span, is not a breaking change.
  • span_propagation::set_span_parent_from_remote moves to __macro_exports. Only the code of the macro calls it. With only the rpc feature, tracing is no longer in the public API.
  • The allowlist of external types moves tracing::span::Span from the 1.0 crates to the stable non-1.0 crates.

The commit message has an evaluation of how a tracing-02 feature would work, and what it would not cover.

Breaking changes

  • changed: WithChannels is #[non_exhaustive]. Other crates cannot use struct expressions, or patterns without ...
  • removed: span_propagation::set_span_parent_from_remote. The code of the macro calls it through __macro_exports.

tracing 0.1 types are in the public API of irpc. tracing 0.2 is stalled
and has no release date, so irpc 1.0 ships with tracing 0.1. This PR
prepares the API so that a minor release can add support for a later
tracing version under a new feature, for example `tracing-02`, while the
current features stay unversioned.

* `WithChannels` is `#[non_exhaustive]`, so a new field, for example a
  tracing 0.2 span, is not a breaking change. The `From` impls create it,
  and all patterns in this repo already use `..`.
* `span_propagation::set_span_parent_from_remote` moves to
  `__macro_exports`. Only the code of the macro calls it. With only the
  `rpc` feature, tracing is no longer in the public API.
* The allowlist of external types moves `tracing::span::Span` from the
  1.0 crates to the stable non-1.0 crates.

## How a `tracing-02` feature would work

tracing 0.1 stays in the API in these places:

* `WithChannels::span` and `parent_span_opt`, with `spans`: `tracing-02`
  adds a field with a tracing 0.2 span and an accessor. The `From` impls
  fill each field from the current span of its tracing version, so both
  features can be enabled at once.
* The macro: the generated code only names items in `__macro_exports`,
  which can route by the features of irpc. But the macro does not know
  these features, and the generated `parent_span()` returns a tracing 0.1
  span in the API of the crate that uses the macro. tracing 0.2 spans in
  generated code need an opt-in argument, for example
  `rpc_requests(tracing_02)`, and new method names.
* `span_propagation::Propagator` takes a tracing 0.1 span. tracing 0.2
  needs a second trait and `layer` function under the new feature. The
  wire format does not depend on tracing and stays.
* A `tracing-subscriber` 0.4 on tracing 0.1 only needs a second `layer`
  function under a feature like `tracing-subscriber-04`. `Propagator`
  stays.

Limits:

* The default features keep tracing 0.1 for all of 1.x.
* irpc logs its own events with tracing 0.1. A subscriber of tracing 0.2
  does not see them, unless tracing 0.2 forwards events from 0.1. This is
  not part of the API.

## Breaking changes

* changed: `WithChannels` is `#[non_exhaustive]`. Other crates cannot use struct expressions, or patterns without `..`.
* removed: `span_propagation::set_span_parent_from_remote`. The code of the macro calls it through `__macro_exports`.
@Frando
Frando marked this pull request as draft October 5, 2026 15:20
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.

1 participant