-
Notifications
You must be signed in to change notification settings - Fork 309
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-33298 JTrace support sampling configuration #19456
HPCC-33298 JTrace support sampling configuration #19456
Conversation
Jira Issue: https://hpccsystems.atlassian.net//browse/HPCC-33298 Jirabot Action Result: |
5a8ea52
to
c56a09b
Compare
@jakesmith made some wholesale changes in order to support the parentBased sampler annotation just in case you were in the middle of reviewing |
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.
@rpastrana - looks good, some very minor comments.
system/jlib/jtrace.cpp
Outdated
if (!isEmptyString(samplerType)) | ||
{ | ||
const char * samplerArgument = samplerTree->queryProp("@argument"); | ||
if (strcmp("AlwaysOff", samplerType)==0) |
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.
trivial: could use jlib's streq
system/jlib/jtrace.cpp
Outdated
else if (strcmp("Ratio", samplerType)==0) | ||
{ | ||
size_t pos; | ||
double ratio = std::stod(samplerArgument, &pos); |
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.
const char * samplerArgument = samplerTree->queryProp("@argument");
could move to here, as only use of argument, and do:
double ratio = samplerTree->getPropReal("@argument");
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.
Agreed, it's meant to be a generic argument for future support, but in reality the ratio is likely to be the only use, will use your suggestion
system/jlib/jtrace.cpp
Outdated
|
||
if (sampler && samplerTree->getPropBool("@parentBased", true)) | ||
{ | ||
return std::unique_ptr<opentelemetry::sdk::trace::ParentBasedSampler>(new opentelemetry::sdk::trace::ParentBasedSampler( std::move(sampler))); |
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.
trivial/formatting: extra unintended space before std::move in 'ParentBasedSampler( std::move(sampler))'
system/jlib/jtrace.cpp
Outdated
if (!sampler) | ||
{ | ||
sampler = std::unique_ptr<opentelemetry::sdk::trace::AlwaysOnSampler> | ||
(new opentelemetry::sdk::trace::AlwaysOnSampler); |
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.
to be consistent, as per line 1378:
sampler.reset(new opentelemetry::sdk::trace::AlwaysOnSampler());
34965d1
to
1e85d43
Compare
system/jlib/jtrace.cpp
Outdated
@@ -768,9 +768,6 @@ class CSpan : public CInterfaceOf<ISpan> | |||
if (span == nullptr) | |||
return false; | |||
|
|||
if (!span->IsRecording()) //if not sampled, we shouldn't consider this valid? |
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.
maybe outside the scope of this issue, but found this causes a hang under certain parentbased configurations -- further analysis is needed, but removing this for now
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.
@jakesmith this amended commit includes the code review changes you requested and approved + this change
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.
@rpastrana - looks good. Please squash.
Do not merge yet, I'm not happy w/ the hang I've noticed (even if avoided by removing call to span->IsRecording |
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.
Do not merge yet, I'm not happy w/ the hang I've noticed (even if avoided by removing call to span->IsRecording
merely commenting, to keep the status of the PR on track (not pending review at this stage).
Do not merge yet, I'm not happy w/ the hang I've noticed (even if avoided by removing call to span->IsRecording
@jakesmith I've reviewed, and this is safe to merge. |
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.
@rpastrana - looks good. Please squash.
1e85d43
to
3a50375
Compare
@ghalliday ready to be merged Just noticed the conflicts (not sure how that happened), will resolve asap Conflicts were resolved |
3a50375
to
1653e52
Compare
@jakesmith in the process of rebasing due to conflicts, I noticed the sample yaml file was incorrect. Latest commit addresses that minor issue. Please review |
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.
@rpastrana - looks good afaics. Please squash.
1653e52
to
38d3a05
Compare
Squashed and ready to merge |
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.
@rpastrana a few comments - mainly regarding ensuring the configuration makes sense from a user's point of view, rather than reflecting the underlying implementation.
system/jlib/jtrace.cpp
Outdated
if (!sampler) | ||
{ | ||
sampler.reset(new opentelemetry::sdk::trace::AlwaysOnSampler()); | ||
WARNLOG("JTrace sampler set to 'Always ON' by default!"); |
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.
I am not sure we want this tracing.
This if could be deleted and covered by the default case in the caller.
system/jlib/jtrace.cpp
Outdated
double ratio = samplerTree->getPropReal("@argument"); | ||
if (ratio < 0 || ratio > 1) | ||
{ | ||
OERRLOG("JTrace invalid ratio sampler configuration. Ratio must be LE 1.0 or GE 0.0"); |
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.
picky: "Ratio must be LE 1.0 or GE 0.0"
should be "and", and symbols probably clearer
"Ratio must >= 0.0 and <= 1.0" or "between 0.0 and 1.0"
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.
really picky: For an if() statement, it is better to have the normal/expected case first. It is easier to read.
system/jlib/jtrace.cpp
Outdated
} | ||
else if (streq(samplerType,"Ratio")) | ||
{ | ||
double ratio = samplerTree->getPropReal("@argument"); |
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.
add a default value of -1, so that failing to specify a ratio is caught as a problem - rather than silently removing all items.
system/jlib/jtrace.cpp
Outdated
@@ -1468,6 +1532,10 @@ Expected Configuration format: | |||
disabled: true #optional - disable OTel tracing | |||
alwaysCreateGlobalIds : false #optional - should global ids always be created? | |||
alwaysCreateTraceIds #optional - should trace ids always be created? | |||
sampler: #optional - controls how traces are either suppressed or sampled | |||
type: #"AlwaysOff" | "AlwaysOn" | "Ratio" | |||
argument: #optional sampler type configuration value |
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.
From a user's point of view argument is very generic. ratio would be better.
You could argue this interface has been defined based on the implementation, rather than what would make sense from the user's viewpoint. I am not sure if you want to go this way, but you could remove the type field, and just rely on a ratio (or percentage) field. If it was 0 you would sample none, if 100 you would include all, otherwise you would create a ratio sampler.
system/jlib/jtrace.cpp
Outdated
sampler: #optional - controls how traces are either suppressed or sampled | ||
type: #"AlwaysOff" | "AlwaysOn" | "Ratio" | ||
argument: #optional sampler type configuration value | ||
parentBased: #optional sets the sampling decision based on the Span’s parent, or absence of parent, to know which secondary sampler to use. |
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.
What does this mean? does it mean exclude if the parent is not included in a sample? What does it mean from the user's perspective?
helm/hpcc/values.schema.json
Outdated
"description": "Name of the Head Sampling type AlwaysOff|AlwaysOn|Ratio" | ||
}, | ||
"argument" : { | ||
"type": "string", |
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.
This would naturally be a number - see comments on "argument" v "ratio" below.
helm/hpcc/values.schema.json
Outdated
@@ -1171,6 +1171,25 @@ | |||
"type": "boolean", | |||
"description": "If true, sets OTEL library logging to debug level (otherwise set to warning)" | |||
}, | |||
"sampler": { |
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.
question: Would "sampling" be more intuitive to the user?
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.
I think the usability improvement would be negligible.
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.
A good set of changes, but I think the using a generic "argument" is wrong.
I don't think there are any other examples like it in the helm chart, and it isn't immediately obvious what it means, and requires the user to specify the value using the wrong type.
5f23509
to
3f9dd92
Compare
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.
Looks good. Please squash, and a couple of things to tidy up.
helm/hpcc/values.schema.json
Outdated
"enum": ["AlwaysOff", "AlwaysOn", "Ratio"], | ||
"description": "Name of the Head Sampling type AlwaysOff|AlwaysOn|Ratio" | ||
}, | ||
"ratio" : { |
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.
trivial: indented by 2 extra
system/jlib/jtrace.cpp
Outdated
endpoint: "localhost:4317" #exporter specific key/value pairs | ||
sampling: #optional - controls how traces are either suppressed or sampled | ||
type: #"AlwaysOff" | "AlwaysOn" | "Ratio" | ||
argument: #optional - Generic argument dependent on sampling type used. |
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.
needs updating to refer to ratio instead.
3f9dd92
to
4fceee8
Compare
squashed |
- Adds Jtrace sampler configuration - Adds OTel sampler initialization logic - Updates JTrace configuration README - Provides samples - Jlog trace/span ids suppressed if not sampled (not sure if this is wanted) - Rename configuration element from sampler to sampling Signed-off-by: Rodrigo Pastrana <[email protected]>
4fceee8
to
2bc7186
Compare
b3b6ad6
into
hpcc-systems:candidate-9.8.x
Jirabot Action Result: |
Type of change:
Checklist:
Smoketest:
Testing: