Skip to content

feat: Make opentelemetry optional - #566

Open
popzxc wants to merge 1 commit into
google:mainfrom
popzxc:optional-otel
Open

popzxc wants to merge 1 commit into
google:mainfrom
popzxc:optional-otel

Conversation

@popzxc

@popzxc popzxc commented Sep 17, 2026

Copy link
Copy Markdown

Fixes #564

Not all projects require opentelemetry, and besides being extra code to compile, it also makes supply chain security harder (see example).

I've kept opentelemetry enabled by default so that the change is backward compatible, hope that works.

@popzxc

popzxc commented Sep 22, 2026

Copy link
Copy Markdown
Author

@tikue any chance you can look into it?

@tikue

tikue commented Sep 22, 2026

Copy link
Copy Markdown
Collaborator

Hi, thanks for the contribution! I will try to look at this in the next week or so.

@popzxc

popzxc commented Oct 12, 2026

Copy link
Copy Markdown
Author

@tikue sorry for pinging, would really appreciate if you'd find a minute to review the PR :)

@tikue tikue left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Apologies for the delay in reviewing!

runs-on: ubuntu-latest
strategy:
matrix:
opentelemetry: ["", "--no-default-features"]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should this have --features opentelemetry?

Comment thread tarpc/src/context.rs

/// An extension trait for [`tracing::Span`] for propagating tarpc Contexts.
pub(crate) trait SpanExt {
fn trace_context(&self) -> Result<trace::Context, trace::NoActiveSpan>;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please document why this method exists. AFAICT, it exists purely as a shim because TryFrom<&tracing::Span> can't be impl'd when the crate is compiled without the tracing dependency.

Comment thread tarpc/src/context.rs
/// An extension trait for [`tracing::Span`] for propagating tarpc Contexts.
pub(crate) trait SpanExt {
fn trace_context(&self) -> Result<trace::Context, trace::NoActiveSpan>;
fn deadline(&self) -> Option<Instant>;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same thing as above -- please document that this exists purely as a shim over the tracing crate, or as a stub / empty impl when the tracing dependency is not present.

Comment thread tarpc/src/context.rs
fn deadline(&self) -> Option<Instant>;
/// Sets the given context on this span. Newly-created spans will be children of the given
/// context's trace context.
fn set_context(&self, context: &Context);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Now that this can fail, please make it return a Result. It seems error prone to silently fail.

Comment thread tarpc/src/otel.rs
}
}

impl From<opentelemetry::trace::TraceId> for TraceId {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can this file be branched from trace.rs so that these lines don't appear as new?

Comment thread tarpc/src/otel.rs

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is it possible for this file to preserve the commit history of trace.rs so that the unchanged lines don't appear as new?

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.

Make opentelemetry optional

2 participants