static ActivitySamplingResult Sample(ref ActivityCreationOptions <ActivityContext> options)
            {
                //Trace id has to be accessed in sample to reproduce the scenario when SetParentId does not work
                var _ = options.TraceId;

                return(ActivitySamplingResult.PropagationData);
            };
        static ActivitySamplingResult ComputeActivitySamplingResult(ref ActivityCreationOptions <ActivityContext> options)
        {
            Assert.Equal("35aae61e3e99044eb5ea5007f2cd159b", options.TraceId.ToHexString());
            Assert.Equal("40a8bd87c078cb4c", options.Parent.SpanId.ToHexString());

            return(ActivitySamplingResult.AllDataAndRecorded);
        }
Exemple #3
0
        public void AddOmexActivitySource_ActivityCreationEnabled(bool shouldListen, ActivitySamplingResult sample, ActivitySamplingResult sampleUsingParent)
        {
            IOptionsMonitor <OmexActivityListenerOptions> optionsMock = CreateOptionsMonitor();

            optionsMock.CurrentValue.ShouldListenTo      = shouldListen;
            optionsMock.CurrentValue.Sample              = sample;
            optionsMock.CurrentValue.SampleUsingParentId = sampleUsingParent;

            IActivityListenerConfigurator configurator = new DefaultActivityListenerConfigurator(optionsMock);

            ActivityCreationOptions <ActivityContext> sampleContext            = new ActivityCreationOptions <ActivityContext>();
            ActivityCreationOptions <string>          sampleUsingParentContext = new ActivityCreationOptions <string>();

            Assert.AreEqual(shouldListen, configurator.ShouldListenTo(new ActivitySource("Some")));
            Assert.AreEqual(sample, configurator.Sample(ref sampleContext));
            Assert.AreEqual(sampleUsingParent, configurator.SampleUsingParentId(ref sampleUsingParentContext));
        }
Exemple #4
0
 public ActivitySamplingResult SampleUsingParentId(ref ActivityCreationOptions <string> options)
 {
     // Return
     return(ActivitySamplingResult.AllData);
 }
Exemple #5
0
 public ActivitySamplingResult Sample(ref ActivityCreationOptions <ActivityContext> options)
 {
     // Return
     return(ActivitySamplingResult.AllData);
 }
 static ActivitySamplingResult SampleUsingParentId(ref ActivityCreationOptions <string> options) => ActivitySamplingResult.PropagationData;
 static ActivitySamplingResult Sample(ref ActivityCreationOptions <ActivityContext> options) => ActivitySamplingResult.PropagationData;
 private ActivitySamplingResult SampleUsingParentId(ref ActivityCreationOptions <string> options)
 {
     return(ActivitySamplingResult.AllData);
 }
 private ActivitySamplingResult Sample(ref ActivityCreationOptions <ActivityContext> options)
 {
     return(ActivitySamplingResult.AllData);
 }
Exemple #10
0
 private ActivitySamplingResult Sample(ref ActivityCreationOptions <ActivityContext> options) =>
 m_configurator.Sample(ref options);
Exemple #11
0
 private ActivitySamplingResult SampleUsingParentId(ref ActivityCreationOptions <string> options) =>
 m_configurator.SampleUsingParentId(ref options);
Exemple #12
0
 /// <summary>
 /// Always sample.
 /// </summary>
 /// <param name="options">The options.</param>
 /// <returns>a result.</returns>
 private ActivitySamplingResult Sample(ref ActivityCreationOptions <ActivityContext> options) => ActivitySamplingResult.AllDataAndRecorded;