Skip to content

Allow skipping some of orleans traces #9673

@Meir017

Description

@Meir017

Specifically these -

  • IGrainTimerInvoker/InvokeCallbackAsync
    • IDeploymentLoadPublisher/UpdateRuntimeStatistics
  • IMembershipService/Ping

these traces are part of the orleans core runtime and not something interesting.

I still want to collect the traces for custom grains I create. (I believe it's the same trace).

We could inject a configuration object with list of activity names to trace -

var activity = source.StartActivity(context.Request.GetActivityName(), ActivityKind.Client);

these are especially annoying when running locally, these traces make it hard to see other traces

basically make this conditional.

introduce

public class ActivityPropagationOptions
{
    public string[] ActivityNamesToSkip { get; set; }  = [];
}
    internal class ActivityPropagationOutgoingGrainCallFilter : ActivityPropagationGrainCallFilter, IOutgoingGrainCallFilter
    {
        private readonly DistributedContextPropagator _propagator;
+       private readonly IOptions<ActivityPropagationOptions> _options;

        /// <summary>
        /// Initializes a new instance of the <see cref="ActivityPropagationOutgoingGrainCallFilter"/> class.
        /// </summary>
        /// <param name="propagator">The context propagator.</param>
-       public ActivityPropagationOutgoingGrainCallFilter(DistributedContextPropagator propagator)
+       public ActivityPropagationOutgoingGrainCallFilter(DistributedContextPropagator propagator, IOptions<ActivityPropagationOptions> options)
        {
            _propagator = propagator;
+           _options = options;
        }

        /// <inheritdoc />
        public Task Invoke(IOutgoingGrainCallContext context)
        {
            var source = GetActivitySource(context);
+           if (options.ActivityNamesToSkip.Contains(context.Request.GetActivityName()))
+           {
+               return context.Invoke();
+           }
            var activity = source.StartActivity(context.Request.GetActivityName(), ActivityKind.Client);

            if (activity is null)
            {
                return context.Invoke();
            }

            _propagator.Inject(activity, null, static (carrier, key, value) => RequestContext.Set(key, value));
            return Process(context, activity);
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions