public override void BeginSubsegment()

in sdk/src/Core/AWSXRayRecorder.cs [103:143]


        public override void BeginSubsegment(string name, DateTime? timestamp = null)
        {
            try
            {
                if (IsTracingDisabled())
                {
                    _logger.DebugFormat("X-Ray tracing is disabled, do not start subsegment");
                    return;
                }

                // If the request is not sampled, a segment will still be available in TraceContext to
                // stores the information of the trace. The trace information will still propagated to 
                // downstream service, in case downstream may overwrite the sample decision.
                Entity parentEntity = TraceContext.GetEntity();

                // If the segment is not sampled, do nothing and exit.
                if (parentEntity.Sampled != SampleDecision.Sampled)
                {
                    _logger.DebugFormat("Do not start subsegment because the segment doesn't get sampled. ({0})", name);
                    return;
                }

                Subsegment subsegment = new Subsegment(name);
                parentEntity.AddSubsegment(subsegment);
                subsegment.Sampled = parentEntity.Sampled;
                if (timestamp == null)
                {
                    subsegment.SetStartTimeToNow();
                }
                else
                {
                    subsegment.SetStartTime(timestamp.Value);
                }
                
                TraceContext.SetEntity(subsegment);
            }
            catch (EntityNotAvailableException e)
            {
                HandleEntityNotAvailableException(e, "Failed to start subsegment because the parent segment is not available.");
            }
        }