Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions libraries/src/AWS.Lambda.Powertools.Tracing/Tracing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,20 @@ public static void WithSubsegment(string nameSpace, string name, Action<TracingS
XRayRecorder.Instance.SetNamespace(GetNamespaceOrDefault(nameSpace));
try
{
var entity = XRayRecorder.Instance.GetEntity() as TracingSubsegment;
subsegment?.Invoke(entity);
var entity = XRayRecorder.Instance.GetEntity();
var tracingSubsegment = new TracingSubsegment("## " + name);

// Copy properties from the current entity
if (entity != null)
{
if (entity is Subsegment subsegmentEntity)
{
tracingSubsegment.Namespace = subsegmentEntity.Namespace;
}
tracingSubsegment.Sampled = entity.Sampled;
}

subsegment?.Invoke(tracingSubsegment);
}
finally
{
Expand Down
Loading
Loading