Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ActivitySource to SamplingParameters #5376

Closed
FstTesla opened this issue Feb 21, 2024 · 4 comments
Closed

Add ActivitySource to SamplingParameters #5376

FstTesla opened this issue Feb 21, 2024 · 4 comments
Labels
enhancement New feature or request needs-spec-change Issues which require the OpenTelemetry Specification to clarify or define behavior

Comments

@FstTesla
Copy link

The SamplingParameters struct almost mirrors the ActivityCreationOptions struct. Anyway, it has no reference to the ActivitySource that wants to create a new Activity, unlike the ActivityCreationOptions.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 the TracerProviderBuilder.AddSource method. This is also because the AddSource 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 the Activity as recorded, therefore making it unavailable for export.
Anyway this approach has at least two major disadvantages:

  • Creating a non-recorded Activity is not the same as not creating it at all, since other processors / ActivityListeners can still see it and cause side effects despite its trace flags.
  • Even admitting that all registered ActivityListeners are "fair" (they do nothing if an Activity 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 the SamplingParameters struct, that can be populated from the corresponding property in the ActivityCreationOptions struct.

@FstTesla FstTesla added the enhancement New feature or request label Feb 21, 2024
@vishweshbankwar
Copy link
Member

SamplingParameters follows the specification which does not contain ActivitySource/Scope information. https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/sdk.md#:~:text=to%20be%20created.-,Required%20arguments%3A,-Context%20with%20parent

Related: #4371

@cijothomas
Copy link
Member

open-telemetry/opentelemetry-specification#1942 More history. I was added, but then reverted.

@martinjt
Copy link
Member

There's a fine line implementing what the spec says, and what the SDK says is needed. I'm sure there are places in our SDK that we go beyond what the spec says as a minimum.

I don't see anywhere in the spec that say we "can't" or "Shouldn't" do it though.

That is to say, it's a choice that we're not going to pass it in within the .NET implementation. If we're not going to do this, I think we should close of this issue and give some closure for @FstTesla so they're not waiting on it.

@cijothomas
Copy link
Member

I don't see anywhere in the spec that say we "can't" or "Shouldn't" do it though.

Yes. Remember that scopes were added to samplinginput to the spec, but then reverted, and there are plenty of open spec issues, like open-telemetry/opentelemetry-specification#3867
We need to wait for spec resolution before making a new addition.

@FstTesla We are not adding it to OTel .NET, unless the spec is changed to allow that. It is possible that spec might be solving this problem in a different way. Please follow the spec issue for updates.

@cijothomas cijothomas added the needs-spec-change Issues which require the OpenTelemetry Specification to clarify or define behavior label Feb 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs-spec-change Issues which require the OpenTelemetry Specification to clarify or define behavior
Projects
None yet
Development

No branches or pull requests

4 participants