Skip to content

HDDS-14814. Unify Fragmented Traces for Freon randomkeys Command#9957

Open
sravani-revuri wants to merge 3 commits intoapache:masterfrom
sravani-revuri:HDDS-14814
Open

HDDS-14814. Unify Fragmented Traces for Freon randomkeys Command#9957
sravani-revuri wants to merge 3 commits intoapache:masterfrom
sravani-revuri:HDDS-14814

Conversation

@sravani-revuri
Copy link
Contributor

What changes were proposed in this pull request?

Tracing for Freon randomkeys is currently fragmented and has the following issues:

  • Instead of a single trace for a command execution, multiple traces are being created. Therefore breaking the parent-child hierarchy.
  • The root span doesnt contain command name as it appears for ozone sh commands.
  • A single freon rk command creates multiple repetitive spans.

Proposed Changes:
Proper handling of spans is required to ensure a chain of spans is created for the same trace.
Implement span level sampling through custom sampler and enable it through OTEL_SPAN_SAMPLING.

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-14814

How was this patch tested?

Manual Testing through Jaeger UI and unit tests.

Running Regular Freon Command

Command:

ozone freon rk --numOfVolumes=1 --numOfBuckets=1 --numOfKeys=3 
OTEL_SPAN_SAMPLING=""

Output:

image

Running Span Sampling only

Command:

ozone freon rk --numOfVolumes=1 --numOfBuckets=4 --numOfKeys=2
OTEL_SPAN_SAMPLING=createVolume:1,createBucket:2,createKey:5

Output:

1 CreateVolume call:
image

2 CreateBucket calls:
image

1 CreateKey call:
image

Running Span Sampling with Trace Sampling

Command:

ozone freon rk --numOfVolumes=1 --numOfBuckets=1 --numOfKeys=10 
OTEL_TRACES_SAMPLER_ARG=0.5
OTEL_SPAN_SAMPLING=createVolume:1,createBucket:1,createKey:5

Output:

8 traces visible when command is run 16 times.

image

without sampling 180 spans are generated.

image

Copy link
Contributor

@Gargi-jais11 Gargi-jais11 left a comment

Choose a reason for hiding this comment

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

Thanks @sravani-revuri for the patch.
Left few comments.

@errose28 errose28 requested a review from sumitagrawl March 23, 2026 16:14
Copy link
Contributor

@sumitagrawl sumitagrawl left a comment

Choose a reason for hiding this comment

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

@sravani-revuri thanks for working over this, few comments given

spanSamplingConfig = spanStrConfig;
}
} catch (Exception ex) {
// ignore and use the default value.
Copy link
Contributor

Choose a reason for hiding this comment

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

need log warn for exception message and default behavior getting executed

private static Map<String, LoopSampler> parseSpanSamplingConfig(String configStr) {
Map<String, LoopSampler> result = new HashMap<>();
if (configStr == null || configStr.isEmpty()) {
return result;
Copy link
Contributor

Choose a reason for hiding this comment

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

can return Collection.emptyMap()


try {
// Long.parseLong strictly rejects decimals (throws NumberFormatException)
long interval = Long.parseLong(val);
Copy link
Contributor

Choose a reason for hiding this comment

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

take value as %cent and convert to sampling to unify with other configuration, %cent is easy configuration

result.put(name, new LoopSampler(interval));

} catch (NumberFormatException e) {
LOG.error("Invalid ratio '{}' for span '{}': decimals not allowed", val, name);
Copy link
Contributor

Choose a reason for hiding this comment

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

update error log with addition info, as, ignoring sample configuration.

String currentSpanContext = TracingUtil.exportCurrentSpan();
for (int i = 0; i < numOfThreads; i++) {
executor.execute(new ObjectCreator());
executor.execute(new ObjectCreator(currentSpanContext));
Copy link
Contributor

Choose a reason for hiding this comment

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

We can pass direct Current span, and test if works.

private static final String OTEL_EXPORTER_OTLP_ENDPOINT_DEFAULT = "http://localhost:4317";
private static final String OTEL_TRACES_SAMPLER_ARG = "OTEL_TRACES_SAMPLER_ARG";
private static final double OTEL_TRACES_SAMPLER_RATIO_DEFAULT = 1.0;
private static final String OTEL_SPAN_SAMPLING = "OTEL_SPAN_SAMPLING";
Copy link
Contributor

Choose a reason for hiding this comment

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

this can be renamed as, OTEL_SPAN_SAMPLER_ARG

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.

3 participants