Skip to content

Commit 58602f5

Browse files
khanayan123claude
andcommitted
test: add root_session_id singleton test
Verify get_or_init returns the first runtime ID on subsequent calls with different values (first-writer-wins semantics). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 69eb64c commit 58602f5

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ add_executable(tests
1818

1919
# telemetry test cases
2020
telemetry/test_configuration.cpp
21+
telemetry/test_root_session_id.cpp
2122
telemetry/test_telemetry.cpp
2223

2324
# test cases
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include <datadog/runtime_id.h>
2+
3+
#include "../test.h"
4+
#include "root_session_id.h"
5+
6+
using namespace datadog::tracing;
7+
8+
#define ROOT_SESSION_ID_TEST(x) \
9+
TEST_CASE(x, "[telemetry],[telemetry.root_session_id]")
10+
11+
ROOT_SESSION_ID_TEST("get_or_init returns the first runtime ID") {
12+
auto first_rid = RuntimeID::generate();
13+
auto second_rid = RuntimeID::generate();
14+
15+
const auto& result1 = root_session_id::get_or_init(first_rid.string());
16+
const auto& result2 = root_session_id::get_or_init(second_rid.string());
17+
18+
CHECK(result1 == first_rid.string());
19+
CHECK(result2 == first_rid.string());
20+
CHECK(result1 == result2);
21+
}

0 commit comments

Comments
 (0)