Skip to content

feat: add valuable serialization support to appender-tracing #3033

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

steved
Copy link

@steved steved commented Jun 19, 2025

Fixes #2819
Design discussion issue (if applicable) N/A

Changes

Supports the valuable extension to tracing for appender-tracing. I moved the serde::Serialize extension out of appender-log into the main package in order to share it with appender-tracing, but if that's not ideal, happy to do something else.

Merge requirement checklist

  • CONTRIBUTING guidelines followed
  • Unit tests added/updated (if applicable)
  • Appropriate CHANGELOG.md files updated for non-trivial, user-facing changes
  • Changes in public API reviewed (if applicable)

@steved steved requested a review from a team as a code owner June 19, 2025 07:52
@steved steved changed the title add valuable serialization support to appender-tracing feat: add valuable serialization support to appender-tracing Jun 19, 2025
@steved steved force-pushed the steved/tracing-appender-valuable-main branch from b99a751 to bfd21ac Compare June 19, 2025 08:06
Copy link

codecov bot commented Jun 19, 2025

Codecov Report

Attention: Patch coverage is 91.72414% with 36 lines in your changes missing coverage. Please review.

Project coverage is 80.4%. Comparing base (0e3511e) to head (e4ff5a4).

Files with missing lines Patch % Lines
opentelemetry/src/logs/serde.rs 91.9% 32 Missing ⚠️
opentelemetry-appender-tracing/src/layer.rs 88.5% 4 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main   #3033     +/-   ##
=======================================
+ Coverage   80.1%   80.4%   +0.2%     
=======================================
  Files        126     127      +1     
  Lines      21949   22110    +161     
=======================================
+ Hits       17603   17782    +179     
+ Misses      4346    4328     -18     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@steved steved force-pushed the steved/tracing-appender-valuable-main branch from bfd21ac to 6b24f5b Compare June 19, 2025 08:14
@lalitb lalitb requested a review from Copilot June 23, 2025 22:02
Copy link

@Copilot Copilot AI left a comment

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 adds experimental support for valuable serialization to appender-tracing by extracting the serde::Serialize extension into the main package and updating dependencies accordingly.

  • Introduces the valuable feature support in the tracing layer.
  • Updates Cargo.toml and allowed-external-types.toml to include serde and valuable dependencies.
  • Adds a new test to verify the valuable serialization behavior.

Reviewed Changes

Copilot reviewed 9 out of 11 changed files in this pull request and generated no comments.

Show a summary per file
File Description
opentelemetry/src/logs/mod.rs Adds serde serialization support for logs using conditional compilation.
opentelemetry/allowed-external-types.toml Includes serde::ser::Serialize among allowed external types.
opentelemetry/Cargo.toml Adds serde dependency and a new "with-serde" feature.
opentelemetry-appender-tracing/src/layer.rs Implements serialization for valuable support and adds a corresponding test.
opentelemetry-appender-tracing/Cargo.toml Introduces valuable and valuable-serde dependencies and updates feature mapping.
opentelemetry-appender-tracing/CHANGELOG.md Updates changelog to document the new valuable support feature.
opentelemetry-appender-log/Cargo.toml Adjusts the with-serde feature dependencies to reference the updated serde support.
Cargo.toml Adds an unexpected_cfgs lint for tracing_unstable builds to the workspace configuration.
.cargo/config.toml Sets the rustflags to enable tracing_unstable configuration.
Comments suppressed due to low confidence (1)

opentelemetry-appender-tracing/src/layer.rs:187

  • Consider adding an inline comment here clarifying the rationale behind using the debug formatted value as a fallback when serialization fails.
            }

@steved steved force-pushed the steved/tracing-appender-valuable-main branch from 0c59e45 to 1cd7694 Compare June 28, 2025 02:06
@@ -2,6 +2,9 @@

## vNext

- [#999](https://github.com/open-telemetry/opentelemetry-rust/pull/9999) Support the [experimental `valuable` feature](https://github.com/tokio-rs/tracing/discussions/1906) in tracing.
Copy link
Contributor

Choose a reason for hiding this comment

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

Wrong PR number? maybe forget to update after open the PR?

@@ -175,6 +177,17 @@ impl<LR: LogRecord> tracing::field::Visit for EventVisitor<'_, LR> {
}
}

#[cfg(feature = "valuable")]
Copy link
Contributor

Choose a reason for hiding this comment

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

can we prefix it with experimental_ like other experimential features?

Some(value) => self.log_record.add_attribute(Key::new(field.name()), value),
None => {
self.log_record
.add_attribute(Key::new(field.name()), AnyValue::from(format!("{value:?}")));
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we want debug printout here?

}

#[derive(Debug)]
struct ValueError(String);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we also include information of which types are we trying to serialize

use valuable::Valuable;

#[derive(Clone, Debug, Valuable)]
struct User {
Copy link
Member

Choose a reason for hiding this comment

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

could you add tests with deeper nested structures? is there any limit to the depth? (Spec is still unclear on how to handle this, but want to make sure we have some limits.)

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.

OpenTelemetry-Appender-Tracing - add support for Valuable
4 participants