Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

[Bug]: Policy-engine sampler ignores the parent's sampling decision, producing orphan spans and partial traces

Open Beginner friendly
#3,735 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@lahiruudayakumara is already working on this.

Since Oct 13, 2026.

  • #3752 by @lahiruudayakumara — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
go
Domain
observability

Research direction

Start with gateway/gateway-runtime/policy-engine/internal/tracing/tracer.go at the sampler setup around lines 121–132, then compare its parent sampling behavior with the Envoy configuration in gateway/gateway-controller/pkg/xds/translator.go around line 2950. Reproduce using the supplied unsampled traceparent and tracing backend. Done when the policy engine honors the parent sampling decision and the reported request no longer produces orphan spans.

Written by the indexing model from the issue text.

Description

Area/Gateway Aspect/Monitoring Severity/Major Type/Bug
Please select the area the issue is related to

Gateway

Please select the aspect the issue is related to

Aspect/Monitoring (Metrics, observability, health checks, alerts)

Description

The policy engine uses AlwaysSample() when sampling_rate is 1.0 and TraceIDRatioBased(rate) otherwise (tracer.go L121-L132). Neither honours the sampled flag of the parent context, while Envoy samples with random_sampling (translator.go L2950).

  • Observed: a request with traceparent: ...-00 (not sampled). Envoy recorded no spans; the policy engine still exported 13 spans whose parent was never recorded (orphan spans).
  • From the code: with sampling_rate < 1, Envoy keeps a random fraction of requests and the policy engine keeps an independent fraction chosen by its own trace ID, so most retained traces will be missing one side.
Steps to Reproduce
  1. Enable [tracing] and a Jaeger/OTLP backend.
  2. Send a request with traceparent: 00-<trace-id>-<span-id>-00.
  3. Jaeger shows policy-engine spans whose parent span does not exist, and no router spans.

Expected: the policy engine follows the parent's sampling decision.

Suggested fix: sdktrace.ParentBased(sdktrace.TraceIDRatioBased(rate)). Together with #3734 the policy engine then follows Envoy's decision exactly; the ratio applies only when there is no parent.

Severity Level of the Issue

Severity/Major (Important functionality is broken. Should be prioritized. Doesn't need immediate attention)

Environment Details (with versions)

gateway-runtime and gateway-controller 2026.09.24 built from main (cba467a), Envoy 1.39.0, Jaeger 1.76. Code links pinned to 94c8527.

Dominant language
Go
Stars
76
Forks
126
Avg merge
2d 10h
Merged PRs (30d)
183

Getting set up

  • No Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from wso2/api-platform

All issues in wso2/api-platform

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.