Skip to content

Split sampling rules into typed subclasses#76

Merged
rubenvanassche merged 2 commits into
mainfrom
sampling-rule-class-hierarchy
May 21, 2026
Merged

Split sampling rules into typed subclasses#76
rubenvanassche merged 2 commits into
mainfrom
sampling-rule-class-hierarchy

Conversation

@rubenvanassche

Copy link
Copy Markdown
Member

Summary

  • Move sampling rules from an enum-discriminated SamplingRule to an abstract class with one concrete subclass per rule type under src/Sampling/Rules/.
  • Add DeferredSamplerRule marker interface so rules that need a resolved handler can opt in. Rename DeferrableSampler::isPending()isDeferred() and swap the using() / usingDeferred() semantics so using() is the immediate-evaluation form.
  • Add SamplingAttributesProvider contract so providers can expose a cheap map (e.g. laravel.route.name) for rule matching, separate from the full toArray() payload that goes into spans.
  • Split JobAttributesProvider into QueuedJobAttributesProvider (queue side, no handler info) and JobAttributesProvider extends QueuedJobAttributesProvider, EntryPointHandlerProvider (execution side). CommandAttributesProvider now extends EntryPointHandlerProvider directly. Php* providers carry their own handler info, so the recorder-side defaults disappear from EntryPoint::setHandlerFromAttributesProvider.
  • Routing recorder folds the route attributes provider's toArray() into the routing span (parity with command/job).
  • SpansRecorder::endSpan short-circuits attribute-closure resolution when neither tracing nor reporting will keep the span.
  • Drop the array form of SamplingRule (SamplingRuleType enum + fromArray); rules are constructed directly via the static factories.
  • Bump the dev-main alias to 3.x-dev.

@rubenvanassche rubenvanassche merged commit 0a66334 into main May 21, 2026
9 checks passed
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.

1 participant