/// <summary>
        /// Streams subsegments of instance of <see cref="Entity"/>.
        /// </summary>
        /// <param name="entity">Instance of <see cref="Entity"/>.</param>
        /// <param name="emitter">Instance of <see cref="ISegmentEmitter"/>.</param>
        public void Stream(Entity entity, ISegmentEmitter emitter)
        {
            lock (entity.Subsegments)
            {
                foreach (var next in entity.Subsegments)
                {
                    Stream(next, emitter);
                }

                entity.Subsegments.RemoveAll(x => x.HasStreamed);
            }

            if (entity is Segment || entity.IsInProgress || entity.Reference > 0 || entity.IsSubsegmentsAdded)
            {
                return;
            }

            Subsegment subsegment = entity as Subsegment;

            subsegment.TraceId  = entity.RootSegment.TraceId;
            subsegment.Type     = "subsegment";
            subsegment.ParentId = subsegment.Parent.Id;
            emitter.Send(subsegment);
            subsegment.RootSegment.DecrementSize();
            subsegment.HasStreamed = true;
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AWSXRayRecorder" /> class
        /// with given instance of <see cref="ISegmentEmitter" />.
        /// </summary>
        /// <param name="emitter">Segment emitter</param>
        internal AWSXRayRecorder(ISegmentEmitter emitter) : base(emitter)
        {
            PopulateContexts();

            if (IsLambda())
            {
                SamplingStrategy = new LocalizedSamplingStrategy();
            }
            else
            {
                SamplingStrategy = new DefaultSamplingStrategy();
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AWSXRayRecorder" /> class
        /// with given instance of <see cref="ISegmentEmitter" /> and instance of <see cref="XRayOptions"/>.
        /// </summary>
        /// <param name="emitter">Instance of <see cref="ISegmentEmitter"/>.</param>
        /// <param name="options">Instance of <see cref="XRayOptions"/>.</param>
        internal AWSXRayRecorder(ISegmentEmitter emitter, XRayOptions options) : base(emitter)
        {
            XRayOptions = options;
            PopulateContexts();

            if (IsLambda())
            {
                SamplingStrategy = new LocalizedSamplingStrategy(options.SamplingRuleManifest);
            }
            else
            {
                SamplingStrategy = new DefaultSamplingStrategy(options.SamplingRuleManifest);
            }
        }
Esempio n. 4
0
        public static AWSXRayRecorder BuildAWSXRayRecorder(ISamplingStrategy samplingStrategy = null, ISegmentEmitter segmentEmitter = null, string daemonAddress = null, ITraceContext traceContext = null)
        {
            AWSXRayRecorderBuilder builder = new AWSXRayRecorderBuilder();

            if (samplingStrategy != null)
            {
                builder.WithSamplingStrategy(samplingStrategy);
            }
            if (segmentEmitter != null)
            {
                builder.WithSegmentEmitter(segmentEmitter);
            }
            if (!string.IsNullOrEmpty(daemonAddress))
            {
                builder.WithDaemonAddress(daemonAddress);
            }
            if (traceContext != null)
            {
                builder.WithTraceContext(traceContext);
            }

            var result = builder.Build();

            return(result);
        }
Esempio n. 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AWSXRayRecorder" /> class
 /// with given instance of <see cref="ISegmentEmitter" />.
 /// </summary>
 /// <param name="emitter">Segment emitter</param>
 internal AWSXRayRecorder(ISegmentEmitter emitter) : base(emitter)
 {
     PopulateContexts();
     SamplingStrategy = new LocalizedSamplingStrategy(XRayOptions.SamplingRuleManifest);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="AWSXRayRecorder" /> class
 /// with given instance of <see cref="ISegmentEmitter" /> and instance of <see cref="XRayOptions"/>.
 /// </summary>
 /// <param name="emitter">Instance of <see cref="ISegmentEmitter"/>.</param>
 /// <param name="options">Instance of <see cref="XRayOptions"/>.</param>
 public AWSXRayRecorder(ISegmentEmitter emitter, XRayOptions options) : base(emitter)
 {
     XRayOptions = options;
     PopulateContexts();
     SamplingStrategy = new LocalizedSamplingStrategy(options.SamplingRuleManifest);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="AWSXRayRecorder" /> class
 /// with given instance of <see cref="ISegmentEmitter" />.
 /// </summary>
 /// <param name="emitter">Segment emitter</param>
 internal AWSXRayRecorder(ISegmentEmitter emitter) : base(emitter)
 {
     PopulateContexts();
     SamplingStrategy = new DefaultSamplingStrategy(AppSettings.SamplingRuleManifest);
 }
 protected AWSXRayRecorderImpl(ISegmentEmitter emitter)
 {
     this._emitter = emitter;
 }
Esempio n. 9
0
 /// <summary>
 /// Adds the provided <see cref="ISegmentEmitter"/> instance.
 /// </summary>
 /// <param name="segmentEmitter">The provided <see cref="ISegmentEmitter"/> instance.</param>
 /// <returns>The builder with ISegmentEmitter added.</returns>
 public AWSXRayRecorderBuilder WithSegmentEmitter(ISegmentEmitter segmentEmitter)
 {
     _segmentEmitter = segmentEmitter ?? throw new ArgumentNullException("SegmentEmitter");
     return(this);
 }
 /// <summary>
 /// Used for unit tests to create a mock implementation. Not intended for production applications.
 /// </summary>
 /// <param name="emitter"></param>
 public static AWSXRayRecorder CreateAWSXRayRecorder(ISegmentEmitter emitter)
 {
     return(new AWSXRayRecorder(emitter));
 }
        private static AWSXRayRecorder BuildAWSXRayRecorder(ISamplingStrategy samplingStrategy, ISegmentEmitter segmentEmitter = null)
        {
            AWSXRayRecorderBuilder builder;

            if (segmentEmitter != null)
            {
                builder = new AWSXRayRecorderBuilder()
                          .WithSamplingStrategy(samplingStrategy).WithSegmentEmitter(segmentEmitter);
            }
            else
            {
                builder = new AWSXRayRecorderBuilder()
                          .WithSamplingStrategy(samplingStrategy);
            }

            var result = builder.Build();

            return(result);
        }
 public void Stream(Entity entity, ISegmentEmitter emitter)
 {
     throw new NotImplementedException();
 }