Skip to content

Sampling based on URL #1597

@pavolloffay

Description

@pavolloffay

What are you trying to achieve?

The Hypertrace agents collect all request and response data (headers and payloads). This data is not needed for every request, hence I would like to implement a sampler that would make a decision based on the URL/endpoint pattern when this data should be collected (e.g. one in 100 requests). The decision should be propagated to downstream services (e.g. via tracestate) to make the decision coherent across the transaction.

The custom sampler would make a decision whether to collect payload and headers, the span sampling would still go through the normal sampling process (e.g. my custom sampler would delegate to it).

To fully implement this use-case these parts are needed:

  • a custom sampler that has access to the URL
  • do not add payload and headers if the span is not sampled - instrumentation can check the tracestate (supported by the API) or drop the header and payload attributes in SpanProcessor#onEnd (not supported by the API).

What is missing in the spec to solve my use-case

The sampler does not have access to the URL. The sampler interface (at least in Java) accepts attributes, however the instrumentation (e.g. servlet in otel-java-instrumentation) is not passing URL attribute there nor spec mandates it to do it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:samplingRelated to trace samplingarea:semantic-conventionsRelated to semantic conventionsspec:traceRelated to the specification/trace directory

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions