示例#1
0
        /// <summary>
        /// Begin a tracing segment. A new tracing segment will be created and started.
        /// </summary>
        /// <param name="name">The name of the segment.</param>
        /// <param name="traceId">Trace id of the segment.</param>
        /// <param name="parentId">Unique id of the upstream remote segment or subsegment where the downstream call originated from.</param>
        /// <param name="sampleDecision">Sample decision for the segment from upstream service.</param>
        /// <exception cref="ArgumentNullException">The argument has a null value.</exception>
        public override void BeginSegment(string name, string traceId = null, string parentId = null, SampleDecision sampleDecision = SampleDecision.Sampled)
        {
            Segment newSegment = new Segment(name, traceId, parentId);

            if (!IsTracingDisabled())
            {
                newSegment.SetStartTimeToNow(); //sets current timestamp
                PopulateNewSegmentAttributes(newSegment);
            }

            newSegment.Sampled = sampleDecision;
            TraceContext.SetEntity(newSegment);
        }
        /// <summary>
        /// Perform sampling decison based on <see cref="SamplingInput"/>.
        /// </summary>
        /// <param name="input"> Instance of <see cref="SamplingInput"/>.</param>
        /// <returns>Instance of <see cref="SamplingResponse"/>.</returns>
        public SamplingResponse ShouldTrace(SamplingInput input)
        {
            SampleDecision sampleDecision = Sample(input.Host, input.Url, input.Method);

            return(new SamplingResponse(sampleDecision));
        }
 public SamplingResponse(SampleDecision sampleDecision)
 {
     SampleDecision = sampleDecision;
 }
 public SamplingResponse(string ruleName, SampleDecision sampleDecision) : this(sampleDecision)
 {
     RuleName = ruleName;
 }
        public static XRaySegment Create(IAWSXRayRecorder xRayRecorder, string serviceName, string traceHeader, SampleDecision sampleDecision = SampleDecision.Unknown)
        {
            GetSamplingDetails(xRayRecorder, serviceName, traceHeader, out string traceId, out SamplingResponse samplingResponse, out string parentId);

            xRayRecorder.BeginSegment(
                serviceName, traceId, parentId, sampleDecision == SampleDecision.Unknown ? samplingResponse : new SamplingResponse(sampleDecision));
            xRayRecorder.AddAnnotation("Environment", "Test");
            xRayRecorder.AddAnnotation("Version", "1.0");

            return(new XRaySegment(xRayRecorder));
        }
示例#6
0
 public XRaySegment Create(string serviceName, string traceHeader, SampleDecision sampleDecision = SampleDecision.Unknown)
 {
     return(XRaySegment.Create(_xRayRecorder, serviceName, traceHeader, sampleDecision));
 }