-
Notifications
You must be signed in to change notification settings - Fork 304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HPCC-30374 Provide JTrace option to declare span start time #18130
Merged
ghalliday
merged 1 commit into
hpcc-systems:candidate-9.4.x
from
rpastrana:HPCC-30374-SpanStartTimeOverride
Dec 19, 2023
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,6 +66,7 @@ class JlibTraceTest : public CppUnit::TestFixture | |
|
||
//CPPUNIT_TEST(testJTraceJLOGExporterprintResources); | ||
//CPPUNIT_TEST(testJTraceJLOGExporterprintAttributes); | ||
CPPUNIT_TEST(manualTestsDeclaredSpanStartTime); | ||
CPPUNIT_TEST_SUITE_END(); | ||
|
||
const char * simulatedGlobalYaml = R"!!(global: | ||
|
@@ -188,6 +189,60 @@ class JlibTraceTest : public CppUnit::TestFixture | |
CPPUNIT_ASSERT_EQUAL_MESSAGE("Missing resource attribute detected", true, jtraceAsTree->hasProp("resources/telemetry.sdk.name")); | ||
}*/ | ||
|
||
//not able to programmatically test yet, but can visually inspect trace output | ||
void manualTestsDeclaredSpanStartTime() | ||
{ | ||
Owned<IProperties> emptyMockHTTPHeaders = createProperties(); | ||
SpanTimeStamp declaredSpanStartTime; | ||
declaredSpanStartTime.now(); // must be initialized via now(), or setMSTickTime | ||
MilliSleep(125); | ||
|
||
{ | ||
//duration should be at least 125 milliseconds | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since I squashed the commits, I wanted to point out these new comments and varying sleep times and also actual CPPUNIT_ASSERTs on uninitialized states. |
||
Owned<ISpan> serverSpan = queryTraceManager().createServerSpan("declaredSpanStartTime", emptyMockHTTPHeaders, &declaredSpanStartTime); | ||
//{ "type": "span", "name": "declaredSpanStartTime", "trace_id": "0a2eff24e1996540056745aaeb2f5824", "span_id": "46d0faf8b4da893e", | ||
//"start": 1702672311203213259, "duration": 125311051 } | ||
} | ||
|
||
auto reqStartMSTick = msTick(); | ||
// a good test would track chrono::system_clock::now() at the point of span creation | ||
// ensure a measurable sleep time between reqStartMSTick and msTickOffsetTimeStamp | ||
// then compare OTel reported span start timestamp to span creation-time timestamp | ||
SpanTimeStamp msTickOffsetTimeStamp; | ||
msTickOffsetTimeStamp.setMSTickTime(reqStartMSTick); | ||
//sleep for 50 milliseconds after span creation and mstick offset, expect at least 50 milliseconds duration output | ||
MilliSleep(50); | ||
|
||
{ | ||
SpanTimeStamp nowTimeStamp; //not used, printed out as "start" time for manual comparison | ||
nowTimeStamp.now(); | ||
{ | ||
Owned<ISpan> serverSpan = queryTraceManager().createServerSpan("msTickOffsetStartTime", emptyMockHTTPHeaders, &msTickOffsetTimeStamp); | ||
} | ||
|
||
DBGLOG("MsTickOffset span actual start-time timestamp: %lld", (long long)(nowTimeStamp.systemClockTime).count()); | ||
//14:49:13.776139 904 MsTickOffset span actual start-time timestamp: 1702669753775893057 | ||
//14:49:13.776082 904 { "type": "span", "name": "msTickOffsetStartTime", "trace_id": "6e89dd6082ff647daed523089f032240", "span_id": "fd359b41a0a9626d", | ||
//"start": 1702669753725771035, "duration": 50285323 } | ||
//Actual start - declared start: 1702669753775893057-1702669753725771035 = 50162022 | ||
} | ||
|
||
//uninitialized SpanTimeStamp will be ignored, and current time will be used | ||
SpanTimeStamp uninitializedTS; | ||
CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected initialized spanTimeStamp", false, uninitializedTS.isInitialized()); | ||
CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected initialized spanTimeStamp", true, uninitializedTS.systemClockTime == std::chrono::nanoseconds::zero()); | ||
CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected initialized spanTimeStamp", true, uninitializedTS.steadyClockTime == std::chrono::nanoseconds::zero()); | ||
{ | ||
Owned<ISpan> serverSpan = queryTraceManager().createServerSpan("uninitializeddeclaredSpanStartTime", emptyMockHTTPHeaders, &uninitializedTS); | ||
//sleep for 75 milliseconds after span creation, expect at least 75 milliseconds duration output | ||
MilliSleep(75); | ||
|
||
//14:22:37.865509 30396 { "type": "span", "name": "uninitializeddeclaredSpanStartTime", "trace_id": "f7844c5c09b413e008f912ded0e12dec", "span_id": "7fcf9042a090c663", | ||
//"start": 1702668157790080022, | ||
//"duration": 75316248 } | ||
} | ||
} | ||
|
||
void testTraceDisableConfig() | ||
{ | ||
Owned<IPropertyTree> testTree = createPTreeFromYAMLString(disableTracingYaml, ipt_none, ptr_ignoreWhiteSpace, nullptr); | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, this gives us two possible ways of instrumenting ESP and Roxie. Either add add SpanTimeStamp (and maybe get rid of the msStartTime that's there now, or just use the existing msStartTime with this function.