Skip to content

tvc: propagate Vivosuite trace context - #235

Closed
daniilrrr wants to merge 1 commit into
mainfrom
daniil/TVC-265-propagate-vivosuite-traces
Closed

daniilrrr wants to merge 1 commit into
mainfrom
daniil/TVC-265-propagate-vivosuite-traces

Conversation

@daniilrrr

@daniilrrr daniilrrr commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Propagates upstream W3C trace context onto TVC API requests.
  • Connects Vivosuite test, phase, and command spans to Coordinator request spans.
  • Uses the official OpenTelemetry propagator with bounded header inputs.
  • Fails open: missing or malformed trace context is omitted and never blocks a request.

Supports TVC-265 and tkhq/mono#7539.

@socket-security

socket-security Bot commented Aug 12, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedopentelemetry@​0.32.09810093100100
Addedopentelemetry-http@​0.32.010010093100100
Addedopentelemetry_sdk@​0.32.19410093100100

View full report

@daniilrrr
daniilrrr force-pushed the daniil/TVC-265-propagate-vivosuite-traces branch from 9034729 to 472c8f9 Compare August 12, 2026 17:33
@daniilrrr
daniilrrr marked this pull request as ready for review August 12, 2026 17:34
@daniilrrr
daniilrrr requested a review from a team as a code owner August 12, 2026 17:34
@daniilrrr
daniilrrr requested a lite review from Copilot August 12, 2026 17:35

@richardpringle richardpringle 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.

I left some comments that aren't blockers... but the more we write code like this, the more work it is to undo it. I would suggest we land this then once verified, you spend the time to unwrap some of these coupled free functions.

I can't approve yet as there's real dependency addition here

Comment thread tvc/src/client.rs
/// known-defective releases with an upgrade prompt.
const TVC_CLIENT_VERSION_HEADER: &str = "X-TVC-CLIENT-VERSION";
const TRACEPARENT_HEADER: HeaderName = HeaderName::from_static("traceparent");
const TRACESTATE_HEADER: HeaderName = HeaderName::from_static("tracestate");

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.

🥇

Comment thread tvc/src/client.rs
enum BoundedHeaderValueError {
TooLong,
Invalid,
}

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.

🥇

Comment thread tvc/src/client.rs Outdated
Comment thread tvc/src/client.rs
}
}

type TraceContextHeaderValue = BoundedHeaderValue<MAX_TRACE_CONTEXT_HEADER_LEN>;

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.

👍

Comment thread tvc/src/client.rs Outdated
Comment thread tvc/src/client.rs Outdated
Comment on lines +232 to +234
if headers
.get(TRACESTATE_HEADER)
.is_some_and(|value| value.is_empty())

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.

Make sure tracestate isn't empty before you get to this point with let tracestate = tracestate.filter(|val| !val.is_empty())

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

applied.

didn't apply in normalize_trace_context_headers() because the W3C propagator will inject a tracestate automatically for

  • No input tracestate
  • Malformed non-empty tracestate
  • Whitespace-only tracestate

which we want to avoid

Comment thread tvc/src/client.rs Outdated
Comment thread tvc/src/client.rs Outdated
Comment thread tvc/src/client.rs Outdated
Comment thread tvc/src/client.rs Outdated
Comment on lines +285 to +299
#[instrument(skip_all)]
pub(crate) fn build_turnkey_client(
stamper: TurnkeyP256ApiKey,
api_base_url: &str,
) -> Result<TurnkeyClient<TurnkeyP256ApiKey>> {
let traceparent = read_env_var(ENV_TRACEPARENT);
let tracestate = read_env_var(ENV_TRACESTATE);

build_turnkey_client_with_trace_context(
stamper,
api_base_url,
traceparent.as_deref(),
tracestate.as_deref(),
)
}

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.

Same comment as above. This is an anti-pattern and couples code.

We want to separate resource acquisition from business logic. The function should receive ready-to-use dependencies, so it will have fewer failure modes, no hidden setup or I/O, less coupling to a concrete construction method, and is easier to test and reuse. Failures also stay at the wiring boundary, where they can be handled with better context.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

updated to

pub(crate) fn build_turnkey_client(
    stamper: TurnkeyP256ApiKey,
    api_base_url: &str,
    headers: HeaderMap,
) -> Result<TurnkeyClient<TurnkeyP256ApiKey>> 

let me know if that's what you meant

@daniilrrr
daniilrrr force-pushed the daniil/TVC-265-propagate-vivosuite-traces branch from 472c8f9 to 454a932 Compare August 12, 2026 18:53
@daniilrrr
daniilrrr requested a review from a team August 12, 2026 20:37
@daniilrrr
daniilrrr force-pushed the daniil/TVC-265-propagate-vivosuite-traces branch from bfad827 to 49d50bf Compare August 12, 2026 21:43
- support `traceparent` and `tracestate` headers
- Using official OTEL propagator
@daniilrrr
daniilrrr force-pushed the daniil/TVC-265-propagate-vivosuite-traces branch from 49d50bf to 3beeac8 Compare August 12, 2026 21:46
@daniilrrr

Copy link
Copy Markdown
Contributor Author

self-blocking on merging until I resolve a discussion about how we do backend tracing and resolve tracecontext vs existing b3 propagator

@daniilrrr

Copy link
Copy Markdown
Contributor Author

@f3nry 's work removed the need for this

@daniilrrr daniilrrr closed this Oct 8, 2026
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