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

Using PerOperationSampler #38

Open
TioLuiso opened this issue Feb 18, 2019 · 3 comments
Open

Using PerOperationSampler #38

TioLuiso opened this issue Feb 18, 2019 · 3 comments

Comments

@TioLuiso
Copy link

Hello

I am just learning OpenTracing and Jaeger, so first of all, forgive me if the question is stupid.
Also, I have tried to find this issue but haven't found it

I am trying to use PerOperationSampler, because there are some operations that usually I don't want to be sampled, but others are critical and want sampled.

So at first I instantiate a PerOperationSampler, with a OperationSamplingParameters with a DefaultProbability (1.0d) and a collection of PerOperationSamplingParameters. One of them I assigned probability 0.0d. For the operation I use [Controller]/[Action]. That is what had some sense to me.

I run it, and I see that the operation is being traced. Then I delve into your code, and I believe I know the reason.

The outmost span the one that is being generated by HostingEventProvider. And the operationName isn't Controller/Action, but "HTTP GET" or "HTTP POST".

There is an inner span generated by MvcEventProcessor, that has the information that I want. its operation names are Controller/Action. But the filtering is done at the outer spans.

I see the reason in generating outer spans such as you are doing, but I believe that renders the PerOperationSampler quite useless, unless I want to filter all HTTP GETs.

Is there a solution for that? That is: Filtering per Controller/Action

@TioLuiso
Copy link
Author

Indeed, stupid me.

Paying more attention, I saw that the operationName for an action is **Action** [controller]/[Action]. Putting that, I can assign the probability well enough.
The only annoying thing is that the httpIn "HTTP POST" span will appear. But it's ok

@csurfleet
Copy link

I'm having the same issue - I can filter on HTTP POST or HTTP GET, but if I put e.g "Action MySampleApp.Controllers.ValuesController/POST" nothing is filtered.

My setup looks like this:
new PerOperationSampler(100000, new OperationSamplingParameters(1d, -1, new List<PerOperationSamplingParameters> { new PerOperationSamplingParameters("Action MySampleApp.Controllers.ValuesController/POST", new ProbabilisticSamplingStrategy(0)) }), sp.GetRequiredService<ILoggerFactory>());

@cwe1ss
Copy link
Collaborator

cwe1ss commented Dec 12, 2020

You could move the sampling to this library by ignoring requests based on an algorithm. Starting with v0.7.0 this libary does no longer create any child spans (EF Core, SQL, HTTP) if the request itself is ignored, so this should give you what you want.

builder.ConfigureAspNetCore(options =>
{
    options.Hosting.IgnorePatterns.Add(ctx =>
    {
        // Ignore 90% of requests = Sampling of 10%
        var newRandom = random.Next(100);
        return newRandom >= 10;
    });
});

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

No branches or pull requests

3 participants