From 0bcaeba8f10159ea20107eaf91e9b051e4ee99f0 Mon Sep 17 00:00:00 2001 From: Vincent Costel <46972+Costo@users.noreply.github.com> Date: Fri, 17 May 2024 16:06:19 -0400 Subject: [PATCH 1/3] Fix for Activity Recorded flag not being propagated --- .../Diagnostics/ActivityPropagationGrainCallFilter.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Orleans.Core/Diagnostics/ActivityPropagationGrainCallFilter.cs b/src/Orleans.Core/Diagnostics/ActivityPropagationGrainCallFilter.cs index 7dc2cac921..5c4769c8cc 100644 --- a/src/Orleans.Core/Diagnostics/ActivityPropagationGrainCallFilter.cs +++ b/src/Orleans.Core/Diagnostics/ActivityPropagationGrainCallFilter.cs @@ -144,7 +144,8 @@ public Task Invoke(IIncomingGrainCallContext context) var source = GetActivitySource(context); if (!string.IsNullOrEmpty(traceParent)) { - activity = source.CreateActivity(context.Request.GetActivityName(), ActivityKind.Server, traceParent); + ActivityContext.TryParse(traceParent, traceState, isRemote: true, out ActivityContext parentContext); + activity = source.CreateActivity(context.Request.GetActivityName(), ActivityKind.Server, parentContext); if (activity is not null) { From ed3170efe6a41ca675e0a597e32dc6a989ba955f Mon Sep 17 00:00:00 2001 From: Vincent Costel <46972+Costo@users.noreply.github.com> Date: Fri, 17 May 2024 16:06:19 -0400 Subject: [PATCH 2/3] Fix for Activity Recorded flag not being propagated --- .../Diagnostics/ActivityPropagationGrainCallFilter.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Orleans.Core/Diagnostics/ActivityPropagationGrainCallFilter.cs b/src/Orleans.Core/Diagnostics/ActivityPropagationGrainCallFilter.cs index 7dc2cac921..5c4769c8cc 100644 --- a/src/Orleans.Core/Diagnostics/ActivityPropagationGrainCallFilter.cs +++ b/src/Orleans.Core/Diagnostics/ActivityPropagationGrainCallFilter.cs @@ -144,7 +144,8 @@ public Task Invoke(IIncomingGrainCallContext context) var source = GetActivitySource(context); if (!string.IsNullOrEmpty(traceParent)) { - activity = source.CreateActivity(context.Request.GetActivityName(), ActivityKind.Server, traceParent); + ActivityContext.TryParse(traceParent, traceState, isRemote: true, out ActivityContext parentContext); + activity = source.CreateActivity(context.Request.GetActivityName(), ActivityKind.Server, parentContext); if (activity is not null) { From f2bc9f638ae6a0edee8c50ebea907fd1f2fd19bf Mon Sep 17 00:00:00 2001 From: Vincent Costel <46972+Costo@users.noreply.github.com> Date: Mon, 3 Jun 2024 19:53:59 -0400 Subject: [PATCH 3/3] Fix failing activity propagation test --- .../ActivityPropagationGrainCallFilter.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Orleans.Core/Diagnostics/ActivityPropagationGrainCallFilter.cs b/src/Orleans.Core/Diagnostics/ActivityPropagationGrainCallFilter.cs index 5c4769c8cc..29ecebbcaa 100644 --- a/src/Orleans.Core/Diagnostics/ActivityPropagationGrainCallFilter.cs +++ b/src/Orleans.Core/Diagnostics/ActivityPropagationGrainCallFilter.cs @@ -144,8 +144,16 @@ public Task Invoke(IIncomingGrainCallContext context) var source = GetActivitySource(context); if (!string.IsNullOrEmpty(traceParent)) { - ActivityContext.TryParse(traceParent, traceState, isRemote: true, out ActivityContext parentContext); - activity = source.CreateActivity(context.Request.GetActivityName(), ActivityKind.Server, parentContext); + if (ActivityContext.TryParse(traceParent, traceState, isRemote: true, out ActivityContext parentContext)) + { + // traceParent is a W3CId + activity = source.CreateActivity(context.Request.GetActivityName(), ActivityKind.Server, parentContext); + } + else + { + // Most likely, traceParent uses ActivityIdFormat.Hierarchical + activity = source.CreateActivity(context.Request.GetActivityName(), ActivityKind.Server, traceParent); + } if (activity is not null) {