Skip to content

Rework sampling_context #3746

Closed
Closed
@sentrivana

Description

@sentrivana

(custom_)sampling_context is a Sentry-specific concept that doesn't fit with how OTel works.

The purpose of a sampling_context is to provide extra external data to use for decision making in the traces_sampler. Right now, we're using it to make things like the transaction name, parent sampled decision, request object or queue name accessible in the sampler.

The goal is to store everything necessary on the span as attributes instead and expose those. However, since attribute types are very limited, we can't just save a custom object like e.g. the request as an attribute. Instead, we need to preprocess it into serializable attributes. For each integration, we need to see what important data we can extract and save on the span.

The idea:

  • no custom_sampling_context argument for start_transaction/start_span anymore
  • start_span instead gets an extra attributes argument which, when provided, prepopulates the attributes
  • integrations that were providing a custom_sampling_context will instead provide a set of prepopulated attributes (that can't be objects)
  • the sampling_context accessible in traces_sampler will change:
    • it'll contain all span attributes by default
    • it'll also contain the current data (transaction_context.name, transaction_context.op, parent_sampled) in some slightly modified form

Integrations that are currently setting a custom_sampling_context that will now have to set specific attributes:

Related:

Metadata

Metadata

Assignees

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions