Rust first variant: for review only#2
Conversation
688ced9 to
41ca8d2
Compare
41ca8d2 to
532fb07
Compare
ivoanjo
left a comment
There was a problem hiding this comment.
This is looking good! I think the main question to me is supporting the old api as well/keeping spin.rs as-it-was.
I kinda like the idea of showing off how the old api can be layered on the new format + providing a nice migration path for users of custom-labels (we can even ask claude to give it a stab) but let me know if you're not convinced, as I'm happy to approve as-is.
What do we do with the license headers?
Do we need to do anything special to donate from libdatadog to OTel?
custom-labels, libdatadog AND opentelemetry all use Apache v2 so they're license-compatible.
My read on 1 and 2 is that it's fine to keep the current copyrights (Datadog for files that came from libdatadog, and implicitly Polar Signals for the other files) and once this moves out of WIP we can check with all parties if we should just assign the copyright to OTel directly.
There was a problem hiding this comment.
This part I think it would be very nice to keep if possible -- e.g. retrofit the existing custom-labels code to use the new APIs, rather than forcing a full API rewrite.
This would provide a really nice way of testing against existing users of custom-labels -- just switch the dep and recompile; vs requiring a full API change; spin.rs would remain exactly the same, which would be a nice demo for how the new format is able to provide the same feature-set (or very close).
There was a problem hiding this comment.
ACK ! addressed in subsequent commits as discussed offline
| // On x86-64, force TLSDESC dialect as required by the OTel spec. | ||
| // On aarch64, TLSDESC is already the default. | ||
| #[cfg(target_arch = "x86_64")] | ||
| build.flag("-mtls-dialect=gnu2"); |
There was a problem hiding this comment.
Minor: Could we use mtls-dialect=gnu2 everywhere? E.g. does arm mind if we ask for the default? I think that would simplify a bit (and is one less sharp edge if someone tries to e.g. compile this on another arch)
There was a problem hiding this comment.
nah, it fails on arm:
unrecognized argument in option '-mtls-dialect=gnu2',
valid values are desc and trad.
we can do the opposite ("add this if you're not arm") but i'm not confident that it's going to work on other arches either. Seeing as we only promise to support arm64 / amd64 this is probably fine?
There was a problem hiding this comment.
unrecognized argument in option '-mtls-dialect=gnu2',
valid values are desc and trad.
Grumble grumble why are compiler people so bad at good/sane behaviors grumble grumble.
I guess let's keep it as-is, we can figure out later what to do with other architectures...
532fb07 to
b087314
Compare
46a66f8 to
148c923
Compare
148c923 to
0c8d9df
Compare
| String::from_utf8( | ||
| rand::thread_rng() | ||
| .sample_iter(&Alphanumeric) | ||
| rand::rng() |
There was a problem hiding this comment.
because of dep update and rust's passion for prerelease crate versions
| loop { | ||
| custom_labels::with_label("l1", rand_str(), || { | ||
| custom_labels::with_label("l2", rand_str(), || loop { | ||
| otel_thread_ctx::custom_labels_adapter::with_label("l1", rand_str(), || { |
There was a problem hiding this comment.
can't do much about the namespace change; intentionally leaving the adapter "off to the side" as discussed rather than presenting a weird API
0c8d9df to
85cca8a
Compare
85cca8a to
683634d
Compare
| /// Mutate the currently attached record in-place with proper synchronization. | ||
| /// Sets `valid = 0` before calling `f`, and `valid = 1` after, with compiler | ||
| /// fences to prevent reordering. Returns `false` if no record is attached. | ||
| fn mutate_in_place(f: impl FnOnce(&mut ThreadContextRecord)) -> bool { |
There was a problem hiding this comment.
factored this out from update so we have the guards in one place and can use it for pop attr too
|
|
||
| pub fn update(_trace_id: [u8; 16], _span_id: [u8; 8], _attrs: &[(u8, &str)]) {} | ||
|
|
||
| pub fn pop_last_attr() {} |
| resource: Some(Resource::default()), | ||
| extra_attributes: vec![ | ||
| KeyValue { | ||
| key: "threadlocal.schema_version".into(), |
There was a problem hiding this comment.
add the core attributes.
fwiw i've also tested both variants are readable with our test reader for procCtx and TLS !
Update polarsignals custom-labels repo to the new TLS format.
Decisions of relevance:
Open Qs:
To see the diff against the libdd code, try this link