Skip to content

Conversation

@leiysky
Copy link
Contributor

@leiysky leiysky commented Jan 9, 2026

No description provided.

Copy link

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 implements serde Serialize and Deserialize traits for the SpanContext struct, enabling JSON and other serialization formats. The implementation leverages the existing W3C Trace Context traceparent encoding format for serialization, ensuring compatibility with distributed tracing standards.

Key Changes

  • Added Serialize implementation that encodes SpanContext as a W3C traceparent string
  • Added Deserialize implementation that decodes from a W3C traceparent string format
  • Error handling for invalid traceparent strings during deserialization

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

Comment on lines 347 to 348
impl<'a> serde::Deserialize<'a> for SpanContext {
fn deserialize<D: serde::Deserializer<'a>>(deserializer: D) -> Result<Self, D::Error> {
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

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

The lifetime parameter name 'a' is inconsistent with the conventional 'de' used in other Deserialize implementations in this file (see TraceId at line 54 and SpanId at line 119). Using 'de' (short for "deserializer") is the Rust community convention for Deserialize implementations and makes the code more consistent.

Suggested change
impl<'a> serde::Deserialize<'a> for SpanContext {
fn deserialize<D: serde::Deserializer<'a>>(deserializer: D) -> Result<Self, D::Error> {
impl<'de> serde::Deserialize<'de> for SpanContext {
fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {

Copilot uses AI. Check for mistakes.
@andylokandy andylokandy merged commit d9263df into main Jan 9, 2026
11 checks passed
@andylokandy andylokandy deleted the chore/span-context-serde branch January 9, 2026 08:34
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.

3 participants