Add ActivitySource to SamplingParameters #5376
Labels
enhancement
New feature or request
needs-spec-change
Issues which require the OpenTelemetry Specification to clarify or define behavior
The
SamplingParameters
struct almost mirrors theActivityCreationOptions
struct. Anyway, it has no reference to theActivitySource
that wants to create a newActivity
, unlike theActivityCreationOptions.Source
property.The absence of such property in the
SamplingParameters
prevents a sampler from making a decision based on criteria that include the activity source; in other words, activities are indistinguishable source-wise from the point of view of the sampler.Please note that sampling at
Sampler
level is not the same as including or not an activity source with theTracerProviderBuilder.AddSource
method. This is also because theAddSource
method accepts wildcards, which means that all matching activity sources will be included, with no way of removing specific ones. This can be useful when the list of desired activity sources is dynamic or initially unknown.At the moment, the only alternative to this is registering a filtering processor (a subclass of
BaseProcessor<Activity>
) that un-flags theActivity
as recorded, therefore making it unavailable for export.Anyway this approach has at least two major disadvantages:
Activity
is not the same as not creating it at all, since other processors /ActivityListener
s can still see it and cause side effects despite its trace flags.ActivityListener
s are "fair" (they do nothing if anActivity
is non-recorded), the filtering processor must be the first one to be executed; anyway, this cannot be taken as granted and there is no public way to reorder the processors.My suggestion is to add an
ActivitySource Source
property to theSamplingParameters
struct, that can be populated from the corresponding property in theActivityCreationOptions
struct.The text was updated successfully, but these errors were encountered: