Skip to content

Commit 35c8de9

Browse files
committed
HPCC-33298 Code review
- Rename configuration element from sampler to sampling - Update documentation, and samples with new config element name - Reversed conditional flow order - Updated error message - Removed duplicate default sampler creation - Updated developer comments Signed-off-by: Rodrigo Pastrana <[email protected]>
1 parent 38d3a05 commit 35c8de9

File tree

5 files changed

+23
-26
lines changed

5 files changed

+23
-26
lines changed

helm/examples/tracing/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ All configuration options detailed here are part of the HPCC Systems Helm chart,
1313
- optAlwaysCreateTraceIds - If true components generate trace/span ids if none are provided by the remote caller.
1414
- enableDefaultLogExporter - If true, creates a trace exporter outputting to the log using the default options
1515
- enableOTELDebugLogging - If true, OTel library logging level set to debug, otherwise warning
16-
- sampler - Defines head sampling strategy. Decision to sample or drop a span or trace is not made by inspecting the trace as a whole. https://opentelemetry.io/docs/concepts/sampling/
16+
- sampling - Defines head sampling strategy. Decision to sample or drop a span or trace is not made by inspecting the trace as a whole. https://opentelemetry.io/docs/concepts/sampling/
1717
- type "AlwaysOff" | "AlwaysOn" | "Ratio"
18-
- argument - Optional sampler type configuration value. Currently, only supported value applies to the "Ratio" sampler type. The argument value is a string representing a numeric value betwen 0.0 and 1.0. This value represents the ratio of trace/spans to sample
19-
- parentBased - Optional boolean. Determines if the sampler policy honors the remote root span sampled flag
18+
- argument - Optional sampling type configuration value. Currently, only supported value applies to the "Ratio" sampling type. The argument value is a string representing a numeric value betwen 0.0 and 1.0. This value represents the ratio of trace/spans to sample
19+
- parentBased - Optional boolean. Determines if the sampling policy honors the remote root span sampled flag
2020
- resourceAttributes: - Defines OTel specific resource attribute configuration values
2121
which are appended to the runtime OTEL_RESOURCE_ATTRIBUTES. See OTel doc: https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/#general-sdk-configuration
2222
- deploymentEnvironment - Defines deployment.environment, which is used to specify

helm/examples/tracing/baremetal-otlp-http-localhost-sample.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<exporters consoleDebug="true" endpoint="http://localhost:4318/v1/traces" type="OTLP-HTTP">
66
<batch enabled="false" maxQueueSize="4095" scheduledDelayMillis="6001" maxExportBatchSize="511"/>
77
</exporters>
8-
<sampler type="Ratio" argument="0.1" parentBased="true"/>
8+
<sampling type="Ratio" argument="0.1" parentBased="true"/>
99
</tracing>
1010
</Software>
1111
</Environment>

helm/examples/tracing/otlp-http-collector-default-sampled.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
global:
22
tracing:
3-
sampler:
3+
sampling:
44
type: Ratio #Head sampling based on simple ratio
55
argument: "0.1" #only sample 10% of traces/spans
66
parentBased: true #Sampling strategy based on parent's sampling

helm/hpcc/values.schema.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,7 +1171,7 @@
11711171
"type": "boolean",
11721172
"description": "If true, sets OTEL library logging to debug level (otherwise set to warning)"
11731173
},
1174-
"sampler": {
1174+
"sampling": {
11751175
"type": "object",
11761176
"properties": {
11771177
"type": {
@@ -1181,11 +1181,11 @@
11811181
},
11821182
"argument" : {
11831183
"type": "string",
1184-
"description": "Optional sampler type configuration value"
1184+
"description": "Optional - Sampling type specific configuration value. Such as the ratio for the Ratio sampling type."
11851185
},
11861186
"parentBased" : {
11871187
"type": "boolean",
1188-
"description": "Optional sets the sampling decision based on the Span’s parent, or absence of parent, to know which secondary sampler to use."
1188+
"description": "Optional - Determines if the sampling policy honors the remote root span sampled flag."
11891189
},
11901190
"additionalProperties": false
11911191
}

system/jlib/jtrace.cpp

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1407,19 +1407,19 @@ static std::unique_ptr<opentelemetry::sdk::trace::Sampler> createSampler(IProper
14071407
}
14081408
else if (streq(samplerType,"Ratio"))
14091409
{
1410-
double ratio = samplerTree->getPropReal("@argument");
1411-
if (ratio < 0 || ratio > 1)
1410+
double ratio = samplerTree->getPropReal("@argument", -1.0);
1411+
if (ratio >= 0.0 && ratio <= 1.0)
14121412
{
1413-
OERRLOG("JTrace invalid ratio sampler configuration. Ratio must be LE 1.0 or GE 0.0");
1413+
sampler.reset(new opentelemetry::sdk::trace::TraceIdRatioBasedSampler(ratio));
14141414
}
14151415
else
14161416
{
1417-
sampler.reset(new opentelemetry::sdk::trace::TraceIdRatioBasedSampler(ratio));
1417+
OERRLOG("JTrace invalid ratio sampling configuration. Ratio must be between 0.0 and 1.0");
14181418
}
14191419
}
14201420
else
14211421
{
1422-
WARNLOG("JTrace initialization: Invalid sampler type configured: '%s'", samplerType);
1422+
WARNLOG("JTrace initialization: Invalid sampling type configured: '%s'", samplerType);
14231423
}
14241424

14251425
if (sampler && samplerTree->getPropBool("@parentBased", true))
@@ -1429,12 +1429,6 @@ static std::unique_ptr<opentelemetry::sdk::trace::Sampler> createSampler(IProper
14291429
}
14301430
}
14311431

1432-
if (!sampler)
1433-
{
1434-
sampler.reset(new opentelemetry::sdk::trace::AlwaysOnSampler());
1435-
WARNLOG("JTrace sampler set to 'Always ON' by default!");
1436-
}
1437-
14381432
return sampler;
14391433
}
14401434

@@ -1464,7 +1458,7 @@ void CTraceManager::initTracerProviderAndGlobalInternals(const IPropertyTree * t
14641458
bool enableDefaultLogExporter = isDebugBuild();
14651459
if (traceConfig)
14661460
{
1467-
sampler = createSampler(traceConfig->queryPropTree("sampler"));
1461+
sampler = createSampler(traceConfig->queryPropTree("sampling"));
14681462

14691463
IPropertyTree * resourceAttributesTree = traceConfig->queryPropTree("resourceAttributes");
14701464
if (resourceAttributesTree)
@@ -1532,13 +1526,16 @@ Expected Configuration format:
15321526
disabled: true #optional - disable OTel tracing
15331527
alwaysCreateGlobalIds : false #optional - should global ids always be created?
15341528
alwaysCreateTraceIds #optional - should trace ids always be created?
1535-
sampler: #optional - controls how traces are either suppressed or sampled
1529+
sampling: #optional - controls how traces are either suppressed or sampled
15361530
type: #"AlwaysOff" | "AlwaysOn" | "Ratio"
1537-
argument: #optional sampler type configuration value
1538-
parentBased: #optional sets the sampling decision based on the Span’s parent, or absence of parent, to know which secondary sampler to use.
1539-
exporters: #optional - Controls how trace data is exported/reported
1540-
- type: OTLP #OS|OTLP|Prometheus|JLOG
1541-
endpoint: "localhost:4317" #exporter specific key/value pairs
1531+
argument: #optional - Generic argument dependent on sampling type used.
1532+
# For example, if Ratio sampling used, 'argument' represents
1533+
# the sampling ratio [0.0 - 1.0]
1534+
parentBased: #optional - Sets OTel's parentbased sampling option as defined here:
1535+
# https://opentelemetry.io/docs/languages/erlang/sampling/#parentbasedsampler
1536+
exporters: #optional - Controls how trace data is exported/reported
1537+
- type: OTLP #OS|OTLP|Prometheus|JLOG
1538+
endpoint: "localhost:4317" #exporter specific key/value pairs
15421539
useSslCredentials: true
15431540
sslCredentialsCACcert: "ssl-certificate"
15441541
batch: #optional - Controls span processing style

0 commit comments

Comments
 (0)