Skip to content

pass Datadog's internal shared tests for 128-bit trace IDs#41

Merged
dgoffredo merged 11 commits into
mainfrom
david.goffredo/128-bit-trace-id-patches
Jul 7, 2023
Merged

pass Datadog's internal shared tests for 128-bit trace IDs#41
dgoffredo merged 11 commits into
mainfrom
david.goffredo/128-bit-trace-id-patches

Conversation

@dgoffredo
Copy link
Copy Markdown
Contributor

@dgoffredo dgoffredo commented Jul 6, 2023

These are the changes necessary for dd-trace-cpp to pass applicable test cases in tests/parametric/test_128_bit_traceids.py in Datadog's internal shared tests.

See the commit messages for the correspondence with shared tests.

@dgoffredo dgoffredo requested a review from cgilmour July 6, 2023 20:26
@pr-commenter
Copy link
Copy Markdown

pr-commenter Bot commented Jul 6, 2023

Benchmarks

Benchmark execution time: 2023-07-06 22:33:12

Comparing candidate commit 7c1144c in PR branch david.goffredo/128-bit-trace-id-patches with baseline commit 0536a16 in branch main.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 1 metrics, 0 unstable metrics.

Copy link
Copy Markdown
Contributor

@cgilmour cgilmour left a comment

Choose a reason for hiding this comment

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

Marking as approved.
Maybe some more checks and tests around zero-values will be needed for other system-tests.
Do all the related tests with valid propagation styles now pass? Any of them worth adding to this repo's unit tests?

const auto seconds =
std::chrono::duration_cast<std::chrono::seconds>(since_epoch).count();
// The farthest we'll go back is the unix epoch.
const std::uint64_t unsigned_seconds = seconds < 0 ? 0 : seconds;
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.

It's not actually going to happen, but the lowest value should probably be 1, and not zero.

Copy link
Copy Markdown
Contributor Author

@dgoffredo dgoffredo Jul 7, 2023

Choose a reason for hiding this comment

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

I agree it's not going to happen. But why 1 and not 0?

My understanding of unix time is that it is the number of seconds elapsed since 00:00:00 UTC on 1 January 1970.

Hm, wait...

david@ein:~/Downloads$ python
Python 3.10.6 (main, May 29 2023, 11:10:38) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import datetime     
>>> datetime.datetime.fromtimestamp(0)
datetime.datetime(1969, 12, 31, 19, 0)

Ah, that's a time zone thing.

Anyway, the reason I have a cutoff here is to prevent the rollover to 18446744073709551615 at -1 (which is not a valid unix timestamp, but would correspond to a date over 584 trillion years in the future -- build software to last!).

Comment thread test/test_tracer.cpp
const auto high = parse_uint64(found->second, 16);
REQUIRE(high);
REQUIRE(*high == generated_id.high);
const std::uint64_t expected = std::uint64_t(flash_crash) << 32;
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'd probably compare this with a raw expected value instead of a computed one.

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.

That's a fine line and I see your point. The test is kind of circular if it just does what the implementation does.

But if I were to include the raw expected value in the test, I'd obtain it by calculating 1273171513 << 32 (which is 5468230010533838848). At that point we'd be testing that operator<<(uint64_t, int) behaves the same way for all build targets, which is meh.

@dgoffredo
Copy link
Copy Markdown
Contributor Author

Thanks for the review, Caleb.

Maybe some more checks and tests around zero-values will be needed for other system-tests.

Maybe so. I'm starting those today.

Do all the related tests with valid propagation styles now pass?

All tests in tests/parametric/test_128_bit_traceids.py pass, except those involving the single-header B3 propagation style, which we don't (yet) support.

Any of them worth adding to this repo's unit tests?

I added unit tests wherever the library's behavior departed from that expected by the shared tests. The consistent behavior is already covered by existing unit tests.

@dgoffredo dgoffredo merged commit 9b2ac56 into main Jul 7, 2023
@dgoffredo dgoffredo deleted the david.goffredo/128-bit-trace-id-patches branch July 7, 2023 18:58
cataphract pushed a commit to cataphract/dd-trace-cpp that referenced this pull request Mar 28, 2024
- Add uWSGI service for testing and as an example
- Add propagation tests for uwsgi directives
- Update example/README.md
- Ignore *.pyc
- Mention uwsgi_pass in the docs for datadog_proxy_directive

Resolves DataDog#38
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